From eef9a8cdd7c149a374eb094750410f306fc85947 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Fri, 19 Dec 2008 09:21:20 +0000 Subject: [PATCH] Tweaks from profiling --- includes/OutputPage.php | 31 ++++++++++++++----------------- includes/Wiki.php | 8 ++++---- index.php | 2 +- 3 files changed, 19 insertions(+), 22 deletions(-) diff --git a/includes/OutputPage.php b/includes/OutputPage.php index dcd5c309be..f943988d62 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -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,27 +211,25 @@ class OutputPage { # this breaks strtotime(). $clientHeader = preg_replace( '/;.*$/', '', $_SERVER["HTTP_IF_MODIFIED_SINCE"] ); - wfSuppressWarnings(); // E_STRICT system time bitching - $clientHeaderTime = strtotime( $clientHeader ); - wfRestoreWarnings(); - if ( !$clientHeaderTime ) { + $clientHeaderTime = @strtotime( $clientHeader ); // E_STRICT system time bitching + 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(); @@ -739,10 +737,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' ); @@ -750,10 +748,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 @@ -779,7 +777,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 { @@ -971,7 +969,6 @@ class OutputPage { */ public static function setEncodings() { global $wgInputEncoding, $wgOutputEncoding; - global $wgUser, $wgContLang; $wgInputEncoding = strtolower( $wgInputEncoding ); diff --git a/includes/Wiki.php b/includes/Wiki.php index 649b07b6c2..b05ae13b64 100644 --- a/includes/Wiki.php +++ b/includes/Wiki.php @@ -109,9 +109,8 @@ 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( count( $wgContLang->getVariants() ) > 1 && !is_null( $ret ) && $ret->getArticleID() == 0 ) + if( !is_null($ret) && $wgContLang->hasVariants() && $ret->getArticleID() == 0 ) $wgContLang->findVariantLink( $title, $ret ); - } if( ( $oldid = $wgRequest->getInt( 'oldid' ) ) && ( is_null( $ret ) || $ret->getNamespace() != NS_SPECIAL ) ) { @@ -240,7 +239,8 @@ class MediaWiki { } } wfProfileOut( __METHOD__ ); - return true; + $this->restInPeace(); + exit; } } /* No match to special cases */ @@ -372,7 +372,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; } diff --git a/index.php b/index.php index 88585792f8..c97a87aac1 100644 --- 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 ); -- 2.20.1