Revert r44801 "Tweaks from profiling"
authorBrion Vibber <brion@users.mediawiki.org>
Tue, 23 Dec 2008 19:39:00 +0000 (19:39 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Tue, 23 Dec 2008 19:39:00 +0000 (19:39 +0000)
Mostly seems to be formatting tweaks, loss of useful debug log output, and mysterious unexplained changes.
If some of these tweaks actually are based on profiling data, please provide details, such as "rearranging this call reduces service time from 80ms to 50ms for client cache hits on my machine" or whatever.

includes/OutputPage.php
includes/Wiki.php
index.php

index f943988..dcd5c30 100644 (file)
@@ -165,7 +165,7 @@ class OutputPage {
         *
         * @return bool True iff cache-ok headers was sent.
         */
-       function checkLastModified( $timestamp ) {
+       function checkLastModified ( $timestamp ) {
                global $wgCachePages, $wgCacheEpoch, $wgUser, $wgRequest;
                
                if ( !$timestamp || $timestamp == '19700101000000' ) {
@@ -199,8 +199,8 @@ class OutputPage {
 
                # Make debug info
                $info = '';
-               foreach( $modifiedTimes as $name => $value ) {
-                       if( $info !== '' ) {
+               foreach ( $modifiedTimes as $name => $value ) {
+                       if ( $info !== '' ) {
                                $info .= ', ';
                        }
                        $info .= "$name=" . wfTimestamp( TS_ISO_8601, $value );
@@ -211,25 +211,27 @@ class OutputPage {
                # this breaks strtotime().
                $clientHeader = preg_replace( '/;.*$/', '', $_SERVER["HTTP_IF_MODIFIED_SINCE"] );
 
-               $clientHeaderTime = @strtotime( $clientHeader ); // E_STRICT system time bitching
-               if( !$clientHeaderTime ) {
+               wfSuppressWarnings(); // E_STRICT system time bitching
+               $clientHeaderTime = strtotime( $clientHeader );
+               wfRestoreWarnings();
+               if ( !$clientHeaderTime ) {
                        wfDebug( __METHOD__ . ": unable to parse the client's If-Modified-Since header: $clientHeader\n" );
                        return false;
                }
                $clientHeaderTime = wfTimestamp( TS_MW, $clientHeaderTime );
 
-               /*
                wfDebug( __METHOD__ . ": client sent If-Modified-Since: " . 
                        wfTimestamp( TS_ISO_8601, $clientHeaderTime ) . "\n", false );
                wfDebug( __METHOD__ . ": effective Last-Modified: " . 
                        wfTimestamp( TS_ISO_8601, $maxModified ) . "\n", false );
-               */
                if( $clientHeaderTime < $maxModified ) {
                        wfDebug( __METHOD__ . ": STALE, $info\n", false );
                        return false;
                }
 
+               # Not modified
                # Give a 304 response code and disable body output 
+               wfDebug( __METHOD__ . ": NOT MODIFIED, $info\n", false );
                $wgRequest->response()->header( "HTTP/1.1 304 Not Modified" );
                $this->sendCacheControl();
                $this->disable();
@@ -737,10 +739,10 @@ class OutputPage {
                global $wgUseSquid, $wgUseESI, $wgUseETag, $wgSquidMaxage, $wgRequest;
 
                $response = $wgRequest->response();
-               if( $wgUseETag && $this->mETag ) {
+               if ($wgUseETag && $this->mETag)
                        $response->header("ETag: $this->mETag");
-               }
-               # Don't serve compressed data to clients who can't handle it
+
+               # don't serve compressed data to clients who can't handle it
                # maintain different caches for logged-in users and non-logged in ones
                $response->header( 'Vary: Accept-Encoding, Cookie' );
 
@@ -748,10 +750,10 @@ class OutputPage {
                $response->header( $this->getXVO() );
 
                if( !$this->uncacheableBecauseRequestVars() && $this->mEnableClientCache ) {
-                       if( $wgUseSquid && session_id() == '' && !$this->isPrintable() && 
-                               $this->mSquidMaxage != 0 && !$this->haveCacheVaryCookies() )
+                       if( $wgUseSquid && session_id() == '' &&
+                         ! $this->isPrintable() && $this->mSquidMaxage != 0 && !$this->haveCacheVaryCookies() )
                        {
-                               if( $wgUseESI ) {
+                               if ( $wgUseESI ) {
                                        # We'll purge the proxy cache explicitly, but require end user agents
                                        # to revalidate against the proxy on each visit.
                                        # Surrogate-Control controls our Squid, Cache-Control downstream caches
@@ -777,7 +779,7 @@ class OutputPage {
                                $response->header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', 0 ) . ' GMT' );
                                $response->header( "Cache-Control: private, must-revalidate, max-age=0" );
                        }
-                       if( $this->mLastModified ) {
+                       if($this->mLastModified) {
                                $response->header( "Last-Modified: {$this->mLastModified}" );
                        }
                } else {
@@ -969,6 +971,7 @@ class OutputPage {
         */
        public static function setEncodings() {
                global $wgInputEncoding, $wgOutputEncoding;
+               global $wgUser, $wgContLang;
 
                $wgInputEncoding = strtolower( $wgInputEncoding );
 
index 6e96fba..9feeb08 100644 (file)
@@ -109,8 +109,9 @@ class MediaWiki {
                        $ret = Title::newFromURL( $title );
                        // check variant links so that interwiki links don't have to worry
                        // about the possible different language variants
-                       if( !is_null($ret) && $wgContLang->hasVariants() && $ret->getArticleID() == 0 )
+                       if( count( $wgContLang->getVariants() ) > 1 && !is_null( $ret ) && $ret->getArticleID() == 0 )
                                $wgContLang->findVariantLink( $title, $ret );
+
                }
                if( ( $oldid = $wgRequest->getInt( 'oldid' ) )
                        && ( is_null( $ret ) || $ret->getNamespace() != NS_SPECIAL ) ) {
@@ -234,8 +235,7 @@ class MediaWiki {
                                                $article->viewUpdates();
                                        }
                                        wfProfileOut( __METHOD__ );
-                                       $this->restInPeace();
-                                       exit;
+                                       return true;
                                }
                        }
                        /* No match to special cases */
@@ -368,7 +368,7 @@ class MediaWiki {
        function doUpdates( &$updates ) {
                wfProfileIn( __METHOD__ );
                /* No need to get master connections in case of empty updates array */
-               if( !$updates ) {
+               if (!$updates) {
                        wfProfileOut( __METHOD__ );
                        return;
                }
index c97a87a..8858579 100644 (file)
--- a/index.php
+++ b/index.php
@@ -89,7 +89,7 @@ $mediaWiki->setVal( 'UseExternalEditor', $wgUseExternalEditor );
 $mediaWiki->setVal( 'UsePathInfo', $wgUsePathInfo );
 
 $mediaWiki->initialize( $wgTitle, $wgArticle, $wgOut, $wgUser, $wgRequest );
-$mediaWiki->finalCleanup( $wgDeferredUpdateList, $wgOut );
+$mediaWiki->finalCleanup ( $wgDeferredUpdateList, $wgOut );
 
 # Not sure when $wgPostCommitUpdateList gets set, so I keep this separate from finalCleanup
 $mediaWiki->doUpdates( $wgPostCommitUpdateList );