X-Git-Url: http://git.cyclocoop.org/%7B%24admin_url%7Dmes_infos.php?a=blobdiff_plain;f=includes%2Fregistration%2FExtensionRegistry.php;h=07fe3186be6827d31bab373e7fc28f2b42d28010;hb=7c9f1a122712362b5840aee0325e36b249cb79db;hp=768b4883234db0dceac000772f1be79859523c6e;hpb=a3b4288eacd34869b13f59782b73c9ddb75e3523;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/registration/ExtensionRegistry.php b/includes/registration/ExtensionRegistry.php index 768b488323..07fe3186be 100644 --- a/includes/registration/ExtensionRegistry.php +++ b/includes/registration/ExtensionRegistry.php @@ -146,7 +146,7 @@ class ExtensionRegistry { * be loaded then). */ public function loadFromQueue() { - global $wgVersion, $wgDevelopmentWarnings; + global $wgVersion, $wgDevelopmentWarnings, $wgObjectCaches; if ( !$this->queued ) { return; } @@ -169,10 +169,9 @@ class ExtensionRegistry { // We use a try/catch because we don't want to fail here // if $wgObjectCaches is not configured properly for APC setup try { - // Don't use MediaWikiServices here to prevent instantiating it before extensions have - // been loaded + // Avoid MediaWikiServices to prevent instantiating it before extensions have loaded $cacheId = ObjectCache::detectLocalServerCache(); - $cache = ObjectCache::newFromId( $cacheId ); + $cache = ObjectCache::newFromParams( $wgObjectCaches[$cacheId] ); } catch ( InvalidArgumentException $e ) { $cache = new EmptyBagOStuff(); } @@ -300,15 +299,12 @@ class ExtensionRegistry { } $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'] ); - AutoLoader::$psr4Namespaces += $autoloadNamespaces; - } + self::exportAutoloadClassesAndNamespaces( + $dir, + $info, + $autoloadClasses, + $autoloadNamespaces + ); // get all requirements/dependencies for this extension $requires = $processor->getRequirements( $info, $this->checkDev ); @@ -347,6 +343,28 @@ class ExtensionRegistry { return $data; } + /** + * Export autoload classes and namespaces for a given directory and parsed JSON info file. + * + * @param string $dir + * @param array $info + * @param array &$autoloadClasses + * @param array &$autoloadNamespaces + */ + public static function exportAutoloadClassesAndNamespaces( + $dir, $info, &$autoloadClasses = [], &$autoloadNamespaces = [] + ) { + if ( isset( $info['AutoloadClasses'] ) ) { + $autoload = self::processAutoLoader( $dir, $info['AutoloadClasses'] ); + $GLOBALS['wgAutoloadClasses'] += $autoload; + $autoloadClasses += $autoload; + } + if ( isset( $info['AutoloadNamespaces'] ) ) { + $autoloadNamespaces += self::processAutoLoader( $dir, $info['AutoloadNamespaces'] ); + AutoLoader::$psr4Namespaces += $autoloadNamespaces; + } + } + protected function exportExtractedData( array $info ) { foreach ( $info['globals'] as $key => $val ) { // If a merge strategy is set, read it and remove it from the value @@ -511,7 +529,7 @@ class ExtensionRegistry { * @param array $files * @return array */ - protected function processAutoLoader( $dir, array $files ) { + protected static function processAutoLoader( $dir, array $files ) { // Make paths absolute, relative to the JSON file foreach ( $files as &$file ) { $file = "$dir/$file";