X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fregistration%2FExtensionRegistry.php;h=bc2f8e47d3bc26547717c3da5904161fb63326a1;hp=740fed4eac8054e23bf624062311e82d6c099d56;hb=036f5b47efc99b56e9e841c8ebdfec7d3e197f83;hpb=3a79761da37abe0e147e4a5ee61b7ee17ec7efc3 diff --git a/includes/registration/ExtensionRegistry.php b/includes/registration/ExtensionRegistry.php index 740fed4eac..bc2f8e47d3 100644 --- a/includes/registration/ExtensionRegistry.php +++ b/includes/registration/ExtensionRegistry.php @@ -196,6 +196,7 @@ class ExtensionRegistry { public function readFromQueue( array $queue ) { global $wgVersion; $autoloadClasses = []; + $autoloadNamespaces = []; $autoloaderPaths = []; $processor = new ExtensionProcessor(); $versionChecker = new VersionChecker( $wgVersion ); @@ -226,10 +227,15 @@ class ExtensionRegistry { $incompatible[] = "$path: unsupported manifest_version: {$version}"; } - $autoload = $this->processAutoLoader( dirname( $path ), $info ); - // Set up the autoloader now so custom processors will work - $GLOBALS['wgAutoloadClasses'] += $autoload; - $autoloadClasses += $autoload; + $dir = dirname( $path ); + if ( isset( $info['AutoloadClasses'] ) ) { + $autoload = $this->processAutoLoader( $dir, $info['AutoloadClasses'] ); + $GLOBALS['wgAutoloadClasses'] += $autoload; + $autoloadClasses += $autoload; + } + if ( isset( $info['AutoloadNamespaces'] ) ) { + $autoloadNamespaces += $this->processAutoLoader( $dir, $info['AutoloadNamespaces'] ); + } // get all requirements/dependencies for this extension $requires = $processor->getRequirements( $info ); @@ -241,7 +247,7 @@ class ExtensionRegistry { // Get extra paths for later inclusion $autoloaderPaths = array_merge( $autoloaderPaths, - $processor->getExtraAutoloaderPaths( dirname( $path ), $info ) ); + $processor->getExtraAutoloaderPaths( $dir, $info ) ); // Compatible, read and extract info $processor->extractInfo( $path, $info, $version ); } @@ -268,6 +274,7 @@ class ExtensionRegistry { $data['globals']['wgAutoloadClasses'] = []; $data['autoload'] = $autoloadClasses; $data['autoloaderPaths'] = $autoloaderPaths; + $data['autoloaderNS'] = $autoloadNamespaces; return $data; } @@ -315,6 +322,10 @@ class ExtensionRegistry { } } + if ( isset( $info['autoloaderNS'] ) ) { + Autoloader::$psr4Namespaces += $info['autoloaderNS']; + } + foreach ( $info['defines'] as $name => $val ) { define( $name, $val ); } @@ -399,20 +410,16 @@ class ExtensionRegistry { } /** - * Register classes with the autoloader + * Fully expand autoloader paths * * @param string $dir * @param array $info * @return array */ protected function processAutoLoader( $dir, array $info ) { - if ( isset( $info['AutoloadClasses'] ) ) { - // Make paths absolute, relative to the JSON file - return array_map( function ( $file ) use ( $dir ) { - return "$dir/$file"; - }, $info['AutoloadClasses'] ); - } else { - return []; - } + // Make paths absolute, relative to the JSON file + return array_map( function ( $file ) use ( $dir ) { + return "$dir/$file"; + }, $info ); } }