Follow-up r89835: Accidently comitted from a deeper dir than the diff. Comitting...
[lhc/web/wiklou.git] / includes / installer / DatabaseUpdater.php
index 2d863db..a369df0 100644 (file)
@@ -30,18 +30,6 @@ abstract class DatabaseUpdater {
         */
        protected $extensionUpdates = array();
 
-       /**
-        * List of extension-provided database updaters
-        * @var array
-        */
-       protected $extensionUpdaters = array();
-
-       /**
-        * Used to hold schema files during installation process
-        * @var array
-        */
-       protected $newExtensions = array();
-
        /**
         * Handle to the database subclass
         *
@@ -73,7 +61,7 @@ abstract class DatabaseUpdater {
                }
                $this->maintenance->setDB( $db );
                $this->initOldGlobals();
-               $this->initIncludedExtensions();
+               $this->loadExtensions();
                wfRunHooks( 'LoadExtensionSchemaUpdates', array( $this ) );
        }
 
@@ -96,25 +84,22 @@ abstract class DatabaseUpdater {
        }
 
        /**
-        * Try to include extensions from LocalSettings so their LocalExtensionSchemaChanges hooks can be run
+        * Loads LocalSettings.php, if needed, and initialises everything needed for LoadExtensionSchemaUpdates hook
         */
-       private function initIncludedExtensions() {
-               global $IP, $wgHooks, $wgAutoloadClasses;
-               $ls = file_get_contents( "$IP/LocalSettings.php" );
-               if ( $ls === false ) return;
-               $matches = array();
-               preg_match_all( '/[[:blank:]]*(?:require|include){1}(?:_once)?[[:blank:]]*\([[:blank:]]*"\$IP\/extensions\/([^\/].*)\/\1\.php"[[:blank:]]*\);[[:blank:]]*/i',
-                                               $ls, $matches, PREG_SET_ORDER );
-               unset( $ls );
-
-               if ( !isset( $wgHooks ) ) 
-                       $wgHooks = array();
-               if ( !isset( $wgAutoloadClasses ) ) 
-                       $wgAutoloadClasses = array();
-
-               foreach ( $matches as $match ) {
-                       include_once ( "$IP/extensions/{$match[1]}/{$match[1]}.php" );
+       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'];
        }
 
        /**
@@ -175,17 +160,6 @@ abstract class DatabaseUpdater {
                $this->extensionUpdates[] = $update;
        }
 
-       /**
-        * Add a updater class that will handle extensions DB install/update. 
-        * This should be called by extensions while executing the 
-        * LoadExtensionSchemaUpdates hook.
-        *
-        * @param $updater (string) classname (extends DatabaseUpdater).
-        */
-       public function addExtensionUpdater( $updater ) {
-               $this->extensionUpdaters[] = $updater;
-       }
-
        /**
         * Convenience wrapper for addExtensionUpdate() when adding a new table (which
         * is the most common usage of updaters in an extension)
@@ -196,23 +170,6 @@ abstract class DatabaseUpdater {
                $this->extensionUpdates[] = array( 'addTable', $tableName, $sqlPath, true );
        }
 
-       /**
-        * Add a brand new extension to MediaWiki. Used during the initial install
-        * @param $ext String Name of extension
-        * @param $sqlPath String Full path to the schema file
-        */
-       public function addNewExtension( $ext, $sqlPath ) {
-               $this->newExtensions[ strtolower( $ext ) ] = $sqlPath;
-       }
-
-       /**
-        * Get the list of extensions that registered a schema with our DB type
-        * @return array
-        */
-       public function getNewExtensions() {
-               return $this->newExtensions;
-       }
-
        /**
         * Get the list of extension-defined updates
         *
@@ -222,15 +179,6 @@ abstract class DatabaseUpdater {
                return $this->extensionUpdates;
        }
 
-       /**
-        * Get the list of extension-defined updaters
-        *
-        * @return Array
-        */
-       protected function getExtensionUpdaters() {
-               return $this->extensionUpdaters;
-       }
-
        public function getPostDatabaseUpdateMaintenance() {
                return $this->postDatabaseUpdateMaintenance;
        }
@@ -250,10 +198,6 @@ abstract class DatabaseUpdater {
                if ( isset( $what['extensions'] ) ) {
                        $this->runUpdates( $this->getOldGlobalUpdates(), false );
                        $this->runUpdates( $this->getExtensionUpdates(), true );
-                       foreach ( $this->getExtensionUpdaters() as $updaterClass ) {
-                               $eupdater = new $updaterClass( $this );
-                               $eupdater->doUpdates();
-                       }
                }
 
                $this->setAppliedUpdates( $wgVersion, $this->updates );