From b3dbd953323632734c9af8b9304ad94abd026519 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Fri, 10 Apr 2020 11:33:06 +0200 Subject: [PATCH 1/3] Fix PHP <5.6 syntax, fixes #8759, closes #8760 --- src/Composer/Command/SelfUpdateCommand.php | 2 +- src/Composer/SelfUpdate/Versions.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Composer/Command/SelfUpdateCommand.php b/src/Composer/Command/SelfUpdateCommand.php index 9984f1547..925270ade 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/SelfUpdate/Versions.php b/src/Composer/SelfUpdate/Versions.php index f6f31b249..01d01e7e3 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 $rfs; 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'; From 2f7e90194028fc90dbddc3293a08e5c607688d43 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Fri, 10 Apr 2020 11:42:52 +0200 Subject: [PATCH 2/3] Fix #8748 in an alternative way to avoid messing with PATH for other binaries, fixes #8758 --- src/Composer/EventDispatcher/EventDispatcher.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Composer/EventDispatcher/EventDispatcher.php b/src/Composer/EventDispatcher/EventDispatcher.php index 2e9b03c80..6b2449d99 100644 --- a/src/Composer/EventDispatcher/EventDispatcher.php +++ b/src/Composer/EventDispatcher/EventDispatcher.php @@ -247,6 +247,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->process->execute($exec))) { $this->io->writeError(sprintf('Script %s handling the %s event returned with error code '.$exitCode.'', $callable, $event->getName()), true, IOInterface::QUIET); @@ -547,10 +554,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]); } } From 8e2e9caf6a5021a1afbbc0aae1e32937024f249d Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Fri, 10 Apr 2020 11:44:13 +0200 Subject: [PATCH 3/3] Update changelog --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 39f4a70e6..2d41be6a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +### [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 @@ -841,6 +846,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