diff --git a/src/Composer/Command/CreateProjectCommand.php b/src/Composer/Command/CreateProjectCommand.php index f5d87d303..65366dfe2 100644 --- a/src/Composer/Command/CreateProjectCommand.php +++ b/src/Composer/Command/CreateProjectCommand.php @@ -316,7 +316,8 @@ EOT $io->writeError('Created project in ' . $directory . ''); chdir($directory); - putenv('COMPOSER_ROOT_VERSION='.$package->getPrettyVersion()); + $_SERVER['COMPOSER_ROOT_VERSION'] = $package->getPrettyVersion(); + putenv('COMPOSER_ROOT_VERSION='.$_SERVER['COMPOSER_ROOT_VERSION']); return $installedFromVcs; } diff --git a/src/Composer/Command/RunScriptCommand.php b/src/Composer/Command/RunScriptCommand.php index 979f86a02..8b5b13d2a 100644 --- a/src/Composer/Command/RunScriptCommand.php +++ b/src/Composer/Command/RunScriptCommand.php @@ -87,7 +87,8 @@ EOT // add the bin dir to the PATH to make local binaries of deps usable in scripts $binDir = $composer->getConfig()->get('bin-dir'); if (is_dir($binDir)) { - putenv('PATH='.realpath($binDir).PATH_SEPARATOR.getenv('PATH')); + $_SERVER['PATH'] = realpath($binDir).PATH_SEPARATOR.getenv('PATH'); + putenv('PATH='.$_SERVER['PATH']); } $args = $input->getArgument('args'); diff --git a/src/Composer/Command/ScriptAliasCommand.php b/src/Composer/Command/ScriptAliasCommand.php index 958678068..b8f0abff5 100644 --- a/src/Composer/Command/ScriptAliasCommand.php +++ b/src/Composer/Command/ScriptAliasCommand.php @@ -57,7 +57,8 @@ EOT // add the bin dir to the PATH to make local binaries of deps usable in scripts $binDir = $composer->getConfig()->get('bin-dir'); if (is_dir($binDir)) { - putenv('PATH='.realpath($binDir).PATH_SEPARATOR.getenv('PATH')); + $_SERVER['PATH'] = realpath($binDir).PATH_SEPARATOR.getenv('PATH'); + putenv('PATH='.$_SERVER['PATH']); } $args = $input->getArguments(); diff --git a/src/Composer/Util/Git.php b/src/Composer/Util/Git.php index e965384e7..34b686d9a 100644 --- a/src/Composer/Util/Git.php +++ b/src/Composer/Util/Git.php @@ -164,18 +164,22 @@ 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']); } // clean up rogue git env vars in case this is running in a git hook if (getenv('GIT_DIR')) { putenv('GIT_DIR'); + unset($_SERVER['GIT_DIR']); } if (getenv('GIT_WORK_TREE')) { putenv('GIT_WORK_TREE'); + unset($_SERVER['GIT_WORK_TREE']); } // clean up env for OSX, see https://github.com/composer/composer/issues/2146#issuecomment-35478940 putenv("DYLD_LIBRARY_PATH"); + unset($_SERVER['DYLD_LIBRARY_PATH']); } public static function getGitHubDomainsRegex(Config $config) diff --git a/src/Composer/Util/ProcessExecutor.php b/src/Composer/Util/ProcessExecutor.php index 60e48a9b9..e7cfa3dcc 100644 --- a/src/Composer/Util/ProcessExecutor.php +++ b/src/Composer/Util/ProcessExecutor.php @@ -56,7 +56,7 @@ class ProcessExecutor $this->captureOutput = count(func_get_args()) > 1; $this->errorOutput = null; - $process = new Process($command, $cwd, array('LANGUAGE' => 'C') + $_ENV + $_SERVER, null, static::getTimeout()); + $process = new Process($command, $cwd, array_replace($_ENV, $_SERVER, array('LANGUAGE' => 'C')), null, static::getTimeout()); $callback = is_callable($output) ? $output : array($this, 'outputHandler'); $process->run($callback); diff --git a/src/Composer/Util/Svn.php b/src/Composer/Util/Svn.php index af7dc6cbd..9ba08bf85 100644 --- a/src/Composer/Util/Svn.php +++ b/src/Composer/Util/Svn.php @@ -81,6 +81,7 @@ class Svn { // clean up env for OSX, see https://github.com/composer/composer/issues/2146#issuecomment-35478940 putenv("DYLD_LIBRARY_PATH"); + unset($_SERVER['DYLD_LIBRARY_PATH']); } /** diff --git a/tests/Composer/Test/AllFunctionalTest.php b/tests/Composer/Test/AllFunctionalTest.php index 6670cc4fa..1b720ad29 100644 --- a/tests/Composer/Test/AllFunctionalTest.php +++ b/tests/Composer/Test/AllFunctionalTest.php @@ -42,7 +42,8 @@ class AllFunctionalTest extends \PHPUnit_Framework_TestCase } if ($this->oldenv) { $fs->removeDirectory(getenv('COMPOSER_HOME')); - putenv('COMPOSER_HOME='.$this->oldenv); + $_SERVER['COMPOSER_HOME'] = $this->oldenv; + putenv('COMPOSER_HOME='.$_SERVER['COMPOSER_HOME']); $this->oldenv = null; } } @@ -86,7 +87,8 @@ class AllFunctionalTest extends \PHPUnit_Framework_TestCase $testData = $this->parseTestFile($testFile); $this->oldenv = getenv('COMPOSER_HOME'); - putenv('COMPOSER_HOME='.$this->testDir.'home'); + $_SERVER['COMPOSER_HOME'] = $this->testDir.'home'; + putenv('COMPOSER_HOME='.$_SERVER['COMPOSER_HOME']); $cmd = 'php '.escapeshellarg(self::$pharPath).' --no-ansi '.$testData['RUN']; $proc = new Process($cmd, __DIR__.'/Fixtures/functional', null, null, 300);