diff --git a/src/Composer/Plugin/PluginManager.php b/src/Composer/Plugin/PluginManager.php index c20d403fa..3f88f6994 100644 --- a/src/Composer/Plugin/PluginManager.php +++ b/src/Composer/Plugin/PluginManager.php @@ -216,6 +216,17 @@ class PluginManager $globalRepo = $this->globalComposer !== null ? $this->globalComposer->getRepositoryManager()->getLocalRepository() : null; $rootPackage = clone $this->composer->getPackage(); + + // clear files autoload rules from the root package as the root dependencies are not + // necessarily all present yet when booting this runtime autoloader + $rootPackageAutoloads = $rootPackage->getAutoload(); + $rootPackageAutoloads['files'] = array(); + $rootPackage->setAutoload($rootPackageAutoloads); + $rootPackageAutoloads = $rootPackage->getDevAutoload(); + $rootPackageAutoloads['files'] = array(); + $rootPackage->setDevAutoload($rootPackageAutoloads); + unset($rootPackageAutoloads); + $rootPackageRepo = new RootPackageRepository($rootPackage); $installedRepo = new InstalledRepository(array($localRepo, $rootPackageRepo)); if ($globalRepo) { diff --git a/tests/Composer/Test/Plugin/Fixtures/files_autoload_which_should_not_run.php b/tests/Composer/Test/Plugin/Fixtures/files_autoload_which_should_not_run.php new file mode 100644 index 000000000..392b5bffd --- /dev/null +++ b/tests/Composer/Test/Plugin/Fixtures/files_autoload_which_should_not_run.php @@ -0,0 +1,3 @@ +repository + ->expects($this->any()) + ->method('getPackages') + ->will($this->returnValue(array())); + $installer = new PluginInstaller($this->io, $this->composer); + $this->pm->loadInstalledPlugins(); + + $this->autoloadGenerator->setDevMode(true); + $this->composer->getPackage()->setAutoload(array('files' => array(__DIR__ . '/Fixtures/files_autoload_which_should_not_run.php'))); + $this->composer->getPackage()->setDevAutoload(array('files' => array(__DIR__ . '/Fixtures/files_autoload_which_should_not_run.php'))); + $installer->install($this->repository, $this->packages[0]); + + $plugins = $this->pm->getPlugins(); + $this->assertEquals( + 'activate v1'.PHP_EOL, + $this->io->getOutput() + ); + $this->assertEquals('installer-v1', $plugins[0]->version); // @phpstan-ignore-line + } + public function testInstallMultiplePlugins() { $this->repository