http://www.mediawiki.org/wiki/Special:Code/MediaWiki/72949
Revision: 72949
Author: tparscal
Date: 2010-09-14 00:45:53 +0000 (Tue, 14 Sep 2010)
Log Message:
-----------
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: trunk/phase3/includes/ResourceLoaderModule.php
===================================================================
--- trunk/phase3/includes/ResourceLoaderModule.php 2010-09-14 00:44:26 UTC
(rev 72948)
+++ trunk/phase3/includes/ResourceLoaderModule.php 2010-09-14 00:45:53 UTC
(rev 72949)
@@ -454,19 +454,20 @@
$this->loaders,
$this->getFileDependencies( $context->getSkin() )
);
-
$filesMtime = max( array_map( 'filemtime', array_map( array(
__CLASS__, 'remapFilename' ), $files ) ) );
-
- // Get the mtime of the message blob
- // TODO: This timestamp is queried a lot and queried separately
for each module. Maybe it should be put in memcached?
- $dbr = wfGetDb( DB_SLAVE );
- $msgBlobMtime = $dbr->selectField( 'msg_resource',
'mr_timestamp', array(
- 'mr_resource' => $this->getName(),
- 'mr_lang' => $context->getLanguage()
- ), __METHOD__
- );
- $msgBlobMtime = $msgBlobMtime ? wfTimestamp( TS_UNIX,
$msgBlobMtime ) : 0;
-
+ // Only get the message timestamp if there are messages in the
module
+ $msgBlobMtime = 0;
+ if ( count( $this->messages ) ) {
+ // Get the mtime of the message blob
+ // TODO: This timestamp is queried a lot and queried
separately for each module. Maybe it should be put in memcached?
+ $dbr = wfGetDb( DB_SLAVE );
+ $msgBlobMtime = $dbr->selectField( 'msg_resource',
'mr_timestamp', array(
+ 'mr_resource' => $this->getName(),
+ 'mr_lang' => $context->getLanguage()
+ ), __METHOD__
+ );
+ $msgBlobMtime = $msgBlobMtime ? wfTimestamp( TS_UNIX,
$msgBlobMtime ) : 0;
+ }
$this->modifiedTime[$context->getHash()] = max( $filesMtime,
$msgBlobMtime );
return $this->modifiedTime[$context->getHash()];
}
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs