r47596 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r47595‎ | r47596 | r47597 >
Date:03:38, 21 February 2009
Author:aaron
Status:ok
Tags:
Comment:
More performance tweaks & sanity checks
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php
@@ -325,11 +325,8 @@
326326 */
327327 public static function parserFetchStableTemplate( $parser, $title, &$skip, &$id ) {
328328 # Trigger for stable version parsing only
329 - if( !$parser || empty($parser->fr_isStable) )
 329+ if( !$parser || empty($parser->fr_isStable) || $title->getNamespace() < 0 ) {
330330 return true;
331 - # Special namespace ... ?
332 - if( $title->getNamespace() < 0 ) {
333 - return true;
334331 }
335332 $dbr = wfGetDB( DB_SLAVE );
336333 # Check for stable version of template if this feature is enabled.
@@ -347,7 +344,7 @@
348345 }
349346 # If there is no stable version (or that feature is not enabled), use
350347 # the template revision during review time. If both, use the newest one.
351 - if( !FlaggedRevs::useProcessCache( $parser->getRevisionId() ) ) {
 348+ if( $parser->getRevisionId() && !FlaggedRevs::useProcessCache( $parser->getRevisionId() ) ) {
352349 $idP = $dbr->selectField( 'flaggedtemplates',
353350 'ft_tmp_rev_id',
354351 array( 'ft_rev_id' => $parser->getRevisionId(),
@@ -355,6 +352,7 @@
356353 'ft_title' => $title->getDBkey() ),
357354 __METHOD__
358355 );
 356+ # Take the newest (or only available) of the two
359357 $id = ($id === false || $idP > $id) ? $idP : $id;
360358 }
361359 # If none specified, see if we are allowed to use the current revision
@@ -380,7 +378,7 @@
381379 */
382380 public static function parserMakeStableImageLink( $parser, $nt, &$skip, &$time, &$query=false ) {
383381 # Trigger for stable version parsing only
384 - if( empty($parser->fr_isStable) ) {
 382+ if( empty($parser->fr_isStable) || $nt->getNamespace() < 0 ) {
385383 return true;
386384 }
387385 $file = null;
@@ -389,6 +387,7 @@
390388 # Normalize NS_MEDIA to NS_FILE
391389 if( $nt->getNamespace() == NS_MEDIA ) {
392390 $title = Title::makeTitle( NS_FILE, $nt->getDBKey() );
 391+ $title->resetArticleId( $nt->getArticleId() ); // avoid extra queries
393392 } else {
394393 $title =& $nt;
395394 }
@@ -417,7 +416,7 @@
418417 }
419418 # If there is no stable version (or that feature is not enabled), use
420419 # the image revision during review time. If both, use the newest one.
421 - if( !FlaggedRevs::useProcessCache( $parser->getRevisionId() ) ) {
 420+ if( $parser->getRevisionId() && !FlaggedRevs::useProcessCache( $parser->getRevisionId() ) ) {
422421 $row = $dbr->selectRow( 'flaggedimages',
423422 array( 'fi_img_timestamp', 'fi_img_sha1' ),
424423 array( 'fi_rev_id' => $parser->getRevisionId(), 'fi_name' => $title->getDBkey() ),
@@ -501,7 +500,7 @@
502501 }
503502 # If there is no stable version (or that feature is not enabled), use
504503 # the image revision during review time. If both, use the newest one.
505 - if( !FlaggedRevs::useProcessCache( $ig->mRevisionId ) ) {
 504+ if( $ig->mRevisionId && !FlaggedRevs::useProcessCache( $ig->mRevisionId ) ) {
506505 $row = $dbr->selectRow( 'flaggedimages',
507506 array( 'fi_img_timestamp', 'fi_img_sha1' ),
508507 array('fi_rev_id' => $ig->mRevisionId, 'fi_name' => $nt->getDBkey() ),

Status & tagging log