1
0
Fork 0

Make sure if plugins depend on the root package that the root package is also autoloaded correctly, refs #9530

pull/9615/head
Jordi Boggiano 2021-01-12 13:47:36 +01:00
parent 92b3725765
commit 94076c0bb9
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
1 changed files with 9 additions and 3 deletions

View File

@ -21,6 +21,7 @@ use Composer\Package\RootPackage;
use Composer\Package\Version\VersionParser; use Composer\Package\Version\VersionParser;
use Composer\Repository\RepositoryInterface; use Composer\Repository\RepositoryInterface;
use Composer\Repository\InstalledRepository; use Composer\Repository\InstalledRepository;
use Composer\Repository\RootPackageRepository;
use Composer\Package\PackageInterface; use Composer\Package\PackageInterface;
use Composer\Package\Link; use Composer\Package\Link;
use Composer\Semver\Constraint\Constraint; use Composer\Semver\Constraint\Constraint;
@ -174,7 +175,8 @@ class PluginManager
$localRepo = $this->composer->getRepositoryManager()->getLocalRepository(); $localRepo = $this->composer->getRepositoryManager()->getLocalRepository();
$globalRepo = $this->globalComposer ? $this->globalComposer->getRepositoryManager()->getLocalRepository() : null; $globalRepo = $this->globalComposer ? $this->globalComposer->getRepositoryManager()->getLocalRepository() : null;
$installedRepo = new InstalledRepository(array($localRepo)); $rootPackageRepo = new RootPackageRepository($this->composer->getPackage());
$installedRepo = new InstalledRepository(array($localRepo, $rootPackageRepo));
if ($globalRepo) { if ($globalRepo) {
$installedRepo->addRepository($globalRepo); $installedRepo->addRepository($globalRepo);
} }
@ -185,11 +187,15 @@ class PluginManager
$generator = $this->composer->getAutoloadGenerator(); $generator = $this->composer->getAutoloadGenerator();
$autoloads = array(); $autoloads = array();
foreach ($autoloadPackages as $autoloadPackage) { foreach ($autoloadPackages as $autoloadPackage) {
$downloadPath = $this->getInstallPath($autoloadPackage, $globalRepo && $globalRepo->hasPackage($autoloadPackage)); if ($autoloadPackage === $this->composer->getPackage()) {
$downloadPath = '';
} else {
$downloadPath = $this->getInstallPath($autoloadPackage, $globalRepo && $globalRepo->hasPackage($autoloadPackage));
}
$autoloads[] = array($autoloadPackage, $downloadPath); $autoloads[] = array($autoloadPackage, $downloadPath);
} }
$map = $generator->parseAutoloads($autoloads, new RootPackage('dummy/root-package', '1.0.0.0', '1.0.0')); $map = $generator->parseAutoloads($autoloads, $this->composer->getPackage());
$classLoader = $generator->createLoader($map); $classLoader = $generator->createLoader($map);
$classLoader->register(); $classLoader->register();