From e3d73b29873a33d95ca9f4c1b931d13a93be16f1 Mon Sep 17 00:00:00 2001 From: Alexandre Emsenhuber Date: Tue, 7 Sep 2010 20:45:04 +0000 Subject: [PATCH] added Maintenance::afterFinalSetup() instead of having to define a callback with MW_CMDLINE_CALLBACK --- maintenance/Maintenance.php | 15 +++++++++++---- maintenance/update.php | 27 +++++++++++++-------------- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/maintenance/Maintenance.php b/maintenance/Maintenance.php index 8e6b5e3d52..bf0639b3fb 100644 --- a/maintenance/Maintenance.php +++ b/maintenance/Maintenance.php @@ -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 diff --git a/maintenance/update.php b/maintenance/update.php index a1cb8c4f0d..5809e60318 100644 --- a/maintenance/update.php +++ b/maintenance/update.php @@ -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'; -- 2.20.1