-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Description
Q | A |
---|---|
Bug report? | yes |
Feature request? | no |
BC Break report? | no |
RFC? | no |
Symfony version | 4.0.9 |
Hi !
First of all, thanks for your great framework. More than being a very well designed and usefull tool, it shows the best practices, so it is the best thing to study how PHP work.
However, I've been confronted to a bug while trying to access my route "/".
I got as error : Exception thrown when handling an exception (ErrorException: Warning: preg_match(): Unknown modifier '#')
I couldn't find anything similar on the web so I looked at the logs which were saying
Uncaught PHP Exception ErrorException: "Warning: preg_match(): Unknown modifier '#'" at ~/vendor/symfony/http-foundation/Request.php line 1171
I added this code at the specified line to see where the error came from dump($pattern); die();
and I had "#localhost##i". I had to surround the variable $pattern
with "/" to see what was my problem (which was kind of stupid btw...).
Second time I reproduced this bug, the dump only showed "#localhost#i".
I'm writting this as an issue as anybody can fall into this bug and this can help them to solve their initial problem instead of losing time on this one. Also it might not be the only case where the error can be found.
How to reproduce the bug
I'm currently on MacOS X High Sierra 10.13.4. My PHP version is 7.2.4 (installed with Homebrew) and I was using the Symfony dev server. I used the dotenv recipe, and modified two line in the .env file :
TRUSTED_PROXIES=127.0.0.1#,127.0.0.2
TRUSTED_HOSTS=localhost#,example.com
// Moved the # after 127.0.0.1 and after localhost instead of beginning of the line