Execute jobs on all index.php requests.
authorAlexandre Emsenhuber <ialex.wiki@gmail.com>
Fri, 20 Jul 2012 20:38:24 +0000 (22:38 +0200)
committerAlexandre Emsenhuber <ialex.wiki@gmail.com>
Sat, 21 Jul 2012 06:14:43 +0000 (08:14 +0200)
The problem is that currently deferred updates are not executed
after action=ajax requests or file cache hits. This means that,
e.g. ViewCountUpdates are not executed after file cache hits.
The code to execute jobs (both deferred updates and job queue)
is now in MediaWiki::restInPeace() so that it's also executed
after what is mentioned above, and the remaining code of
MediaWiki::finalCleanup() is moved directly MediaWiki::main()
since that function is only used in one place and it make no
sense to keep a method for such little code.

Change-Id: I6f511a74c59a2e3653c10bfcff9b0d15118e699f

includes/Wiki.php

index 7efb082..5f593e7 100644 (file)
@@ -392,23 +392,6 @@ class MediaWiki {
                return $article;
        }
 
-       /**
-        * Cleaning up request by doing deferred updates, DB transaction, and the output
-        */
-       public function finalCleanup() {
-               wfProfileIn( __METHOD__ );
-               // Now commit any transactions, so that unreported errors after
-               // output() don't roll back the whole DB transaction
-               $factory = wfGetLBFactory();
-               $factory->commitMasterChanges();
-               // Output everything!
-               $this->context->getOutput()->output();
-               // Do any deferred jobs
-               DeferredUpdates::doUpdates( 'commit' );
-               $this->doJobs();
-               wfProfileOut( __METHOD__ );
-       }
-
        /**
         * Do a job from the job queue
         */
@@ -447,12 +430,23 @@ class MediaWiki {
         * Ends this task peacefully
         */
        public function restInPeace() {
+               // Do any deferred jobs
+               DeferredUpdates::doUpdates( 'commit' );
+
+               // Execute a job from the queue
+               $this->doJobs();
+
+               // Log message usage, if $wgAdaptiveMessageCache is set to true
                MessageCache::logMessages();
+
+               // Log profiling data, e.g. in the database or UDP
                wfLogProfilingData();
+
                // Commit and close up!
                $factory = wfGetLBFactory();
                $factory->commitMasterChanges();
                $factory->shutdown();
+
                wfDebug( "Request ended normally\n" );
        }
 
@@ -599,7 +593,13 @@ class MediaWiki {
                }
 
                $this->performRequest();
-               $this->finalCleanup();
+
+               // Now commit any transactions, so that unreported errors after
+               // output() don't roll back the whole DB transaction
+               wfGetLBFactory()->commitMasterChanges();
+
+               // Output everything!
+               $this->context->getOutput()->output();
 
                wfProfileOut( __METHOD__ );
        }