diff --git a/UPGRADE-4.4.md b/UPGRADE-4.4.md index 8ffb10d4091f..eb403fcba26a 100644 --- a/UPGRADE-4.4.md +++ b/UPGRADE-4.4.md @@ -102,6 +102,11 @@ MonologBridge -------------- * The `RouteProcessor` has been marked final. + +Process +------- + + * Deprecated the `Process::inheritEnvironmentVariables()` method: env variables are always inherited. PropertyAccess -------------- diff --git a/UPGRADE-5.0.md b/UPGRADE-5.0.md index 36ed24ff692a..80339859900f 100644 --- a/UPGRADE-5.0.md +++ b/UPGRADE-5.0.md @@ -319,6 +319,7 @@ MonologBridge Process ------- + * Removed the `Process::inheritEnvironmentVariables()` method: env variables are always inherited. * Removed the `Process::setCommandline()` and the `PhpProcess::setPhpBinary()` methods. * Commands must be defined as arrays when creating a `Process` instance. diff --git a/src/Symfony/Bundle/WebServerBundle/WebServer.php b/src/Symfony/Bundle/WebServerBundle/WebServer.php index 978c5bb17a59..97be6c95f0c9 100644 --- a/src/Symfony/Bundle/WebServerBundle/WebServer.php +++ b/src/Symfony/Bundle/WebServerBundle/WebServer.php @@ -167,7 +167,11 @@ private function createServerProcess(WebServerConfig $config) if (\in_array('APP_ENV', explode(',', getenv('SYMFONY_DOTENV_VARS')))) { $process->setEnv(['APP_ENV' => false]); - $process->inheritEnvironmentVariables(); + + if (!method_exists(Process::class, 'fromShellCommandline')) { + // Symfony 3.4 does not inherit env vars by default: + $process->inheritEnvironmentVariables(); + } } return $process; diff --git a/src/Symfony/Component/Dotenv/Dotenv.php b/src/Symfony/Component/Dotenv/Dotenv.php index 66a2c105a883..0d695a4b3097 100644 --- a/src/Symfony/Component/Dotenv/Dotenv.php +++ b/src/Symfony/Component/Dotenv/Dotenv.php @@ -402,7 +402,12 @@ private function resolveCommands($value) } $process = method_exists(Process::class, 'fromShellCommandline') ? Process::fromShellCommandline('echo '.$matches[0]) : new Process('echo '.$matches[0]); - $process->inheritEnvironmentVariables(true); + + if (!method_exists(Process::class, 'fromShellCommandline')) { + // Symfony 3.4 does not inherit env vars by default: + $process->inheritEnvironmentVariables(); + } + $process->setEnv($this->values); try { $process->mustRun(); diff --git a/src/Symfony/Component/Process/CHANGELOG.md b/src/Symfony/Component/Process/CHANGELOG.md index 31d063852e9d..a0f55b52bcc2 100644 --- a/src/Symfony/Component/Process/CHANGELOG.md +++ b/src/Symfony/Component/Process/CHANGELOG.md @@ -1,6 +1,11 @@ CHANGELOG ========= +4.4.0 +----- + +* deprecated `Process::inheritEnvironmentVariables()`: env variables are always inherited. + 4.2.0 ----- diff --git a/src/Symfony/Component/Process/Process.php b/src/Symfony/Component/Process/Process.php index 755a574de6b4..34cf9b8a51f5 100644 --- a/src/Symfony/Component/Process/Process.php +++ b/src/Symfony/Component/Process/Process.php @@ -1210,9 +1210,13 @@ public function setInput($input) * @param bool $inheritEnv * * @return self The current Process instance + * + * @deprecated since Symfony 4.4, env variables are always inherited */ public function inheritEnvironmentVariables($inheritEnv = true) { + @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.4, env variables are always inherited.', __METHOD__), E_USER_DEPRECATED); + if (!$inheritEnv) { throw new InvalidArgumentException('Not inheriting environment variables is not supported.'); } diff --git a/src/Symfony/Component/Process/Tests/ProcessTest.php b/src/Symfony/Component/Process/Tests/ProcessTest.php index 1ee9b3c43dcb..6318355727b2 100644 --- a/src/Symfony/Component/Process/Tests/ProcessTest.php +++ b/src/Symfony/Component/Process/Tests/ProcessTest.php @@ -1405,7 +1405,6 @@ public function testSetBadEnv() { $process = $this->getProcess('echo hello'); $process->setEnv(['bad%%' => '123']); - $process->inheritEnvironmentVariables(true); $process->run(); @@ -1419,7 +1418,6 @@ public function testEnvBackupDoesNotDeleteExistingVars() $_ENV['existing_var'] = 'foo'; $process = $this->getProcess('php -r "echo getenv(\'new_test_var\');"'); $process->setEnv(['existing_var' => 'bar', 'new_test_var' => 'foo']); - $process->inheritEnvironmentVariables(); $process->run(); @@ -1581,7 +1579,6 @@ private function getProcess($commandline, string $cwd = null, array $env = null, } else { $process = new Process($commandline, $cwd, $env, $input, $timeout); } - $process->inheritEnvironmentVariables(); if (self::$process) { self::$process->stop(0); diff --git a/src/Symfony/Component/VarDumper/Tests/Dumper/ServerDumperTest.php b/src/Symfony/Component/VarDumper/Tests/Dumper/ServerDumperTest.php index b4bef49cd3f9..c52ec191d8b8 100644 --- a/src/Symfony/Component/VarDumper/Tests/Dumper/ServerDumperTest.php +++ b/src/Symfony/Component/VarDumper/Tests/Dumper/ServerDumperTest.php @@ -88,7 +88,6 @@ private function getServerProcess(): Process 'COMPONENT_ROOT' => __DIR__.'/../../', 'VAR_DUMPER_SERVER' => self::VAR_DUMPER_SERVER, ]); - $process->inheritEnvironmentVariables(true); return $process->setTimeout(9); } diff --git a/src/Symfony/Component/VarDumper/Tests/Server/ConnectionTest.php b/src/Symfony/Component/VarDumper/Tests/Server/ConnectionTest.php index 21902b5cf1aa..dd895453cb44 100644 --- a/src/Symfony/Component/VarDumper/Tests/Server/ConnectionTest.php +++ b/src/Symfony/Component/VarDumper/Tests/Server/ConnectionTest.php @@ -81,7 +81,6 @@ private function getServerProcess(): Process 'COMPONENT_ROOT' => __DIR__.'/../../', 'VAR_DUMPER_SERVER' => self::VAR_DUMPER_SERVER, ]); - $process->inheritEnvironmentVariables(true); return $process->setTimeout(9); } diff --git a/src/Symfony/Component/VarDumper/composer.json b/src/Symfony/Component/VarDumper/composer.json index 727e50f3cfbb..085efe4467e1 100644 --- a/src/Symfony/Component/VarDumper/composer.json +++ b/src/Symfony/Component/VarDumper/composer.json @@ -23,7 +23,7 @@ "require-dev": { "ext-iconv": "*", "symfony/console": "^3.4|^4.0|^5.0", - "symfony/process": "^3.4|^4.0|^5.0", + "symfony/process": "^4.4|^5.0", "twig/twig": "~1.34|~2.4" }, "conflict": {
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: