-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Process] intersect with getenv() to populate default envs #44070
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
Conversation
nicolas-grekas
commented
Nov 16, 2021
Q | A |
---|---|
Branch? | 4.4 |
Bug fix? | yes |
New feature? | no |
Deprecations? | no |
Tickets | Fix #44066 |
License | MIT |
Doc PR | - |
72c52b9
to
77f8f52
Compare
77f8f52
to
f608f0b
Compare
$env = getenv(); | ||
$env = array_intersect_key($env, $_SERVER) ?: $env; |
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 means if the current running process has added env vars putenv(), they still won't be detected though. One has to update $_SERVER + do putenv() for it to be taken into account.
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.
That's right, we are intentionally not compatible with putenv() here, because using putenv leads to blank pages in Windows
$env = []; | ||
|
||
foreach ($_SERVER as $k => $v) { | ||
if (\is_string($v) && false !== $v = getenv($k)) { |
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.
Removal of the is_string check seems to be allowing arrays to get in to the env array as values. This causes an error "ErrorException Array to string conversion" when the env vars are read as a string in the start() method()
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.
Already fixed, see #44208
Please create issue instead of commenting on closed PRs to report issue btw.