Skip to content

Commit

Permalink
Match plugin-optional more strictly
Browse files Browse the repository at this point in the history
  • Loading branch information
Seldaek committed Feb 10, 2023
1 parent b781031 commit d35cb21
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Composer/Installer/PluginInstaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function prepare($type, PackageInterface $package, ?PackageInterface $pre
{
// 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);
Expand Down
4 changes: 2 additions & 2 deletions src/Composer/Plugin/PluginManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public function registerPackage(PackageInterface $package, bool $failOnMissingCl
}
}

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;
Expand Down Expand Up @@ -370,7 +370,7 @@ public function addPlugin(PluginInterface $plugin, bool $isGlobalPlugin = false,

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;
Expand Down

0 comments on commit d35cb21

Please sign in to comment.