From 0dd58115835624a2be8293c372e777294a4bb2da Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Fri, 10 Feb 2023 14:19:02 +0100 Subject: [PATCH 1/6] Ensure we have a bool for plugin-optional --- src/Composer/Plugin/PluginManager.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Composer/Plugin/PluginManager.php b/src/Composer/Plugin/PluginManager.php index 74c33221e..a6c662c84 100644 --- a/src/Composer/Plugin/PluginManager.php +++ b/src/Composer/Plugin/PluginManager.php @@ -187,7 +187,7 @@ class PluginManager } } - if (!$this->isPluginAllowed($package->getName(), $isGlobalPlugin, $package->getExtra()['plugin-optional'] ?? false)) { + if (!$this->isPluginAllowed($package->getName(), $isGlobalPlugin, (bool) ($package->getExtra()['plugin-optional'] ?? false))) { $this->io->writeError('Skipped loading "'.$package->getName() . '" '.($isGlobalPlugin || $this->runningInGlobalDir ? '(installed globally) ' : '').'as it is not in config.allow-plugins', true, IOInterface::DEBUG); return; @@ -370,7 +370,7 @@ class PluginManager if ($sourcePackage === null) { trigger_error('Calling PluginManager::addPlugin without $sourcePackage is deprecated, if you are using this please get in touch with us to explain the use case', E_USER_DEPRECATED); - } elseif (!$this->isPluginAllowed($sourcePackage->getName(), $isGlobalPlugin, $sourcePackage->getExtra()['plugin-optional'] ?? false)) { + } elseif (!$this->isPluginAllowed($sourcePackage->getName(), $isGlobalPlugin, (bool) ($sourcePackage->getExtra()['plugin-optional'] ?? false))) { $this->io->writeError('Skipped loading "'.get_class($plugin).' from '.$sourcePackage->getName() . '" '.($isGlobalPlugin || $this->runningInGlobalDir ? '(installed globally) ' : '').' as it is not in config.allow-plugins', true, IOInterface::DEBUG); return; From b7810314130bce6ffdaf5c9f26e50224a18d2b4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Noco=C5=84?= Date: Fri, 10 Feb 2023 21:12:30 +0100 Subject: [PATCH 2/6] Added optional plugin check in PluginInstaller (#11318) --- src/Composer/Installer/PluginInstaller.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Composer/Installer/PluginInstaller.php b/src/Composer/Installer/PluginInstaller.php index 68326462e..bae1d938b 100644 --- a/src/Composer/Installer/PluginInstaller.php +++ b/src/Composer/Installer/PluginInstaller.php @@ -50,7 +50,7 @@ class PluginInstaller extends LibraryInstaller { // fail install process early if it is going to fail due to a plugin not being allowed if (($type === 'install' || $type === 'update') && !$this->getPluginManager()->arePluginsDisabled('local')) { - $this->getPluginManager()->isPluginAllowed($package->getName(), false); + $this->getPluginManager()->isPluginAllowed($package->getName(), false, $package->getExtra()['plugin-optional'] ?? false); } return parent::prepare($type, $package, $prevPackage); From d35cb21749629408dd695c49506a87aceb8f62c5 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Fri, 10 Feb 2023 21:13:30 +0100 Subject: [PATCH 3/6] Match plugin-optional more strictly --- src/Composer/Installer/PluginInstaller.php | 2 +- src/Composer/Plugin/PluginManager.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Composer/Installer/PluginInstaller.php b/src/Composer/Installer/PluginInstaller.php index bae1d938b..3a982f13b 100644 --- a/src/Composer/Installer/PluginInstaller.php +++ b/src/Composer/Installer/PluginInstaller.php @@ -50,7 +50,7 @@ class PluginInstaller extends LibraryInstaller { // fail install process early if it is going to fail due to a plugin not being allowed if (($type === 'install' || $type === 'update') && !$this->getPluginManager()->arePluginsDisabled('local')) { - $this->getPluginManager()->isPluginAllowed($package->getName(), false, $package->getExtra()['plugin-optional'] ?? false); + $this->getPluginManager()->isPluginAllowed($package->getName(), false, true === ($package->getExtra()['plugin-optional'] ?? false)); } return parent::prepare($type, $package, $prevPackage); diff --git a/src/Composer/Plugin/PluginManager.php b/src/Composer/Plugin/PluginManager.php index a6c662c84..14eb40211 100644 --- a/src/Composer/Plugin/PluginManager.php +++ b/src/Composer/Plugin/PluginManager.php @@ -187,7 +187,7 @@ class PluginManager } } - if (!$this->isPluginAllowed($package->getName(), $isGlobalPlugin, (bool) ($package->getExtra()['plugin-optional'] ?? false))) { + if (!$this->isPluginAllowed($package->getName(), $isGlobalPlugin, true === ($package->getExtra()['plugin-optional'] ?? false))) { $this->io->writeError('Skipped loading "'.$package->getName() . '" '.($isGlobalPlugin || $this->runningInGlobalDir ? '(installed globally) ' : '').'as it is not in config.allow-plugins', true, IOInterface::DEBUG); return; @@ -370,7 +370,7 @@ class PluginManager if ($sourcePackage === null) { trigger_error('Calling PluginManager::addPlugin without $sourcePackage is deprecated, if you are using this please get in touch with us to explain the use case', E_USER_DEPRECATED); - } elseif (!$this->isPluginAllowed($sourcePackage->getName(), $isGlobalPlugin, (bool) ($sourcePackage->getExtra()['plugin-optional'] ?? false))) { + } elseif (!$this->isPluginAllowed($sourcePackage->getName(), $isGlobalPlugin, true === ($sourcePackage->getExtra()['plugin-optional'] ?? false))) { $this->io->writeError('Skipped loading "'.get_class($plugin).' from '.$sourcePackage->getName() . '" '.($isGlobalPlugin || $this->runningInGlobalDir ? '(installed globally) ' : '').' as it is not in config.allow-plugins', true, IOInterface::DEBUG); return; From 774f04108b3e37d16b389ba24846628bd9cf2d5c Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Wed, 15 Feb 2023 13:09:48 +0100 Subject: [PATCH 4/6] Update changelog --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e04f80d5..5405513ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +### [2.5.4] 2023-02-15 + + * Fixed extra.plugin-optional support in PluginInstaller when doing pre-install checks (#11318) + ### [2.5.3] 2023-02-10 * Added extra.plugin-optional support for allow auto-disabling unknown plugins which are not critical when running non-interactive (#11315) @@ -1695,6 +1699,7 @@ * Initial release +[2.5.4]: https://github.com/composer/composer/compare/2.5.3...2.5.4 [2.5.3]: https://github.com/composer/composer/compare/2.5.2...2.5.3 [2.5.2]: https://github.com/composer/composer/compare/2.5.1...2.5.2 [2.5.1]: https://github.com/composer/composer/compare/2.5.0...2.5.1 From 6b67eeea4d72051c369ccdbfb2423a56e2ab51a9 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Wed, 15 Feb 2023 13:10:06 +0100 Subject: [PATCH 5/6] Release 2.5.4 --- src/Composer/Composer.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Composer/Composer.php b/src/Composer/Composer.php index 8a870cc47..3790513f3 100644 --- a/src/Composer/Composer.php +++ b/src/Composer/Composer.php @@ -51,10 +51,10 @@ class Composer extends PartialComposer * * @see getVersion() */ - public const VERSION = '@package_version@'; - public const BRANCH_ALIAS_VERSION = '@package_branch_alias_version@'; - public const RELEASE_DATE = '@release_date@'; - public const SOURCE_VERSION = '2.5.999-dev+source'; + public const VERSION = '2.5.4'; + public const BRANCH_ALIAS_VERSION = ''; + public const RELEASE_DATE = '2023-02-15 13:10:06'; + public const SOURCE_VERSION = ''; /** * Version number of the internal composer-runtime-api package From b0a110f164ec08063900be127f363c295a1af3c9 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Wed, 15 Feb 2023 13:10:06 +0100 Subject: [PATCH 6/6] Reverting release version changes --- src/Composer/Composer.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Composer/Composer.php b/src/Composer/Composer.php index 3790513f3..8a870cc47 100644 --- a/src/Composer/Composer.php +++ b/src/Composer/Composer.php @@ -51,10 +51,10 @@ class Composer extends PartialComposer * * @see getVersion() */ - public const VERSION = '2.5.4'; - public const BRANCH_ALIAS_VERSION = ''; - public const RELEASE_DATE = '2023-02-15 13:10:06'; - public const SOURCE_VERSION = ''; + public const VERSION = '@package_version@'; + public const BRANCH_ALIAS_VERSION = '@package_branch_alias_version@'; + public const RELEASE_DATE = '@release_date@'; + public const SOURCE_VERSION = '2.5.999-dev+source'; /** * Version number of the internal composer-runtime-api package