*/
class ExtensionRegistry {
+ /**
+ * "requires" key that applies to MediaWiki core/$wgVersion
+ */
+ const MEDIAWIKI_CORE = 'MediaWiki';
+
/**
* Version of the highest supported manifest version
*/
}
public function loadFromQueue() {
+ global $wgVersion;
if ( !$this->queued ) {
return;
}
+ // A few more things to vary the cache on
+ $versions = array(
+ 'registration' => self::CACHE_VERSION,
+ 'mediawiki' => $wgVersion
+ );
+
// See if this queue is in APC
- $key = wfMemcKey( 'registration', md5( json_encode( $this->queued ) ), self::CACHE_VERSION );
+ $key = wfMemcKey(
+ 'registration',
+ md5( json_encode( $this->queued + $versions ) )
+ );
$data = $this->cache->get( $key );
if ( $data ) {
$this->exportExtractedData( $data );
* @throws Exception
*/
public function readFromQueue( array $queue ) {
+ global $wgVersion;
$autoloadClasses = array();
$processor = new ExtensionProcessor();
+ $incompatible = array();
+ $coreVersionParser = new CoreVersionChecker( $wgVersion );
foreach ( $queue as $path => $mtime ) {
$json = file_get_contents( $path );
if ( $json === false ) {
// 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;
+ }
+ // Compatible, read and extract info
$processor->extractInfo( $path, $info, $version );
}
+ if ( $incompatible ) {
+ if ( count( $incompatible ) === 1 ) {
+ throw new Exception( $incompatible[0] );
+ } else {
+ throw new Exception( implode( "\n", $incompatible ) );
+ }
+ }
$data = $processor->getExtractedInfo();
// Need to set this so we can += to it later
$data['globals']['wgAutoloadClasses'] = array();
$GLOBALS[$key] = array_merge_recursive( $GLOBALS[$key], $val );
break;
case 'array_plus_2d':
- // First merge items that are in both arrays
- foreach ( $GLOBALS[$key] as $name => &$groupVal ) {
- if ( isset( $val[$name] ) ) {
- $groupVal += $val[$name];
- }
- }
- // Now add items that didn't exist yet
- $GLOBALS[$key] += $val;
+ $GLOBALS[$key] = wfArrayPlus2d( $GLOBALS[$key], $val );
break;
case 'array_plus':
- $GLOBALS[$key] = $val + $GLOBALS[$key];
+ $GLOBALS[$key] += $val;
break;
case 'array_merge':
$GLOBALS[$key] = array_merge( $val, $GLOBALS[$key] );