Unbreak creating extension tables from the web installer
authorKunal Mehta <legoktm@member.fsf.org>
Wed, 11 Apr 2018 03:10:22 +0000 (20:10 -0700)
committerKunal Mehta <legoktm@member.fsf.org>
Wed, 11 Apr 2018 03:10:22 +0000 (20:10 -0700)
The web installer loads extensions during
Installer::includeExtensions(), but then
DatabaseUpdater::loadExtensions() reloads them again. Use a constant
(MW_EXTENSIONS_LOADED) to indicate that we shouldn't load them again.

Also fix a minor issue in loadExtensions() that would accidentally
register a bogus yet harmless hook called 'wgHooks'.

Change-Id: Id72fc0ceea15ccea52b1709bef51918ce64f8b40

includes/installer/DatabaseUpdater.php
includes/installer/Installer.php

index 7a1aba6..04132ad 100644 (file)
@@ -150,7 +150,7 @@ abstract class DatabaseUpdater {
         * LoadExtensionSchemaUpdates hook.
         */
        private function loadExtensions() {
         * LoadExtensionSchemaUpdates hook.
         */
        private function loadExtensions() {
-               if ( !defined( 'MEDIAWIKI_INSTALL' ) ) {
+               if ( !defined( 'MEDIAWIKI_INSTALL' ) || defined( 'MW_EXTENSIONS_LOADED' ) ) {
                        return; // already loaded
                }
                $vars = Installer::getExistingLocalSettings();
                        return; // already loaded
                }
                $vars = Installer::getExistingLocalSettings();
@@ -162,7 +162,7 @@ abstract class DatabaseUpdater {
 
                // This will automatically add "AutoloadClasses" to $wgAutoloadClasses
                $data = $registry->readFromQueue( $queue );
 
                // This will automatically add "AutoloadClasses" to $wgAutoloadClasses
                $data = $registry->readFromQueue( $queue );
-               $hooks = [ 'wgHooks' => [ 'LoadExtensionSchemaUpdates' => [] ] ];
+               $hooks = [];
                if ( isset( $data['globals']['wgHooks']['LoadExtensionSchemaUpdates'] ) ) {
                        $hooks = $data['globals']['wgHooks']['LoadExtensionSchemaUpdates'];
                }
                if ( isset( $data['globals']['wgHooks']['LoadExtensionSchemaUpdates'] ) ) {
                        $hooks = $data['globals']['wgHooks']['LoadExtensionSchemaUpdates'];
                }
index 7cfc617..94a5a5a 100644 (file)
@@ -1346,6 +1346,10 @@ abstract class Installer {
                $exts = $this->getVar( '_Extensions' );
                $IP = $this->getVar( 'IP' );
 
                $exts = $this->getVar( '_Extensions' );
                $IP = $this->getVar( 'IP' );
 
+               // Marker for DatabaseUpdater::loadExtensions so we don't
+               // double load extensions
+               define( 'MW_EXTENSIONS_LOADED', true );
+
                /**
                 * We need to include DefaultSettings before including extensions to avoid
                 * warnings about unset variables. However, the only thing we really
                /**
                 * We need to include DefaultSettings before including extensions to avoid
                 * warnings about unset variables. However, the only thing we really