r72949 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r72948‎ | r72949 | r72950 >
Date:00:45, 14 September 2010
Author:tparscal
Status:ok (Comments)
Tags:
Comment:
Reduced (dramatically) the number of database queries being performed to evaluate the last modified time of a module by only checking the mr_timestamp table when there are messages in the module.
Modified paths:
  • /trunk/phase3/includes/ResourceLoaderModule.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/ResourceLoaderModule.php
@@ -454,19 +454,20 @@
455455 $this->loaders,
456456 $this->getFileDependencies( $context->getSkin() )
457457 );
458 -
459458 $filesMtime = max( array_map( 'filemtime', array_map( array( __CLASS__, 'remapFilename' ), $files ) ) );
460 -
461 - // Get the mtime of the message blob
462 - // TODO: This timestamp is queried a lot and queried separately for each module. Maybe it should be put in memcached?
463 - $dbr = wfGetDb( DB_SLAVE );
464 - $msgBlobMtime = $dbr->selectField( 'msg_resource', 'mr_timestamp', array(
465 - 'mr_resource' => $this->getName(),
466 - 'mr_lang' => $context->getLanguage()
467 - ), __METHOD__
468 - );
469 - $msgBlobMtime = $msgBlobMtime ? wfTimestamp( TS_UNIX, $msgBlobMtime ) : 0;
470 -
 459+ // Only get the message timestamp if there are messages in the module
 460+ $msgBlobMtime = 0;
 461+ if ( count( $this->messages ) ) {
 462+ // Get the mtime of the message blob
 463+ // TODO: This timestamp is queried a lot and queried separately for each module. Maybe it should be put in memcached?
 464+ $dbr = wfGetDb( DB_SLAVE );
 465+ $msgBlobMtime = $dbr->selectField( 'msg_resource', 'mr_timestamp', array(
 466+ 'mr_resource' => $this->getName(),
 467+ 'mr_lang' => $context->getLanguage()
 468+ ), __METHOD__
 469+ );
 470+ $msgBlobMtime = $msgBlobMtime ? wfTimestamp( TS_UNIX, $msgBlobMtime ) : 0;
 471+ }
471472 $this->modifiedTime[$context->getHash()] = max( $filesMtime, $msgBlobMtime );
472473 return $this->modifiedTime[$context->getHash()];
473474 }

Comments

#Comment by MZMcBride (talk | contribs)   16:59, 14 September 2010

Related to bug 25143.

Status & tagging log