Closed
Description
Q | A |
---|---|
Bug report? | yes |
Feature request? | no |
BC Break report? | no |
RFC? | no |
Symfony version | 4.0.2 |
<?php // process.php
var_dump(getenv('MY_VARIABLE'));
<?php // runner.php
require_once __DIR__ . '/vendor/autoload.php';
$process = new \Symfony\Component\Process\Process(
'php process.php',
__DIR__,
['MY_VARIABLE' => '']
);
$process->run();
echo $process->getOutput();
Symfony 4.0.0, 4.0.1:
$ php runner.php
string(0) ""
Symfony 4.0.2:
$ php runner.php
bool(false)
This is probably related to PHP bug https://bugs.php.net/bug.php?id=71868 and was perhaps caused by changes in #25417 & #24924 (cc @nicolas-grekas ).
Symfony until 4.0.1 did not pass the variables to proc_open (which is where the PHP bug comes into an effect).
The workaround in 4.0.2 I found is to pass the variables in a "key=value" format:
Process('php process.php', __DIR__, ['MY_VARIABLE=']);
(though I don't know what could be broken by this...)
In our CLI app we depend on the original behavior (ie. empty value of the variable is what we expect, and has different meaning than "variable not set at all"), and as this is impact of PHP bug, it would be nice if Symfony could still workaround it.