1
0
Fork 0

Load plugins before purging packages, fixes #3557

pull/3562/head
Jordi Boggiano 2014-12-15 20:34:23 +00:00
parent 0c87048fed
commit 2b16a73659
3 changed files with 13 additions and 9 deletions

View File

@ -283,11 +283,6 @@ class Factory
// add installers to the manager (must happen after download manager is created since they read it out of $composer) // add installers to the manager (must happen after download manager is created since they read it out of $composer)
$this->createDefaultInstallers($im, $composer, $io); $this->createDefaultInstallers($im, $composer, $io);
// purge packages if they have been deleted on the filesystem
if ($rm->getLocalRepository()) {
$this->purgePackages($rm->getLocalRepository(), $im);
}
if ($fullLoad) { if ($fullLoad) {
$globalComposer = $this->createGlobalComposer($io, $config, $disablePlugins); $globalComposer = $this->createGlobalComposer($io, $config, $disablePlugins);
$pm = $this->createPluginManager($io, $composer, $globalComposer); $pm = $this->createPluginManager($io, $composer, $globalComposer);
@ -296,6 +291,12 @@ class Factory
if (!$disablePlugins) { if (!$disablePlugins) {
$pm->loadInstalledPlugins(); $pm->loadInstalledPlugins();
} }
// once we have plugins and custom installers we can
// purge packages from local repos if they have been deleted on the filesystem
if ($rm->getLocalRepository()) {
$this->purgePackages($rm->getLocalRepository(), $im);
}
} }
// init locker if possible // init locker if possible

View File

@ -61,7 +61,7 @@ class PluginInstaller extends LibraryInstaller
} }
parent::install($repo, $package); parent::install($repo, $package);
$this->composer->getPluginManager()->registerPackage($package); $this->composer->getPluginManager()->registerPackage($package, true);
} }
/** /**
@ -75,6 +75,6 @@ class PluginInstaller extends LibraryInstaller
} }
parent::update($repo, $initial, $target); parent::update($repo, $initial, $target);
$this->composer->getPluginManager()->registerPackage($target); $this->composer->getPluginManager()->registerPackage($target, true);
} }
} }

View File

@ -190,10 +190,11 @@ class PluginManager
* instead for BC * instead for BC
* *
* @param PackageInterface $package * @param PackageInterface $package
* @param bool $failOnMissingClasses By default this silently skips plugins that can not be found, but if set to true it fails with an exception
* *
* @throws \UnexpectedValueException * @throws \UnexpectedValueException
*/ */
public function registerPackage(PackageInterface $package) public function registerPackage(PackageInterface $package, $failOnMissingClasses = false)
{ {
$oldInstallerPlugin = ($package->getType() === 'composer-installer'); $oldInstallerPlugin = ($package->getType() === 'composer-installer');
@ -242,10 +243,12 @@ class PluginManager
if ($oldInstallerPlugin) { if ($oldInstallerPlugin) {
$installer = new $class($this->io, $this->composer); $installer = new $class($this->io, $this->composer);
$this->composer->getInstallationManager()->addInstaller($installer); $this->composer->getInstallationManager()->addInstaller($installer);
} else { } elseif (class_exists($class)) {
$plugin = new $class(); $plugin = new $class();
$this->addPlugin($plugin); $this->addPlugin($plugin);
$this->registeredPlugins[] = $package->getName(); $this->registeredPlugins[] = $package->getName();
} elseif ($failOnMissingClasses) {
throw new \UnexpectedValueException('Plugin '.$package->getName().' could not be initialized, class not found: '.$class);
} }
} }
} }