Skip to content

Commit af9bad3

Browse files
committed
[Process] Deprecate Process::inheritEnvironmentVariables()
1 parent d3c17f2 commit af9bad3

File tree

10 files changed

+27
-8
lines changed

10 files changed

+27
-8
lines changed

UPGRADE-4.4.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,11 @@ MonologBridge
102102
--------------
103103

104104
* The `RouteProcessor` has been marked final.
105+
106+
Process
107+
-------
108+
109+
* Deprecated the `Process::inheritEnvironmentVariables()` method: env variables are always inherited.
105110

106111
PropertyAccess
107112
--------------

UPGRADE-5.0.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,7 @@ MonologBridge
319319
Process
320320
-------
321321

322+
* Removed the `Process::inheritEnvironmentVariables()` method: env variables are always inherited.
322323
* Removed the `Process::setCommandline()` and the `PhpProcess::setPhpBinary()` methods.
323324
* Commands must be defined as arrays when creating a `Process` instance.
324325

src/Symfony/Bundle/WebServerBundle/WebServer.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,11 @@ private function createServerProcess(WebServerConfig $config)
167167

168168
if (\in_array('APP_ENV', explode(',', getenv('SYMFONY_DOTENV_VARS')))) {
169169
$process->setEnv(['APP_ENV' => false]);
170-
$process->inheritEnvironmentVariables();
170+
171+
if (!method_exists(Process::class, 'fromShellCommandline')) {
172+
// Symfony 3.4 does not inherit env vars by default:
173+
$process->inheritEnvironmentVariables();
174+
}
171175
}
172176

173177
return $process;

src/Symfony/Component/Dotenv/Dotenv.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,12 @@ private function resolveCommands($value)
402402
}
403403

404404
$process = method_exists(Process::class, 'fromShellCommandline') ? Process::fromShellCommandline('echo '.$matches[0]) : new Process('echo '.$matches[0]);
405-
$process->inheritEnvironmentVariables(true);
405+
406+
if (!method_exists(Process::class, 'fromShellCommandline')) {
407+
// Symfony 3.4 does not inherit env vars by default:
408+
$process->inheritEnvironmentVariables();
409+
}
410+
406411
$process->setEnv($this->values);
407412
try {
408413
$process->mustRun();

src/Symfony/Component/Process/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
4.4.0
5+
-----
6+
7+
* deprecated `Process::inheritEnvironmentVariables()`: env variables are always inherited.
8+
49
4.2.0
510
-----
611

src/Symfony/Component/Process/Process.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,9 +1210,13 @@ public function setInput($input)
12101210
* @param bool $inheritEnv
12111211
*
12121212
* @return self The current Process instance
1213+
*
1214+
* @deprecated since Symfony 4.4, env variables are always inherited
12131215
*/
12141216
public function inheritEnvironmentVariables($inheritEnv = true)
12151217
{
1218+
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.4, env variables are always inherited.', __METHOD__), E_USER_DEPRECATED);
1219+
12161220
if (!$inheritEnv) {
12171221
throw new InvalidArgumentException('Not inheriting environment variables is not supported.');
12181222
}

src/Symfony/Component/Process/Tests/ProcessTest.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1405,7 +1405,6 @@ public function testSetBadEnv()
14051405
{
14061406
$process = $this->getProcess('echo hello');
14071407
$process->setEnv(['bad%%' => '123']);
1408-
$process->inheritEnvironmentVariables(true);
14091408

14101409
$process->run();
14111410

@@ -1419,7 +1418,6 @@ public function testEnvBackupDoesNotDeleteExistingVars()
14191418
$_ENV['existing_var'] = 'foo';
14201419
$process = $this->getProcess('php -r "echo getenv(\'new_test_var\');"');
14211420
$process->setEnv(['existing_var' => 'bar', 'new_test_var' => 'foo']);
1422-
$process->inheritEnvironmentVariables();
14231421

14241422
$process->run();
14251423

@@ -1581,7 +1579,6 @@ private function getProcess($commandline, string $cwd = null, array $env = null,
15811579
} else {
15821580
$process = new Process($commandline, $cwd, $env, $input, $timeout);
15831581
}
1584-
$process->inheritEnvironmentVariables();
15851582

15861583
if (self::$process) {
15871584
self::$process->stop(0);

src/Symfony/Component/VarDumper/Tests/Dumper/ServerDumperTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ private function getServerProcess(): Process
8888
'COMPONENT_ROOT' => __DIR__.'/../../',
8989
'VAR_DUMPER_SERVER' => self::VAR_DUMPER_SERVER,
9090
]);
91-
$process->inheritEnvironmentVariables(true);
9291

9392
return $process->setTimeout(9);
9493
}

src/Symfony/Component/VarDumper/Tests/Server/ConnectionTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ private function getServerProcess(): Process
8181
'COMPONENT_ROOT' => __DIR__.'/../../',
8282
'VAR_DUMPER_SERVER' => self::VAR_DUMPER_SERVER,
8383
]);
84-
$process->inheritEnvironmentVariables(true);
8584

8685
return $process->setTimeout(9);
8786
}

src/Symfony/Component/VarDumper/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"require-dev": {
2424
"ext-iconv": "*",
2525
"symfony/console": "^3.4|^4.0|^5.0",
26-
"symfony/process": "^3.4|^4.0|^5.0",
26+
"symfony/process": "^4.4|^5.0",
2727
"twig/twig": "~1.34|~2.4"
2828
},
2929
"conflict": {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

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:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy