X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fregistration%2FExtensionRegistry.php;h=c5b21500f5374e815d757395ee3694b45aa4561f;hb=9ac29c74edda2f457814a1ed634a19f9a44fd0a5;hp=70dc6248f0ad587e107a65b6a5b2ff5c7220de0a;hpb=17b3bab4d636df56e4a4b55e52fcda9fde892804;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/registration/ExtensionRegistry.php b/includes/registration/ExtensionRegistry.php index 70dc6248f0..c5b21500f5 100644 --- a/includes/registration/ExtensionRegistry.php +++ b/includes/registration/ExtensionRegistry.php @@ -31,7 +31,7 @@ class ExtensionRegistry { /** * Bump whenever the registration cache needs resetting */ - const CACHE_VERSION = 4; + const CACHE_VERSION = 5; /** * Special key that defines the merge strategy @@ -203,8 +203,9 @@ class ExtensionRegistry { $autoloadClasses = []; $autoloaderPaths = []; $processor = new ExtensionProcessor(); + $versionChecker = new VersionChecker( $wgVersion ); + $extDependencies = []; $incompatible = []; - $coreVersionParser = new CoreVersionChecker( $wgVersion ); foreach ( $queue as $path => $mtime ) { $json = file_get_contents( $path ); if ( $json === false ) { @@ -215,25 +216,13 @@ class ExtensionRegistry { 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; } $version = $info['manifest_version']; if ( $version < self::OLDEST_MANIFEST_VERSION || $version > self::MANIFEST_VERSION ) { - throw new Exception( "$path: unsupported manifest_version: {$version}" ); + $incompatible[] = "$path: unsupported manifest_version: {$version}"; } $autoload = $this->processAutoLoader( dirname( $path ), $info ); @@ -241,12 +230,30 @@ class ExtensionRegistry { $GLOBALS['wgAutoloadClasses'] += $autoload; $autoloadClasses += $autoload; + // get all requirements/dependencies for this extension + $requires = $processor->getRequirements( $info ); + + // validate the information needed and add the requirements + if ( is_array( $requires ) && $requires && isset( $info['name'] ) ) { + $extDependencies[$info['name']] = $requires; + } + // Get extra paths for later inclusion $autoloaderPaths = array_merge( $autoloaderPaths, $processor->getExtraAutoloaderPaths( dirname( $path ), $info ) ); // Compatible, read and extract info $processor->extractInfo( $path, $info, $version ); } + $data = $processor->getExtractedInfo(); + + // check for incompatible extensions + $incompatible = array_merge( + $incompatible, + $versionChecker + ->setLoadedExtensionsAndSkins( $data['credits'] ) + ->checkArray( $extDependencies ) + ); + if ( $incompatible ) { if ( count( $incompatible ) === 1 ) { throw new Exception( $incompatible[0] ); @@ -254,7 +261,7 @@ class ExtensionRegistry { throw new Exception( implode( "\n", $incompatible ) ); } } - $data = $processor->getExtractedInfo(); + // Need to set this so we can += to it later $data['globals']['wgAutoloadClasses'] = []; $data['autoload'] = $autoloadClasses;