From b18a29b6f4daa416fa0fe2c9b28f17e7134c1c77 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 22 Nov 2021 23:02:22 +0100 Subject: [PATCH 1/3] [Process] exclude argv/argc from possible default env vars --- Process.php | 1 + 1 file changed, 1 insertion(+) diff --git a/Process.php b/Process.php index 77094820..b516344b 100644 --- a/Process.php +++ b/Process.php @@ -1673,6 +1673,7 @@ private function getDefaultEnv(): array { $env = getenv(); $env = array_intersect_key($env, $_SERVER) ?: $env; + unset($env['argc'], $env['argv']); foreach ($_ENV as $k => $v) { if (\is_string($v)) { From c2098705326addae6e6742151dfade47ac71da1b Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 22 Nov 2021 23:30:31 +0100 Subject: [PATCH 2/3] [Process] filter env vars for "argc" & "argv" specifically --- Process.php | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-) diff --git a/Process.php b/Process.php index b516344b..d5c697cf 100644 --- a/Process.php +++ b/Process.php @@ -340,7 +340,7 @@ public function start(callable $callback = null, array $env = []) $envPairs = []; foreach ($env as $k => $v) { - if (false !== $v) { + if (false !== $v && 'argc' !== $k && 'argv' !== $k) { $envPairs[] = $k.'='.$v; } } @@ -1171,25 +1171,12 @@ public function getEnv() /** * Sets the environment variables. * - * Each environment variable value should be a string. - * If it is an array, the variable is ignored. - * If it is false or null, it will be removed when - * env vars are otherwise inherited. - * - * That happens in PHP when 'argv' is registered into - * the $_ENV array for instance. - * - * @param array $env The new environment variables + * @param array $env The new environment variables * * @return $this */ public function setEnv(array $env) { - // Process can not handle env values that are arrays - $env = array_filter($env, function ($value) { - return !\is_array($value); - }); - $this->env = $env; return $this; @@ -1673,14 +1660,7 @@ private function getDefaultEnv(): array { $env = getenv(); $env = array_intersect_key($env, $_SERVER) ?: $env; - unset($env['argc'], $env['argv']); - - foreach ($_ENV as $k => $v) { - if (\is_string($v)) { - $env[$k] = $v; - } - } - return $env; + return $_ENV + $env; } } From e8f02d0795d3852e2e0169dc7660786e9de30859 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 23 Nov 2021 15:18:55 +0100 Subject: [PATCH 3/3] [Messenger][Process] Add SensioLabs as a backer to the README --- README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/README.md b/README.md index afce5e45..8777de4a 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,17 @@ Process Component The Process component executes commands in sub-processes. +Sponsor +------- + +The Process component for Symfony 5.4/6.0 is [backed][1] by [SensioLabs][2]. + +As the creator of Symfony, SensioLabs supports companies using Symfony, with an +offering encompassing consultancy, expertise, services, training, and technical +assistance to ensure the success of web application development projects. + +Help Symfony by [sponsoring][3] its development! + Resources --------- @@ -11,3 +22,7 @@ Resources * [Report issues](https://github.com/symfony/symfony/issues) and [send Pull Requests](https://github.com/symfony/symfony/pulls) in the [main Symfony repository](https://github.com/symfony/symfony) + +[1]: https://symfony.com/backers +[2]: https://sensiolabs.com +[3]: https://symfony.com/sponsor