Merge pull request #6371 from balbuf/balbuf/move-all-plugins
Move all plugins and their dependencies to the frontpull/1694/merge
commit
b1110df873
|
@ -744,8 +744,11 @@ class Installer
|
||||||
*/
|
*/
|
||||||
private function movePluginsToFront(array $operations)
|
private function movePluginsToFront(array $operations)
|
||||||
{
|
{
|
||||||
$installerOps = array();
|
$pluginsNoDeps = array();
|
||||||
foreach ($operations as $idx => $op) {
|
$pluginsWithDeps = array();
|
||||||
|
$pluginRequires = array();
|
||||||
|
|
||||||
|
foreach (array_reverse($operations, true) as $idx => $op) {
|
||||||
if ($op instanceof InstallOperation) {
|
if ($op instanceof InstallOperation) {
|
||||||
$package = $op->getPackage();
|
$package = $op->getPackage();
|
||||||
} elseif ($op instanceof UpdateOperation) {
|
} elseif ($op instanceof UpdateOperation) {
|
||||||
|
@ -754,23 +757,32 @@ class Installer
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($package->getType() === 'composer-plugin' || $package->getType() === 'composer-installer') {
|
// is this package a plugin?
|
||||||
// ignore requirements to platform or composer-plugin-api
|
$is_plugin = $package->getType() === 'composer-plugin' || $package->getType() === 'composer-installer';
|
||||||
$requires = array_keys($package->getRequires());
|
|
||||||
foreach ($requires as $index => $req) {
|
// is this a plugin or a dependency of a plugin?
|
||||||
if ($req === 'composer-plugin-api' || preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $req)) {
|
if ($is_plugin || count(array_intersect($package->getNames(), $pluginRequires))) {
|
||||||
unset($requires[$index]);
|
// get the package's requires, but filter out any platform requirements or 'composer-plugin-api'
|
||||||
}
|
$requires = array_filter(array_keys($package->getRequires()), function($req) {
|
||||||
}
|
return $req !== 'composer-plugin-api' && !preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $req);
|
||||||
// if there are no other requirements, move the plugin to the top of the op list
|
});
|
||||||
if (!count($requires)) {
|
|
||||||
$installerOps[] = $op;
|
// is this a plugin with no meaningful dependencies?
|
||||||
unset($operations[$idx]);
|
if ($is_plugin && !count($requires)) {
|
||||||
|
// plugins with no dependencies go to the very front
|
||||||
|
array_unshift($pluginsNoDeps, $op);
|
||||||
|
} else {
|
||||||
|
// capture the requirements for this package so those packages will be moved up as well
|
||||||
|
$pluginRequires = array_merge($pluginRequires, $requires);
|
||||||
|
// move the operation to the front
|
||||||
|
array_unshift($pluginsWithDeps, $op);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unset($operations[$idx]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return array_merge($installerOps, $operations);
|
return array_merge($pluginsNoDeps, $pluginsWithDeps, $operations);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
--TEST--
|
--TEST--
|
||||||
Composer installers are installed first if they have no meaningful requirements
|
Composer installers and their requirements are installed first
|
||||||
--COMPOSER--
|
--COMPOSER--
|
||||||
{
|
{
|
||||||
"repositories": [
|
"repositories": [
|
||||||
|
@ -26,6 +26,6 @@ install
|
||||||
--EXPECT--
|
--EXPECT--
|
||||||
Installing inst (1.0.0)
|
Installing inst (1.0.0)
|
||||||
Installing inst-with-req (1.0.0)
|
Installing inst-with-req (1.0.0)
|
||||||
Installing pkg (1.0.0)
|
|
||||||
Installing pkg2 (1.0.0)
|
Installing pkg2 (1.0.0)
|
||||||
Installing inst-with-req2 (1.0.0)
|
Installing inst-with-req2 (1.0.0)
|
||||||
|
Installing pkg (1.0.0)
|
||||||
|
|
Loading…
Reference in New Issue