Restore "Avoid loading plugins that do not match the current plugin api even during installation" but fixed
This reverts commit 0118d69603
.
pull/4790/head
parent
a13b06725e
commit
41d8fdfda8
|
@ -106,6 +106,28 @@ class PluginManager
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($package->getType() === 'composer-plugin') {
|
||||||
|
$requiresComposer = null;
|
||||||
|
foreach ($package->getRequires() as $link) { /** @var Link $link */
|
||||||
|
if ('composer-plugin-api' === $link->getTarget()) {
|
||||||
|
$requiresComposer = $link->getConstraint();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$requiresComposer) {
|
||||||
|
throw new \RuntimeException("Plugin ".$package->getName()." is missing a require statement for a version of the composer-plugin-api package.");
|
||||||
|
}
|
||||||
|
|
||||||
|
$currentPluginApiVersion = $this->getPluginApiVersion();
|
||||||
|
$currentPluginApiConstraint = new Constraint('==', $this->versionParser->normalize($currentPluginApiVersion));
|
||||||
|
|
||||||
|
if (!$requiresComposer->matches($currentPluginApiConstraint)) {
|
||||||
|
$this->io->writeError('<warning>The "' . $package->getName() . '" plugin was skipped because it requires a Plugin API version ("' . $requiresComposer->getPrettyString() . '") that does not match your Composer installation ("' . $currentPluginApiVersion . '"). You may need to run composer update with the "--no-plugins" option.</warning>');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$oldInstallerPlugin = ($package->getType() === 'composer-installer');
|
$oldInstallerPlugin = ($package->getType() === 'composer-installer');
|
||||||
|
|
||||||
if (in_array($package->getName(), $this->registeredPlugins)) {
|
if (in_array($package->getName(), $this->registeredPlugins)) {
|
||||||
|
@ -209,28 +231,7 @@ class PluginManager
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ('composer-plugin' === $package->getType()) {
|
if ('composer-plugin' === $package->getType()) {
|
||||||
$requiresComposer = null;
|
|
||||||
foreach ($package->getRequires() as $link) { /** @var Link $link */
|
|
||||||
if ('composer-plugin-api' === $link->getTarget()) {
|
|
||||||
$requiresComposer = $link->getConstraint();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$requiresComposer) {
|
|
||||||
throw new \RuntimeException("Plugin ".$package->getName()." is missing a require statement for a version of the composer-plugin-api package.");
|
|
||||||
}
|
|
||||||
|
|
||||||
$currentPluginApiVersion = $this->getPluginApiVersion();
|
|
||||||
$currentPluginApiConstraint = new Constraint('==', $this->versionParser->normalize($currentPluginApiVersion));
|
|
||||||
|
|
||||||
if (!$requiresComposer->matches($currentPluginApiConstraint)) {
|
|
||||||
$this->io->writeError('<warning>The "' . $package->getName() . '" plugin was skipped because it requires a Plugin API version ("' . $requiresComposer->getPrettyString() . '") that does not match your Composer installation ("' . $currentPluginApiVersion . '"). You may need to run composer update with the "--no-plugins" option.</warning>');
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->registerPackage($package);
|
$this->registerPackage($package);
|
||||||
|
|
||||||
// Backward compatibility
|
// Backward compatibility
|
||||||
} elseif ('composer-installer' === $package->getType()) {
|
} elseif ('composer-installer' === $package->getType()) {
|
||||||
$this->registerPackage($package);
|
$this->registerPackage($package);
|
||||||
|
|
Loading…
Reference in New Issue