From 2cb9630320370109a733b214049b6c2028712307 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Tue, 26 Jan 2021 15:54:21 +0100 Subject: [PATCH] Fix $_SERVER var not being updated when using putenv, refs b80038804ff791a9d4608d737ad937b6033b0bae and fixes #9372 --- src/Composer/EventDispatcher/EventDispatcher.php | 2 ++ src/Composer/Util/Git.php | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Composer/EventDispatcher/EventDispatcher.php b/src/Composer/EventDispatcher/EventDispatcher.php index 3d4542a96..52b26d98e 100644 --- a/src/Composer/EventDispatcher/EventDispatcher.php +++ b/src/Composer/EventDispatcher/EventDispatcher.php @@ -234,6 +234,8 @@ class EventDispatcher if (substr($exec, 0, 8) === '@putenv ') { putenv(substr($exec, 8)); + list($var, $value) = explode('=', substr($exec, 8), 2); + $_SERVER[$var] = $value; continue; } elseif (substr($exec, 0, 5) === '@php ') { diff --git a/src/Composer/Util/Git.php b/src/Composer/Util/Git.php index cdb559712..cd714c7e8 100644 --- a/src/Composer/Util/Git.php +++ b/src/Composer/Util/Git.php @@ -347,7 +347,7 @@ class Git // added in git 1.7.1, prevents prompting the user for username/password if (getenv('GIT_ASKPASS') !== 'echo') { putenv('GIT_ASKPASS=echo'); - unset($_SERVER['GIT_ASKPASS']); + $_SERVER['GIT_ASKPASS'] = 'echo'; } // clean up rogue git env vars in case this is running in a git hook @@ -363,6 +363,7 @@ class Git // Run processes with predictable LANGUAGE if (getenv('LANGUAGE') !== 'C') { putenv('LANGUAGE=C'); + $_SERVER['LANGUAGE'] = 'C'; } // clean up env for OSX, see https://github.com/composer/composer/issues/2146#issuecomment-35478940