Merge "jquery.accessKeyLabel: Update Opera access keys"
[lhc/web/wiklou.git] / includes / MediaWiki.php
index aee6ee1..38d9e47 100644 (file)
@@ -203,10 +203,9 @@ class MediaWiki {
                        // curid and oldid request  parameters would allow page titles to be enumerated even
                        // when they are not guessable. So we reset the title to Special:Badtitle before the
                        // permissions error is displayed.
-                       //
+
                        // The skin mostly uses $this->context->getTitle() these days, but some extensions
                        // still use $wgTitle.
-
                        $badTitle = SpecialPage::getTitleFor( 'Badtitle' );
                        $this->context->setTitle( $badTitle );
                        $wgTitle = $badTitle;
@@ -487,13 +486,22 @@ class MediaWiki {
                $this->doPostOutputShutdown( 'normal' );
        }
 
+       /**
+        * @see MediaWiki::preOutputCommit()
+        * @since 1.26
+        */
+       public function doPreOutputCommit() {
+               self::preOutputCommit( $this->context );
+       }
+
        /**
         * This function commits all DB changes as needed before
         * the user can receive a response (in case commit fails)
         *
-        * @since 1.26
+        * @param IContextSource $context
+        * @since 1.27
         */
-       public function doPreOutputCommit() {
+       public static function preOutputCommit( IContextSource $context ) {
                // Either all DBs should commit or none
                ignore_user_abort( true );
 
@@ -506,16 +514,18 @@ class MediaWiki {
 
                // Set a cookie to tell all CDN edge nodes to "stick" the user to the
                // DC that handles this POST request (e.g. the "master" data center)
-               $request = $this->context->getRequest();
+               $request = $context->getRequest();
+               $config = $context->getConfig();
                if ( $request->wasPosted() && $factory->hasOrMadeRecentMasterChanges() ) {
-                       $expires = time() + $this->config->get( 'DataCenterUpdateStickTTL' );
-                       $request->response()->setCookie( 'UseDC', 'master', $expires );
+                       $expires = time() + $config->get( 'DataCenterUpdateStickTTL' );
+                       $request->response()->setCookie( 'UseDC', 'master', $expires, array( 'prefix' => '' ) );
                }
 
                // Avoid letting a few seconds of slave lag cause a month of stale data
                if ( $factory->laggedSlaveUsed() ) {
-                       $maxAge = $this->config->get( 'CdnMaxageLagged' );
-                       $this->context->getOutput()->lowerCdnMaxage( $maxAge );
+                       $maxAge = $config->get( 'CdnMaxageLagged' );
+                       $context->getOutput()->lowerCdnMaxage( $maxAge );
+                       $request->response()->header( "X-Database-Lagged: true" );
                        wfDebugLog( 'replication', "Lagged DB used; CDN cache TTL limited to $maxAge seconds" );
                }
        }
@@ -531,6 +541,9 @@ class MediaWiki {
         * @since 1.26
         */
        public function doPostOutputShutdown( $mode = 'normal' ) {
+               $timing = $this->context->getTiming();
+               $timing->mark( 'requestShutdown' );
+
                // Show visible profiling data if enabled (which cannot be post-send)
                Profiler::instance()->logDataPageOutputOnly();
 
@@ -628,7 +641,7 @@ class MediaWiki {
                                        // redirecting to HTTPS. It's likely such a request is going
                                        // to fail due to post data being lost, but let's try anyway
                                        // and just log the instance.
-                                       //
+
                                        // @todo FIXME: See if we could issue a 307 or 308 here, need
                                        // to see how clients (automated & browser) behave when we do
                                        wfDebugLog( 'RedirectedPosts', "Redirected from HTTP to HTTPS: $oldUrl" );
@@ -690,7 +703,7 @@ class MediaWiki {
                Profiler::instance()->getTransactionProfiler()->resetExpectations();
 
                // Do any deferred jobs
-               DeferredUpdates::doUpdates( 'commit', 'enqueue' );
+               DeferredUpdates::doUpdates( 'enqueue' );
 
                // Make sure any lazy jobs are pushed
                JobQueueGroup::pushLazyJobs();
@@ -707,7 +720,7 @@ class MediaWiki {
                // Commit and close up!
                $factory = wfGetLBFactory();
                $factory->commitMasterChanges();
-               $factory->shutdown();
+               $factory->shutdown( LBFactory::SHUTDOWN_NO_CHRONPROT );
 
                wfDebug( "Request ended normally\n" );
        }