Skip to content

[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

Merged
merged 1 commit into from
Nov 16, 2021

Conversation

nicolas-grekas
Copy link
Member

Q A
Branch? 4.4
Bug fix? yes
New feature? no
Deprecations? no
Tickets Fix #44066
License MIT
Doc PR -

@nicolas-grekas nicolas-grekas merged commit e70ad34 into symfony:4.4 Nov 16, 2021
@nicolas-grekas nicolas-grekas deleted the proc-getenv branch November 16, 2021 15:12
This was referenced Nov 18, 2021
Comment on lines +1674 to +1675
$env = getenv();
$env = array_intersect_key($env, $_SERVER) ?: $env;
Copy link
Member

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.

Copy link
Member Author

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)) {
Copy link

@devsi devsi Nov 23, 2021

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()

Copy link
Member Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants