Skip to content
Snippets Groups Projects
Commit 22b43bf6 authored by Adam G-H's avatar Adam G-H
Browse files

Issue #3273008 by phenaproxima, tedbow: Automatic Updates is incompatible with...

Issue #3273008 by phenaproxima, tedbow: Automatic Updates is incompatible with the global Drush launcher
parent 967f86c7
No related branches found
No related tags found
1 merge request!248Issue #3273008: Installing modules with Drush with AutoUpdates enabled shows an error
...@@ -14,7 +14,8 @@ ...@@ -14,7 +14,8 @@
"ext-json": "*", "ext-json": "*",
"drupal/core": "^9.2", "drupal/core": "^9.2",
"php-tuf/composer-stager": "0.3.0", "php-tuf/composer-stager": "0.3.0",
"composer/composer": "^2.2.12 || ^2.3.5" "composer/composer": "^2.2.12 || ^2.3.5",
"composer-runtime-api": "^2.0.9"
}, },
"config": { "config": {
"platform": { "platform": {
......
...@@ -47,8 +47,28 @@ class PathLocator { ...@@ -47,8 +47,28 @@ class PathLocator {
* The absolute path of the vendor directory. * The absolute path of the vendor directory.
*/ */
public function getVendorDirectory(): string { public function getVendorDirectory(): string {
$reflector = new \ReflectionClass(ClassLoader::class); // There may be multiple class loaders at work.
return dirname($reflector->getFileName(), 2); // ClassLoader::getRegisteredLoaders() keeps track of them all, indexed by
// the path of the vendor directory they load classes from.
$loaders = ClassLoader::getRegisteredLoaders();
// If there's only one class loader, we don't need to search for the right
// one.
if (count($loaders) === 1) {
return key($loaders);
}
// To determine which class loader is the one for Drupal's vendor directory,
// look for the loader whose vendor path starts the same way as the path to
// this file.
foreach (array_keys($loaders) as $path) {
if (str_starts_with(__FILE__, dirname($path))) {
return $path;
}
}
// If we couldn't find a match, assume that the first registered class
// loader is the one we want.
return key($loaders);
} }
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment