From 51df60c3518b14c7a3be239524271ec6faff42d0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Niklas=20Laxstr=C3=B6m?= Date: Tue, 14 Sep 2010 09:23:43 +0000 Subject: [PATCH] Fix broken r72956 with another approach --- includes/ResourceLoaderModule.php | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/includes/ResourceLoaderModule.php b/includes/ResourceLoaderModule.php index 990a814d8e..e7fc1cf52c 100644 --- a/includes/ResourceLoaderModule.php +++ b/includes/ResourceLoaderModule.php @@ -740,28 +740,26 @@ abstract class ResourceLoaderWikiModule extends ResourceLoaderModule { if ( isset( $this->modifiedTime[$hash] ) ) { return $this->modifiedTime[$hash]; } + $titles = array(); foreach ( $this->getPages( $context ) as $page => $options ) { - $titles[] = Title::makeTitle( $options['ns'], $page ); + $titles[$options['ns']][$page] = true; } - // 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() ) { - $ids[] = $title->getArticleId(); + if ( $titles ) { + $dbr = wfGetDB( DB_SLAVE ); + $latest = $dbr->selectField( 'page', 'MAX(page_touched)', + $dbr->makeWhereFrom2d( $titles, 'page_namespace', 'page_title' ), + __METHOD__ ); + + if ( $latest ) { + $modifiedTime = wfTimestamp( TS_UNIX, $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 ); + return $this->modifiedTime[$hash] = $modifiedTime; } } -- 2.20.1