Deactivate plugins before recreating a new composer instance and loading new plugins in require/remove commands, fixes #9962
parent
91548d178b
commit
d86049565d
|
@ -210,6 +210,10 @@ EOT
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($composer = $this->getComposer(false)) {
|
||||||
|
$composer->getPluginManager()->deactivateInstalledPlugins();
|
||||||
|
}
|
||||||
|
|
||||||
// Update packages
|
// Update packages
|
||||||
$this->resetComposer();
|
$this->resetComposer();
|
||||||
$composer = $this->getComposer(true, $input->getOption('no-plugins'));
|
$composer = $this->getComposer(true, $input->getOption('no-plugins'));
|
||||||
|
|
|
@ -278,6 +278,8 @@ EOT
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$composer->getPluginManager()->deactivateInstalledPlugins();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return $this->doUpdate($input, $output, $io, $requirements, $requireKey, $removeKey);
|
return $this->doUpdate($input, $output, $io, $requirements, $requireKey, $removeKey);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
|
|
@ -90,6 +90,25 @@ class PluginManager
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deactivate all plugins from currently installed plugin packages
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function deactivateInstalledPlugins()
|
||||||
|
{
|
||||||
|
if ($this->disablePlugins) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$repo = $this->composer->getRepositoryManager()->getLocalRepository();
|
||||||
|
$globalRepo = $this->globalComposer ? $this->globalComposer->getRepositoryManager()->getLocalRepository() : null;
|
||||||
|
$this->deactivateRepository($repo, false);
|
||||||
|
if ($globalRepo) {
|
||||||
|
$this->deactivateRepository($globalRepo, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets all currently active plugin instances
|
* Gets all currently active plugin instances
|
||||||
*
|
*
|
||||||
|
@ -428,6 +447,34 @@ class PluginManager
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deactivate all plugins and installers from a repository
|
||||||
|
*
|
||||||
|
* If a plugin requires another plugin, the required one will be deactivated last
|
||||||
|
*
|
||||||
|
* @param RepositoryInterface $repo Repository to scan for plugins to install
|
||||||
|
* @param bool $isGlobalRepo
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
private function deactivateRepository(RepositoryInterface $repo, $isGlobalRepo)
|
||||||
|
{
|
||||||
|
$packages = $repo->getPackages();
|
||||||
|
$sortedPackages = array_reverse(PackageSorter::sortPackages($packages));
|
||||||
|
|
||||||
|
foreach ($sortedPackages as $package) {
|
||||||
|
if (!($package instanceof CompletePackage)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if ('composer-plugin' === $package->getType()) {
|
||||||
|
$this->deactivatePackage($package);
|
||||||
|
// Backward compatibility
|
||||||
|
} elseif ('composer-installer' === $package->getType()) {
|
||||||
|
$this->deactivatePackage($package);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Recursively generates a map of package names to packages for all deps
|
* Recursively generates a map of package names to packages for all deps
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue