Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb07933d

Browse files
feature#32475 [Process] Deprecate Process::inheritEnvironmentVariables() (ogizanagi)
This PR was merged into the 4.4 branch.Discussion----------[Process] Deprecate Process::inheritEnvironmentVariables()| Q | A| ------------- | ---| Branch? | 4.4 <!-- see below -->| Bug fix? | no| New feature? | no <!-- please update src/**/CHANGELOG.md files -->| BC breaks? | no <!-- seehttps://symfony.com/bc -->| Deprecations? | yes <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->| Tests pass? | yes <!-- please add some, will be required by reviewers -->| Fixed tickets | N/A <!-- #-prefixed issue number(s), if any -->| License | MIT| Doc PR | N/AIIUC, this method was kept as a BC layer from 3.4 to 4.0 to switch to the "inherit env vars" behavior, inciting developers to opt-in in 3.4. Since 4.0, env vars are always inherited, and this method doesn't allow to opt-out. So, time to remove it?---refs:-#21470-#22836Commits-------af9bad3 [Process] Deprecate Process::inheritEnvironmentVariables()
2 parents1d3db3d +af9bad3 commitb07933d

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
@@ -118,6 +118,11 @@ MonologBridge
118118
--------------
119119

120120
* The `RouteProcessor` has been marked final.
121+
122+
Process
123+
-------
124+
125+
* Deprecated the `Process::inheritEnvironmentVariables()` method: env variables are always inherited.
121126

122127
PropertyAccess
123128
--------------

‎UPGRADE-5.0.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,7 @@ MonologBridge
334334
Process
335335
-------
336336

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

‎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]) :newProcess('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
publicfunctioninheritEnvironmentVariables($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
thrownewInvalidArgumentException('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 =newProcess($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)

[8]ページ先頭

©2009-2025 Movatter.jp