added Maintenance::afterFinalSetup() instead of having to define a callback with...
authorAlexandre Emsenhuber <ialex@users.mediawiki.org>
Tue, 7 Sep 2010 20:45:04 +0000 (20:45 +0000)
committerAlexandre Emsenhuber <ialex@users.mediawiki.org>
Tue, 7 Sep 2010 20:45:04 +0000 (20:45 +0000)
maintenance/Maintenance.php
maintenance/update.php

index 8e6b5e3..bf0639b 100644 (file)
@@ -694,12 +694,10 @@ abstract class Maintenance {
                                $wgLBFactoryConf['serverTemplate']['user'] = $wgDBuser;
                                $wgLBFactoryConf['serverTemplate']['password'] = $wgDBpassword;
                        }
+                       LBFactory::destroyInstance();
                }
 
-               if ( defined( 'MW_CMDLINE_CALLBACK' ) ) {
-                       $fn = MW_CMDLINE_CALLBACK;
-                       $fn();
-               }
+               $this->afterFinalSetup();
 
                $wgShowSQLErrors = true;
                @set_time_limit( 0 );
@@ -708,6 +706,15 @@ abstract class Maintenance {
                $wgProfiling = false; // only for Profiler.php mode; avoids OOM errors
        }
 
+       /**
+        * Execute a callback function at the end of initialisation
+        */
+       protected function afterFinalSetup() {
+               if ( defined( 'MW_CMDLINE_CALLBACK' ) ) {
+                       call_user_func( MW_CMDLINE_CALLBACK );
+               }
+       }
+
        /**
         * Potentially debug globals. Originally a feature only
         * for refreshLinks
index a1cb8c4..5809e60 100644 (file)
@@ -9,7 +9,6 @@
  * @ingroup Maintenance
  */
 
-define( 'MW_CMDLINE_CALLBACK', 'wfSetupUpdateScript' );
 $wgUseMasterForMaintenance = true;
 require_once( 'Maintenance.php' );
 
@@ -76,20 +75,20 @@ class UpdateMediaWiki extends Maintenance {
 
                $this->output( "Done.\n" );
        }
-}
 
-function wfSetupUpdateScript() {
-       global $wgLocalisationCacheConf;
-
-       # Don't try to access the database
-       # This needs to be disabled early since extensions will try to use the l10n
-       # cache from $wgExtensionSetupFunctions (bug 20471)
-       $wgLocalisationCacheConf = array(
-               'class' => 'LocalisationCache',
-               'storeClass' => 'LCStore_Null',
-               'storeDirectory' => false,
-               'manualRecache' => false,
-       );
+       protected function afterFinalSetup() {
+               global $wgLocalisationCacheConf;
+
+               # Don't try to access the database
+               # This needs to be disabled early since extensions will try to use the l10n
+               # cache from $wgExtensionSetupFunctions (bug 20471)
+               $wgLocalisationCacheConf = array(
+                       'class' => 'LocalisationCache',
+                       'storeClass' => 'LCStore_Null',
+                       'storeDirectory' => false,
+                       'manualRecache' => false,
+               );
+       }
 }
 
 $maintClass = 'UpdateMediaWiki';