From 9045d4ec3abc634d7d2bc41bf552372fdd2f83f7 Mon Sep 17 00:00:00 2001 From: Bryan Tong Minh Date: Thu, 26 May 2011 17:11:51 +0000 Subject: [PATCH] (bug 27891) Follow-up r72475: destroy the LBFactory singleton before doing any jobs so that jobs do not access the current session while still preserving ChronologyProtector. --- includes/Wiki.php | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/includes/Wiki.php b/includes/Wiki.php index 86017bd346..c447b24253 100644 --- a/includes/Wiki.php +++ b/includes/Wiki.php @@ -321,8 +321,7 @@ class MediaWiki { $this->context->output->output(); // Do any deferred jobs wfDoUpdates( 'commit' ); - // Close the session so that jobs don't access the current session - session_write_close(); + $this->doJobs(); wfProfileOut( __METHOD__ ); } @@ -345,6 +344,10 @@ class MediaWiki { } else { $n = intval( $wgJobRunRate ); } + + // Close the session so that jobs don't access the current session + $this->shutdownLBFactory(); + session_write_close(); while ( $n-- && false != ( $job = Job::pop() ) ) { $output = $job->toString() . "\n"; @@ -367,11 +370,20 @@ class MediaWiki { public function restInPeace() { MessageCache::logMessages(); wfLogProfilingData(); + $this->shutdownLBFactory(); + wfDebug( "Request ended normally\n" ); + } + + /** + * Commit pending master changes, shutdown the current loadbalancer + * factory and destroys the factory instance. + */ + private function shutdownLBFactory() { // Commit and close up! - $factory = wfGetLBFactory(); + $factory = LBFactory::singleton(); $factory->commitMasterChanges(); $factory->shutdown(); - wfDebug( "Request ended normally\n" ); + LBFactory::destroyInstance(); } /** -- 2.20.1