From 7e26c3350b9b692e86de8c5dd5b73f5debe999b0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Niklas=20Laxstr=C3=B6m?= Date: Tue, 14 Sep 2010 07:32:08 +0000 Subject: [PATCH] Use only single query for determinging highest page_touched, which is not loaded by link batch. Every query is still executed twice, apparently for different modules, but why? --- includes/ResourceLoaderModule.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/includes/ResourceLoaderModule.php b/includes/ResourceLoaderModule.php index b8fbb16ecf..3551d2e7de 100644 --- a/includes/ResourceLoaderModule.php +++ b/includes/ResourceLoaderModule.php @@ -747,14 +747,21 @@ abstract class ResourceLoaderWikiModule extends ResourceLoaderModule { // Do batch existence check // TODO: This would work better if page_touched were loaded by this as well $lb = new LinkBatch( $titles ); + $lb->setCaller( __METHOD__ ); $lb->execute(); $modifiedTime = 1; // wfTimestamp() interprets 0 as "now" + + $ids = array(); foreach ( $titles as $title ) { if ( $title->exists() ) { - $modifiedTime = max( $modifiedTime, wfTimestamp( TS_UNIX, $title->getTouched() ) ); + $ids[] = $title->getArticleId(); } } - return $this->modifiedTime[$hash] = $modifiedTime; + + $dbr = wfGetDB( DB_SLAVE ); + $modifiedTime = $dbr->selectField( 'page', 'MAX(page_touched)', array( 'page_id' => $ids ), __METHOD__ ); + + return $this->modifiedTime[$hash] = wfTimestamp( TS_UNIX, $modifiedTime ); } } -- 2.20.1