X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fregistration%2FExtensionRegistry.php;h=35044e1f86eabfb9671e18716c4acefafb21a2e3;hb=ce079cf6ad79ca8d3360817f809b219d166f9153;hp=3bec457c1e8dcd216ff796e7895bee6d7bae6200;hpb=a303296f2730d6279a249bde77f3e0b9b42e494f;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/registration/ExtensionRegistry.php b/includes/registration/ExtensionRegistry.php index 3bec457c1e..70dc6248f0 100644 --- a/includes/registration/ExtensionRegistry.php +++ b/includes/registration/ExtensionRegistry.php @@ -1,5 +1,7 @@ cache = ObjectCache::getLocalServerInstance(); + $this->cache = MediaWikiServices::getInstance()->getLocalServerObjectCache(); } catch ( MWException $e ) { $this->cache = new EmptyBagOStuff(); } @@ -113,12 +121,23 @@ class ExtensionRegistry { $this->queued[$path] = $mtime; } + /** + * @throws MWException If the queue is already marked as finished (no further things should + * be loaded then). + */ public function loadFromQueue() { global $wgVersion; if ( !$this->queued ) { return; } + if ( $this->finished ) { + throw new MWException( + "The following paths tried to load late: " + . implode( ', ', array_keys( $this->queued ) ) + ); + } + // A few more things to vary the cache on $versions = [ 'registration' => self::CACHE_VERSION, @@ -163,6 +182,15 @@ class ExtensionRegistry { $this->queued = []; } + /** + * After this is called, no more extensions can be loaded + * + * @since 1.29 + */ + public function finish() { + $this->finished = true; + } + /** * Process a queue of extensions and return their extracted data * @@ -186,6 +214,19 @@ class ExtensionRegistry { if ( !is_array( $info ) ) { throw new Exception( "$path is not a valid JSON file." ); } + + // Check any constraints against MediaWiki core + $requires = $processor->getRequirements( $info ); + if ( isset( $requires[self::MEDIAWIKI_CORE] ) + && !$coreVersionParser->check( $requires[self::MEDIAWIKI_CORE] ) + ) { + // Doesn't match, mark it as incompatible. + $incompatible[] = "{$info['name']} is not compatible with the current " + . "MediaWiki core (version {$wgVersion}), it requires: " . $requires[self::MEDIAWIKI_CORE] + . '.'; + continue; + } + if ( !isset( $info['manifest_version'] ) ) { // For backwards-compatability, assume a version of 1 $info['manifest_version'] = 1; @@ -194,21 +235,12 @@ class ExtensionRegistry { if ( $version < self::OLDEST_MANIFEST_VERSION || $version > self::MANIFEST_VERSION ) { throw new Exception( "$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; - // Check any constraints against MediaWiki core - $requires = $processor->getRequirements( $info ); - if ( isset( $requires[self::MEDIAWIKI_CORE] ) - && !$coreVersionParser->check( $requires[self::MEDIAWIKI_CORE] ) - ) { - // Doesn't match, mark it as incompatible. - $incompatible[] = "{$info['name']} is not compatible with the current " - . "MediaWiki core (version {$wgVersion}), it requires: " . $requires[self::MEDIAWIKI_CORE] - . '.'; - continue; - } + // Get extra paths for later inclusion $autoloaderPaths = array_merge( $autoloaderPaths, $processor->getExtraAutoloaderPaths( dirname( $path ), $info ) ); @@ -257,6 +289,9 @@ class ExtensionRegistry { case 'array_merge_recursive': $GLOBALS[$key] = array_merge_recursive( $GLOBALS[$key], $val ); break; + case 'array_replace_recursive': + $GLOBALS[$key] = array_replace_recursive( $GLOBALS[$key], $val ); + break; case 'array_plus_2d': $GLOBALS[$key] = wfArrayPlus2d( $GLOBALS[$key], $val ); break; @@ -277,9 +312,6 @@ class ExtensionRegistry { foreach ( $info['autoloaderPaths'] as $path ) { require_once $path; } - foreach ( $info['callbacks'] as $cb ) { - call_user_func( $cb ); - } $this->loaded += $info['credits']; if ( $info['attributes'] ) { @@ -289,6 +321,10 @@ class ExtensionRegistry { $this->attributes = array_merge_recursive( $this->attributes, $info['attributes'] ); } } + + foreach ( $info['callbacks'] as $name => $cb ) { + call_user_func( $cb, $info['credits'][$name] ); + } } /**