From: Niklas Laxström Date: Tue, 14 Sep 2010 09:23:43 +0000 (+0000) Subject: Fix broken r72956 with another approach X-Git-Tag: 1.31.0-rc.0~34936 X-Git-Url: https://git.cyclocoop.org//%22?a=commitdiff_plain;h=51df60c3518b14c7a3be239524271ec6faff42d0;p=lhc%2Fweb%2Fwiklou.git Fix broken r72956 with another approach --- 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; } }