Check MW version requires before manifest_version
authorReedy <reedy@wikimedia.org>
Tue, 1 Nov 2016 23:03:13 +0000 (23:03 +0000)
committerReedy <reedy@wikimedia.org>
Tue, 1 Nov 2016 23:03:13 +0000 (23:03 +0000)
Bug: T149751
Change-Id: I914be4da431dcd613bdf2d1fd5ba9f28cf5b936b

includes/registration/ExtensionRegistry.php

index 0236ea2..b5c70e9 100644 (file)
@@ -187,6 +187,19 @@ class ExtensionRegistry {
                        if ( !is_array( $info ) ) {
                                throw new Exception( "$path is not a valid JSON file." );
                        }
                        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;
                        if ( !isset( $info['manifest_version'] ) ) {
                                // For backwards-compatability, assume a version of 1
                                $info['manifest_version'] = 1;
@@ -195,21 +208,12 @@ class ExtensionRegistry {
                        if ( $version < self::OLDEST_MANIFEST_VERSION || $version > self::MANIFEST_VERSION ) {
                                throw new Exception( "$path: unsupported manifest_version: {$version}" );
                        }
                        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;
                        $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 ) );
                        // Get extra paths for later inclusion
                        $autoloaderPaths = array_merge( $autoloaderPaths,
                                $processor->getExtraAutoloaderPaths( dirname( $path ), $info ) );