diff --git a/CHANGELOG.md b/CHANGELOG.md index c6761c0e9..84f9fd79a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,11 @@ * Fixed suggest output being very spammy, it now is only one line long and shows more rarely * Fixed conflict rules like e.g. >=5 from matching dev-master, as it is not normalized to 9999999-dev internally anymore +### [1.10.5] 2020-04-10 + + * Fixed self-update on PHP <5.6, seriously please upgrade people, it's time + * Fixed 1.10.2 regression with PATH resolution in scripts + ### [1.10.4] 2020-04-09 * Fixed 1.10.2 regression in path symlinking with absolute path repos @@ -863,6 +868,7 @@ * Initial release +[1.10.5]: https://github.com/composer/composer/compare/1.10.4...1.10.5 [1.10.4]: https://github.com/composer/composer/compare/1.10.3...1.10.4 [1.10.3]: https://github.com/composer/composer/compare/1.10.2...1.10.3 [1.10.2]: https://github.com/composer/composer/compare/1.10.1...1.10.2 diff --git a/src/Composer/Command/SelfUpdateCommand.php b/src/Composer/Command/SelfUpdateCommand.php index 554be607e..3bc482e63 100644 --- a/src/Composer/Command/SelfUpdateCommand.php +++ b/src/Composer/Command/SelfUpdateCommand.php @@ -85,7 +85,7 @@ EOT // switch channel if requested $requestedChannel = null; - foreach (Versions::CHANNELS as $channel) { + foreach (Versions::$channels as $channel) { if ($input->getOption($channel)) { $requestedChannel = $channel; $versionsUtil->setChannel($channel); diff --git a/src/Composer/EventDispatcher/EventDispatcher.php b/src/Composer/EventDispatcher/EventDispatcher.php index 463fd46d4..6cbb0c314 100644 --- a/src/Composer/EventDispatcher/EventDispatcher.php +++ b/src/Composer/EventDispatcher/EventDispatcher.php @@ -248,6 +248,13 @@ class EventDispatcher } } + // if composer is being executed, make sure it runs the expected composer from current path + // resolution, even if bin-dir contains composer too because the project requires composer/composer + // see https://github.com/composer/composer/issues/8748 + if (substr($exec, 0, 9) === 'composer ') { + $exec = $this->getPhpExecCommand() . ' ' . ProcessExecutor::escape(getenv('COMPOSER_BINARY')) . substr($exec, 8); + } + if (0 !== ($exitCode = $this->executeTty($exec))) { $this->io->writeError(sprintf('Script %s handling the %s event returned with error code '.$exitCode.'', $callable, $event->getName()), true, IOInterface::QUIET); @@ -535,10 +542,7 @@ class EventDispatcher if (is_dir($binDir)) { $binDir = realpath($binDir); if (isset($_SERVER[$pathStr]) && !preg_match('{(^|'.PATH_SEPARATOR.')'.preg_quote($binDir).'($|'.PATH_SEPARATOR.')}', $_SERVER[$pathStr])) { - // prepend the COMPOSER_BINARY dir to the path to make sure that scripts running "composer" will run the expected composer - // from current path resolution, even if bin-dir contains composer too because the project requires composer/composer - // see https://github.com/composer/composer/issues/8748 - $_SERVER[$pathStr] = dirname(getenv('COMPOSER_BINARY')).PATH_SEPARATOR.$binDir.PATH_SEPARATOR.getenv($pathStr); + $_SERVER[$pathStr] = $binDir.PATH_SEPARATOR.getenv($pathStr); putenv($pathStr.'='.$_SERVER[$pathStr]); } } diff --git a/src/Composer/SelfUpdate/Versions.php b/src/Composer/SelfUpdate/Versions.php index 4d89e5ecb..a03a75054 100644 --- a/src/Composer/SelfUpdate/Versions.php +++ b/src/Composer/SelfUpdate/Versions.php @@ -21,7 +21,7 @@ use Composer\Json\JsonFile; */ class Versions { - const CHANNELS = array('stable', 'preview', 'snapshot', '1', '2'); + public static $channels = array('stable', 'preview', 'snapshot', '1', '2'); private $httpDownloader; private $config; @@ -52,8 +52,8 @@ class Versions public function setChannel($channel) { - if (!in_array($channel, self::CHANNELS, true)) { - throw new \InvalidArgumentException('Invalid channel '.$channel.', must be one of: ' . implode(', ', self::CHANNELS)); + if (!in_array($channel, self::$channels, true)) { + throw new \InvalidArgumentException('Invalid channel '.$channel.', must be one of: ' . implode(', ', self::$channels)); } $channelFile = $this->config->get('home').'/update-channel';