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,9 +597,19 @@ class Installer
continue; continue;
} }
if ($package->getRequires() === array() && ($package->getType() === 'composer-plugin' || $package->getType() === 'composer-installer')) { if ($package->getType() === 'composer-plugin' || $package->getType() === 'composer-installer') {
$installerOps[] = $op; // ignore requirements to platform or composer-plugin-api
unset($operations[$idx]); $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]);
}
} }
} }

View File

@ -1,5 +1,5 @@
--TEST-- --TEST--
Composer installers are installed first if they have no requirements Composer installers are installed first if they have no meaningful requirements
--COMPOSER-- --COMPOSER--
{ {
"repositories": [ "repositories": [
@ -9,20 +9,23 @@ Composer installers are installed first if they have no requirements
{ "name": "pkg", "version": "1.0.0" }, { "name": "pkg", "version": "1.0.0" },
{ "name": "pkg2", "version": "1.0.0" }, { "name": "pkg2", "version": "1.0.0" },
{ "name": "inst", "version": "1.0.0", "type": "composer-plugin" }, { "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": { "require": {
"pkg": "1.0.0", "pkg": "1.0.0",
"inst": "1.0.0", "inst": "1.0.0",
"inst2": "1.0.0" "inst-with-req2": "1.0.0",
"inst-with-req": "1.0.0"
} }
} }
--RUN-- --RUN--
install install
--EXPECT-- --EXPECT--
Installing inst (1.0.0) Installing inst (1.0.0)
Installing inst-with-req (1.0.0)
Installing pkg (1.0.0) Installing pkg (1.0.0)
Installing pkg2 (1.0.0) Installing pkg2 (1.0.0)
Installing inst2 (1.0.0) Installing inst-with-req2 (1.0.0)