-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[WebServerBundle] fix a bug where require would not require the good file because of env #25523
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WebServerBundle] fix a bug where require would not require the good file because of env #25523
Conversation
05888ce
to
cdd1c58
Compare
@@ -32,6 +32,10 @@ | ||
|
||
$script = getenv('APP_FRONT_CONTROLLER') ?: 'index.php'; | ||
|
||
if (false === getenv('APP_FRONT_CONTROLLER')) { | ||
$script = $_ENV['APP_FRONT_CONTROLLER']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not good, it should not squash the ternary above (when the env var doesn't exist, the value should remain 'index.php'). No need for calling getenv twice also
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed
cdd1c58
to
cd1dafa
Compare
Status: Needs Review |
@@ -33,6 +33,7 @@ public function __construct($documentRoot, $env, $address = null, $router = null | ||
} | ||
|
||
putenv('APP_FRONT_CONTROLLER='.$file); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to just remove putenv
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should keep it because like @ostrolucky said there could be cases where $_ENV could be empty
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also think we should remove the call to putenv (but alongside with -dvariable_order)
and then, symfony/process should be bumped to symfony/process ^3.4.2
in the bundle's composer.json
There should be some investigation regarding general usage of getenv/putenv/$_ENV/$_SERVER in Symfony code. I've seen people on slack too who complained that $_SERVER is not populated with Apache, but $_ENV is. I have tried it now with apache and neither $_SERVER nor $_ENV is populated, but getenv() is. When env is set via .htaccess, both $_SERVER and getenv is populated, but $_ENV isn't Then there are concurrency issues with getenv()/putenv() and now this PHP bug(?). Other than these bugs(?), there are also several other disadvantages for env variables. Old parameters.yml seems sweeter and sweeter to me as time goes on. |
Status: Needs Review |
$script = getenv('APP_FRONT_CONTROLLER') ?: 'index.php'; | ||
$script = getenv('APP_FRONT_CONTROLLER'); | ||
|
||
if (isset($_ENV['APP_FRONT_CONTROLLER']) && false === $script) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this doesn't work when "E" is not listed in variables_order
, which is the default on Ubuntu
note that this file is used only with php -S
so we don't care behavior on Apache
I'd suggest to add -dvariables_order=EGPCS
when calling php -S
, and then we can get rid of the call to getenv completely
Should it target 3.3? This code did not change in 3.4 AFAIK |
2bbab0f
to
4fdf6d8
Compare
i'll rebase on 3.3, tell me if it's better to rebase on 3.4. The things is the bug appear only on 3.4 but hey, it could be on 3.3 too I guess. |
4fdf6d8
to
7f69bf8
Compare
7f69bf8
to
9352603
Compare
@Simperfit you forgot to account for this comment (just replace ^3.4.2 by ^3.3.14 since you rebased on 3.3):
|
9352603
to
2a878a4
Compare
…file because of env
2a878a4
to
bfeee1f
Compare
done @nicolas-grekas |
@Simperfit not quite: ^3.3.14 != ~3.3.14 ;) |
Thank you @Simperfit. |
…e the good file because of env (Simperfit) This PR was merged into the 3.3 branch. Discussion ---------- [WebServerBundle] fix a bug where require would not require the good file because of env | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no <!-- don't forget to update src/**/CHANGELOG.md files --> | BC breaks? | no | Deprecations? | no <!-- don't forget to update UPGRADE-*.md files --> | Tests pass? | yes | Fixed tickets | #25515 | License | MIT | Doc PR | This fixes a bug with putenv that could be not working on certain version of php. (>=7.0.0). Commits ------- bfeee1f [WebServerBundle] fix a bug where require would not require the good file because of env
@@ -19,7 +19,7 @@ | ||
"php": "^5.5.9|>=7.0.8", | ||
"symfony/console": "~3.3", | ||
"symfony/http-kernel": "~3.3", | ||
"symfony/process": "~3.3" | ||
"symfony/process": "~3.3.14" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this now forbids using 3.4, so not good. Should be ~3.3.14 || ^3.4.2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
was patched while merged, see 743be09
This fixes a bug with putenv that could be not working on certain version of php. (>=7.0.0).