-
-
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1671,13 +1671,8 @@ private function replacePlaceholders(string $commandline, array $env) | |
|
||
private function getDefaultEnv(): array | ||
{ | ||
$env = []; | ||
|
||
foreach ($_SERVER as $k => $v) { | ||
if (\is_string($v) && false !== $v = getenv($k)) { | ||
$env[$k] = $v; | ||
} | ||
} | ||
$env = getenv(); | ||
$env = array_intersect_key($env, $_SERVER) ?: $env; | ||
Comment on lines
+1674
to
+1675
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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 |
||
|
||
foreach ($_ENV as $k => $v) { | ||
if (\is_string($v)) { | ||
|
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.