r44963 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r44962‎ | r44963 | r44964 >
Date:19:39, 23 December 2008
Author:brion
Status:ok
Tags:
Comment:
Revert r44801 "Tweaks from profiling"
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.
Modified paths:
  • /trunk/phase3/includes/OutputPage.php (modified) (history)
  • /trunk/phase3/includes/Wiki.php (modified) (history)
  • /trunk/phase3/index.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/OutputPage.php
@@ -165,7 +165,7 @@
166166 *
167167 * @return bool True iff cache-ok headers was sent.
168168 */
169 - function checkLastModified( $timestamp ) {
 169+ function checkLastModified ( $timestamp ) {
170170 global $wgCachePages, $wgCacheEpoch, $wgUser, $wgRequest;
171171
172172 if ( !$timestamp || $timestamp == '19700101000000' ) {
@@ -199,8 +199,8 @@
200200
201201 # Make debug info
202202 $info = '';
203 - foreach( $modifiedTimes as $name => $value ) {
204 - if( $info !== '' ) {
 203+ foreach ( $modifiedTimes as $name => $value ) {
 204+ if ( $info !== '' ) {
205205 $info .= ', ';
206206 }
207207 $info .= "$name=" . wfTimestamp( TS_ISO_8601, $value );
@@ -211,25 +211,27 @@
212212 # this breaks strtotime().
213213 $clientHeader = preg_replace( '/;.*$/', '', $_SERVER["HTTP_IF_MODIFIED_SINCE"] );
214214
215 - $clientHeaderTime = @strtotime( $clientHeader ); // E_STRICT system time bitching
216 - if( !$clientHeaderTime ) {
 215+ wfSuppressWarnings(); // E_STRICT system time bitching
 216+ $clientHeaderTime = strtotime( $clientHeader );
 217+ wfRestoreWarnings();
 218+ if ( !$clientHeaderTime ) {
217219 wfDebug( __METHOD__ . ": unable to parse the client's If-Modified-Since header: $clientHeader\n" );
218220 return false;
219221 }
220222 $clientHeaderTime = wfTimestamp( TS_MW, $clientHeaderTime );
221223
222 - /*
223224 wfDebug( __METHOD__ . ": client sent If-Modified-Since: " .
224225 wfTimestamp( TS_ISO_8601, $clientHeaderTime ) . "\n", false );
225226 wfDebug( __METHOD__ . ": effective Last-Modified: " .
226227 wfTimestamp( TS_ISO_8601, $maxModified ) . "\n", false );
227 - */
228228 if( $clientHeaderTime < $maxModified ) {
229229 wfDebug( __METHOD__ . ": STALE, $info\n", false );
230230 return false;
231231 }
232232
 233+ # Not modified
233234 # Give a 304 response code and disable body output
 235+ wfDebug( __METHOD__ . ": NOT MODIFIED, $info\n", false );
234236 $wgRequest->response()->header( "HTTP/1.1 304 Not Modified" );
235237 $this->sendCacheControl();
236238 $this->disable();
@@ -737,10 +739,10 @@
738740 global $wgUseSquid, $wgUseESI, $wgUseETag, $wgSquidMaxage, $wgRequest;
739741
740742 $response = $wgRequest->response();
741 - if( $wgUseETag && $this->mETag ) {
 743+ if ($wgUseETag && $this->mETag)
742744 $response->header("ETag: $this->mETag");
743 - }
744 - # Don't serve compressed data to clients who can't handle it
 745+
 746+ # don't serve compressed data to clients who can't handle it
745747 # maintain different caches for logged-in users and non-logged in ones
746748 $response->header( 'Vary: Accept-Encoding, Cookie' );
747749
@@ -748,10 +750,10 @@
749751 $response->header( $this->getXVO() );
750752
751753 if( !$this->uncacheableBecauseRequestVars() && $this->mEnableClientCache ) {
752 - if( $wgUseSquid && session_id() == '' && !$this->isPrintable() &&
753 - $this->mSquidMaxage != 0 && !$this->haveCacheVaryCookies() )
 754+ if( $wgUseSquid && session_id() == '' &&
 755+ ! $this->isPrintable() && $this->mSquidMaxage != 0 && !$this->haveCacheVaryCookies() )
754756 {
755 - if( $wgUseESI ) {
 757+ if ( $wgUseESI ) {
756758 # We'll purge the proxy cache explicitly, but require end user agents
757759 # to revalidate against the proxy on each visit.
758760 # Surrogate-Control controls our Squid, Cache-Control downstream caches
@@ -777,7 +779,7 @@
778780 $response->header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', 0 ) . ' GMT' );
779781 $response->header( "Cache-Control: private, must-revalidate, max-age=0" );
780782 }
781 - if( $this->mLastModified ) {
 783+ if($this->mLastModified) {
782784 $response->header( "Last-Modified: {$this->mLastModified}" );
783785 }
784786 } else {
@@ -969,6 +971,7 @@
970972 */
971973 public static function setEncodings() {
972974 global $wgInputEncoding, $wgOutputEncoding;
 975+ global $wgUser, $wgContLang;
973976
974977 $wgInputEncoding = strtolower( $wgInputEncoding );
975978
Index: trunk/phase3/includes/Wiki.php
@@ -109,8 +109,9 @@
110110 $ret = Title::newFromURL( $title );
111111 // check variant links so that interwiki links don't have to worry
112112 // about the possible different language variants
113 - if( !is_null($ret) && $wgContLang->hasVariants() && $ret->getArticleID() == 0 )
 113+ if( count( $wgContLang->getVariants() ) > 1 && !is_null( $ret ) && $ret->getArticleID() == 0 )
114114 $wgContLang->findVariantLink( $title, $ret );
 115+
115116 }
116117 if( ( $oldid = $wgRequest->getInt( 'oldid' ) )
117118 && ( is_null( $ret ) || $ret->getNamespace() != NS_SPECIAL ) ) {
@@ -234,8 +235,7 @@
235236 $article->viewUpdates();
236237 }
237238 wfProfileOut( __METHOD__ );
238 - $this->restInPeace();
239 - exit;
 239+ return true;
240240 }
241241 }
242242 /* No match to special cases */
@@ -368,7 +368,7 @@
369369 function doUpdates( &$updates ) {
370370 wfProfileIn( __METHOD__ );
371371 /* No need to get master connections in case of empty updates array */
372 - if( !$updates ) {
 372+ if (!$updates) {
373373 wfProfileOut( __METHOD__ );
374374 return;
375375 }
Index: trunk/phase3/index.php
@@ -89,7 +89,7 @@
9090 $mediaWiki->setVal( 'UsePathInfo', $wgUsePathInfo );
9191
9292 $mediaWiki->initialize( $wgTitle, $wgArticle, $wgOut, $wgUser, $wgRequest );
93 -$mediaWiki->finalCleanup( $wgDeferredUpdateList, $wgOut );
 93+$mediaWiki->finalCleanup ( $wgDeferredUpdateList, $wgOut );
9494
9595 # Not sure when $wgPostCommitUpdateList gets set, so I keep this separate from finalCleanup
9696 $mediaWiki->doUpdates( $wgPostCommitUpdateList );

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r44801Tweaks from profilingaaron09:21, 19 December 2008

Status & tagging log