-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Environment variables are not inherited when $_ENV is empty #26451
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
Comments
The env is inherited using the values in both |
If I'm not mistaken, On the other hand, |
getenv() with no arguments exists only since 7.1. $_SERVER also contains the env vars. |
Snap, I missed that from the docs. Thanks for the clarification. |
I think I traced it down to being an issue with PHPs built-in web server. <?php
# test.php
var_dump($_SERVER);
var_dump($_ENV);
var_dump(getenv()); And run with
A simple workaround for this would be (granted you're on PHP >= 7.1): if (php_sapi_name() === "cli-server") {
$_ENV = getenv();
} Or running the server with |
It looks like starting with version 3.3.x in the
symfony/process
component, there's an issue with inheriting environment variables when$_ENV
is empty - which is the recommended setup for production systems (see http://php.net/manual/en/reserved.variables.environment.php#98113).Could be solved by including an extra loop with
getenv()
inProcess::getDefaultEnv()
, but not sure if there's a rationale to not do this.This bug might cause hard to find bugs - i.e. I discovered this issue after debugging an issue for hours where a headless chrome instance wouldn't listen to the specified port when ran with
--remote-debugging-port=9222
, turned out it was missing some - apparently - critical env vars.Reproduce:
Edit: seems to conflict with #25559, though I think that could be solved by introducing a loop and filtering out all non-string values, like in the other loops.
The text was updated successfully, but these errors were encountered: