r23117 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r23116‎ | r23117 | r23118 >
Date:07:51, 20 June 2007
Author:aaron
Status:old
Tags:
Comment:
*Inject mImageTimestamps directly after using a single query through hooks
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php
@@ -245,7 +245,7 @@
246246 array('fr_namespace' => $page->getNamespace(), 'fr_title' => $page->getDBkey() ),
247247 __METHOD__ ,
248248 array('ORDER BY' => 'fr_rev_id DESC') );
249 - while ( $row = $db->fetchObject($result) ) {
 249+ while( $row = $db->fetchObject($result) ) {
250250 $rows[$row->fr_rev_id] = $row->fr_quality;
251251 }
252252 wfProfileOut( __METHOD__ );
@@ -667,6 +667,30 @@
668668
669669 $ig->isStable = true;
670670 }
 671+
 672+ static function parserInjectImageTimestamps( &$parser, &$text ) {
 673+ $images = array();
 674+ $parser->mOutput->mImageTimestamps = array();
 675+ # Fetch the timestamps of the images
 676+ if( !empty($parser->mOutput->mImages) ) {
 677+ $dbr = wfGetDB( DB_SLAVE );
 678+ foreach( $parser->mOutput->mImages as $name => $v ) {
 679+ $safename = $dbr->strencode( $name );
 680+ $images[] = "'$safename'";
 681+ }
 682+ $res = $dbr->select('image', array('img_name','img_timestamp'),
 683+ array('img_name IN(' . implode(',',$images) . ')'),
 684+ __METHOD__ );
 685+
 686+ while( $row = $dbr->fetchObject($res) ) {
 687+ $parser->mOutput->mImageTimestamps[$row->img_name] = $row->img_timestamp;
 688+ }
 689+ }
 690+ }
 691+
 692+ static function outputInjectImageTimestamps( &$out, &$parserOutput ) {
 693+ $out->mImageTimestamps = $parserOutput->mImageTimestamps;
 694+ }
671695
672696 /**
673697 * Callback that autopromotes user according to the setting in
@@ -1285,4 +1309,7 @@
12861310 $wgHooks['BeforeGalleryFindFile'][] = array( $flaggedrevs, 'galleryFindStableFileTime');
12871311 $wgHooks['BeforeParserFetchTemplateAndtitle'][] = array( $flaggedrevs, 'parserFetchStableTemplate');
12881312 $wgHooks['BeforeParserMakeImageLinkObj'][] = array( $flaggedrevs, 'parserMakeStableImageLink');
 1313+// Additional parser versioning
 1314+$wgHooks['ParserAfterTidy'][] = array( $flaggedrevs, 'parserInjectImageTimestamps');
 1315+$wgHooks['OutputPageParserOutput'][] = array( $flaggedrevs, 'outputInjectImageTimestamps');
12891316 ?>

Status & tagging log