1
0
Fork 0

Improve sorting of plugin packages, fixes #3109, refs #2972

pull/2492/merge
Jordi Boggiano 2014-09-22 17:04:58 +01:00
parent 4d522e40fb
commit 62b5062146
2 changed files with 20 additions and 7 deletions

View File

@ -597,11 +597,21 @@ class Installer
continue;
}
if ($package->getRequires() === array() && ($package->getType() === 'composer-plugin' || $package->getType() === 'composer-installer')) {
if ($package->getType() === 'composer-plugin' || $package->getType() === 'composer-installer') {
// ignore requirements to platform or composer-plugin-api
$requires = array_keys($package->getRequires());
foreach ($requires as $index => $req) {
if ($req === 'composer-plugin-api' || preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $req)) {
unset($requires[$index]);
}
}
// if there are no other requirements, move the plugin to the top of the op list
if (!count($requires)) {
$installerOps[] = $op;
unset($operations[$idx]);
}
}
}
return array_merge($installerOps, $operations);
}

View File

@ -1,5 +1,5 @@
--TEST--
Composer installers are installed first if they have no requirements
Composer installers are installed first if they have no meaningful requirements
--COMPOSER--
{
"repositories": [
@ -9,20 +9,23 @@ Composer installers are installed first if they have no requirements
{ "name": "pkg", "version": "1.0.0" },
{ "name": "pkg2", "version": "1.0.0" },
{ "name": "inst", "version": "1.0.0", "type": "composer-plugin" },
{ "name": "inst2", "version": "1.0.0", "type": "composer-plugin", "require": { "pkg2": "*" } }
{ "name": "inst-with-req", "version": "1.0.0", "type": "composer-plugin", "require": { "php": ">=5", "ext-json": "*", "composer-plugin-api": "*" } },
{ "name": "inst-with-req2", "version": "1.0.0", "type": "composer-plugin", "require": { "pkg2": "*" } }
]
}
],
"require": {
"pkg": "1.0.0",
"inst": "1.0.0",
"inst2": "1.0.0"
"inst-with-req2": "1.0.0",
"inst-with-req": "1.0.0"
}
}
--RUN--
install
--EXPECT--
Installing inst (1.0.0)
Installing inst-with-req (1.0.0)
Installing pkg (1.0.0)
Installing pkg2 (1.0.0)
Installing inst2 (1.0.0)
Installing inst-with-req2 (1.0.0)