Follow-up r89254 and r89481: re-did loading extension updates properly, now upgrading...
authorMax Semenik <maxsem@users.mediawiki.org>
Sun, 5 Jun 2011 19:52:03 +0000 (19:52 +0000)
committerMax Semenik <maxsem@users.mediawiki.org>
Sun, 5 Jun 2011 19:52:03 +0000 (19:52 +0000)
includes/installer/DatabaseUpdater.php
includes/installer/Installer.php
includes/installer/WebInstallerPage.php
maintenance/install.php

index f66f81c..c09a229 100644 (file)
@@ -73,6 +73,7 @@ abstract class DatabaseUpdater {
                }
                $this->maintenance->setDB( $db );
                $this->initOldGlobals();
+               $this->loadExtensions();
                wfRunHooks( 'LoadExtensionSchemaUpdates', array( $this ) );
        }
 
@@ -94,6 +95,25 @@ abstract class DatabaseUpdater {
                $wgExtModifiedFields = array(); // table, index, dir
        }
 
+       /**
+        * Loads LocalSettings.php, if needed, and initialises everything needed for LoadExtensionSchemaUpdates hook
+        */
+       private function loadExtensions() {
+               if ( !defined( 'MEDIAWIKI_INSTALL' ) ) {
+                       return; // already loaded
+               }
+               $vars = Installer::getExistingLocalSettings();
+               if ( !$vars ) {
+                       return; // no LocalSettings found
+               }
+               if ( !isset( $vars['wgHooks'] ) && !isset( $vars['wgHooks']['LoadExtensionSchemaUpdates'] ) ) {
+                       return;
+               }
+               global $wgHooks, $wgAutoloadClasses;
+               $wgHooks['LoadExtensionSchemaUpdates'] = $vars['wgHooks']['LoadExtensionSchemaUpdates'];
+               $wgAutoloadClasses = $wgAutoloadClasses + $vars['wgAutoloadClasses'];
+       }
+
        /**
         * @throws MWException
         * @param DatabaseBase $db
index 6df0e08..6c6a99f 100644 (file)
@@ -456,7 +456,7 @@ abstract class Installer {
         *
         * @return Array
         */
-       public function getExistingLocalSettings() {
+       public static function getExistingLocalSettings() {
                global $IP;
 
                wfSuppressWarnings();
index ac11459..65fa0a2 100644 (file)
@@ -228,7 +228,7 @@ class WebInstaller_Language extends WebInstallerPage {
 class WebInstaller_ExistingWiki extends WebInstallerPage {
        public function execute() {
                // If there is no LocalSettings.php, continue to the installer welcome page
-               $vars = $this->parent->getExistingLocalSettings();
+               $vars = Installer::getExistingLocalSettings();
                if ( !$vars ) {
                        return 'skip';
                }
index 57e669d..34e3ea8 100644 (file)
@@ -27,6 +27,7 @@ if ( !function_exists( 'version_compare' ) || ( version_compare( phpversion(), '
 }
 
 define( 'MW_CONFIG_CALLBACK', 'Installer::overrideConfig' );
+define( 'MEDIAWIKI_INSTALL', true );
 
 require_once( dirname( dirname( __FILE__ ) )."/maintenance/Maintenance.php" );