From b1aed48e1ae26de30ad14b874a22fc95bdcfbe8a Mon Sep 17 00:00:00 2001 From: johnstevenson Date: Thu, 2 Nov 2017 13:53:09 +0000 Subject: [PATCH] Fix bug setting COMPOSER_ORIGINAL_INIS This variable stores the loaded ini file and any additional scanned ini files, separated by a path-separator. The loaded ini file should always be present, even if it is an empty value. Unfortunately I removed any empty value to parse the ini files, then used the truncated list to set the variable. This bug surfaced on docker php images. These do not have a specific php.ini but store all their settings in the location(s) configured at build time using --with-config-file-scan-dir. --- src/Composer/XdebugHandler.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Composer/XdebugHandler.php b/src/Composer/XdebugHandler.php index f7fd8c2a1..e9d719abf 100644 --- a/src/Composer/XdebugHandler.php +++ b/src/Composer/XdebugHandler.php @@ -139,11 +139,6 @@ class XdebugHandler $iniPaths = IniHelper::getAll(); $additional = count($iniPaths) > 1; - if (empty($iniPaths[0])) { - // There is no loaded ini - array_shift($iniPaths); - } - if ($this->writeTmpIni($iniPaths)) { return $this->setEnvironment($additional, $iniPaths); } @@ -156,20 +151,25 @@ class XdebugHandler * * The filename is passed as the -c option when the process restarts. * - * @param array $iniFiles The php.ini locations + * @param array $iniPaths Locations reported by the current process * * @return bool */ - private function writeTmpIni(array $iniFiles) + private function writeTmpIni(array $iniPaths) { if (!$this->tmpIni = tempnam(sys_get_temp_dir(), '')) { return false; } + // $iniPaths has at least one item and it may be empty + if (empty($iniPaths[0])) { + array_shift($iniPaths); + } + $content = ''; $regex = '/^\s*(zend_extension\s*=.*xdebug.*)$/mi'; - foreach ($iniFiles as $file) { + foreach ($iniPaths as $file) { $data = preg_replace($regex, ';$1', file_get_contents($file)); $content .= $data.PHP_EOL; } @@ -203,7 +203,7 @@ class XdebugHandler * Returns true if the restart environment variables were set * * @param bool $additional Whether there were additional inis - * @param array $iniPaths Locations used by the current prcoess + * @param array $iniPaths Locations reported by the current process * * @return bool */