Skip to content
Snippets Groups Projects

Issue #3273008: Installing modules with Drush with AutoUpdates enabled shows an error

Files
2
@@ -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);
}
}
/**
/**
Loading