(bug 27891) Follow-up r72475: destroy the LBFactory singleton before doing any jobs...
authorBryan Tong Minh <btongminh@users.mediawiki.org>
Thu, 26 May 2011 17:11:51 +0000 (17:11 +0000)
committerBryan Tong Minh <btongminh@users.mediawiki.org>
Thu, 26 May 2011 17:11:51 +0000 (17:11 +0000)
includes/Wiki.php

index 86017bd..c447b24 100644 (file)
@@ -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();
        }
 
        /**