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 diff --git a/src/Composer/Installer/PluginInstaller.php b/src/Composer/Installer/PluginInstaller.php index 68326462e..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); + $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 74c33221e..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, $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, $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;