From 9a6d63f0f4f187df304fd60803b340c84211bc13 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Tue, 5 Jul 2022 16:22:29 +0200 Subject: [PATCH] Fix build regressions --- src/Composer/Factory.php | 3 +++ src/Composer/Installer/PluginInstaller.php | 2 +- src/Composer/Plugin/PluginManager.php | 2 +- tests/Composer/Test/Plugin/PluginInstallerTest.php | 4 ++++ 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Composer/Factory.php b/src/Composer/Factory.php index 9fb0be111..de1516f7d 100644 --- a/src/Composer/Factory.php +++ b/src/Composer/Factory.php @@ -413,6 +413,9 @@ class Factory $locker = new Package\Locker($io, new JsonFile($config->get('lock') ? $lockFile : Platform::getDevNull(), null, $io), $im, file_get_contents($composerFile), $process); $composer->setLocker($locker); + } elseif ($composer instanceof Composer) { + $locker = new Package\Locker($io, new JsonFile(Platform::getDevNull(), null, $io), $im, json_encode($localConfig), $process); + $composer->setLocker($locker); } if ($composer instanceof Composer) { diff --git a/src/Composer/Installer/PluginInstaller.php b/src/Composer/Installer/PluginInstaller.php index 751130e7f..fc9c6dcbb 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 going to fail due to a plugin not being allowed if ($type === 'install' || $type === 'update') { - $this->composer->getPluginManager()->isPluginAllowed($package->getName(), false); + $this->getPluginManager()->isPluginAllowed($package->getName(), false); } return parent::prepare($type, $package, $prevPackage); diff --git a/src/Composer/Plugin/PluginManager.php b/src/Composer/Plugin/PluginManager.php index f83353829..2ca137012 100644 --- a/src/Composer/Plugin/PluginManager.php +++ b/src/Composer/Plugin/PluginManager.php @@ -77,7 +77,7 @@ class PluginManager $this->versionParser = new VersionParser(); $this->disablePlugins = $disablePlugins; $this->allowPluginRules = $this->parseAllowedPlugins($composer->getConfig()->get('allow-plugins'), $composer->getLocker()); - $this->allowGlobalPluginRules = $this->parseAllowedPlugins($globalComposer !== null ? $globalComposer->getConfig()->get('allow-plugins') : false, $globalComposer !== null ? $globalComposer->getLocker() : null); + $this->allowGlobalPluginRules = $this->parseAllowedPlugins($globalComposer !== null ? $globalComposer->getConfig()->get('allow-plugins') : false); } /** diff --git a/tests/Composer/Test/Plugin/PluginInstallerTest.php b/tests/Composer/Test/Plugin/PluginInstallerTest.php index 44d06292a..8215b97f1 100644 --- a/tests/Composer/Test/Plugin/PluginInstallerTest.php +++ b/tests/Composer/Test/Plugin/PluginInstallerTest.php @@ -15,10 +15,12 @@ namespace Composer\Test\Plugin; use Composer\Composer; use Composer\Config; use Composer\Installer\PluginInstaller; +use Composer\Json\JsonFile; use Composer\Package\CompleteAliasPackage; use Composer\Package\CompletePackage; use Composer\Package\Loader\JsonLoader; use Composer\Package\Loader\ArrayLoader; +use Composer\Package\Locker; use Composer\Package\RootPackage; use Composer\Plugin\PluginManager; use Composer\IO\BufferIO; @@ -26,6 +28,7 @@ use Composer\EventDispatcher\EventDispatcher; use Composer\Autoload\AutoloadGenerator; use Composer\Test\TestCase; use Composer\Util\Filesystem; +use Composer\Util\Platform; class PluginInstallerTest extends TestCase { @@ -123,6 +126,7 @@ class PluginInstallerTest extends TestCase $this->composer->setAutoloadGenerator($this->autoloadGenerator); $this->composer->setEventDispatcher(new EventDispatcher($this->composer, $this->io)); $this->composer->setPackage(new RootPackage('dummy/root', '1.0.0.0', '1.0.0')); + $this->composer->setLocker(new Locker($this->io, new JsonFile(Platform::getDevNull()), $im, '{}')); $config->merge(array( 'config' => array(