Browse Source

Merge pull request #4784 from josegonzalez/master

Revert "Avoid loading plugins that do not match the current plugin api even during installation"
Jordi Boggiano 9 years ago
parent
commit
ea38cf24ac
1 changed files with 21 additions and 20 deletions
  1. 21 20
      src/Composer/Plugin/PluginManager.php

+ 21 - 20
src/Composer/Plugin/PluginManager.php

@@ -106,26 +106,6 @@ class PluginManager
             return;
         }
 
-        $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');
 
         if (in_array($package->getName(), $this->registeredPlugins)) {
@@ -229,7 +209,28 @@ class PluginManager
                 continue;
             }
             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);
+
             // Backward compatibility
             } elseif ('composer-installer' === $package->getType()) {
                 $this->registerPackage($package);