Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Environment variables are not inherited when $_ENV is empty #26451

Closed
@hongaar

Description

@hongaar
Q A
Bug report? yes
Feature request? no
BC Break report? not sure
RFC? no
Symfony version >=3.3

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() in Process::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:

$_ENV = [];
$process = new PhpProcess(<<<EOF
<?php var_dump(getenv()); ?>
EOF
);
$process->setEnv(getenv()); // <-- comment out this line to see bug
$process->run();

echo "<pre>".$process->getOutput();

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions