r112282 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r112281‎ | r112282 | r112283 >
Date:01:13, 24 February 2012
Author:aaron
Status:ok
Tags:1.19 
Comment:
Fixes to parserFetchStableFile() hook:
* Do not set $options to have false values for sha1 (or timestamp just in case). Parser will try to lookup via SHA1 if the sha1 parameter is set, even if it's set to false. This can mean fetching the file with SHA1 equal to "", which is apparently code for the Swedish flag...
* Actually append ?filetimestamp= instead of writing over the whole $query var.
Modified paths:
  • /trunk/extensions/FlaggedRevs/backend/FlaggedRevs.hooks.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/backend/FlaggedRevs.hooks.php
@@ -193,7 +193,7 @@
194194 $title = Title::makeTitle( NS_FILE, $title->getDBkey() );
195195 $title->resetArticleId( $title->getArticleId() ); // avoid extra queries
196196 }
197 - $time = $sha1 = false; // current version
 197+ $time = $sha1 = false; // unspecified (defaults to current version)
198198 # Check for the version of this file used when reviewed...
199199 list( $maybeTS, $maybeSha1 ) = $incManager->getReviewedFileVersion( $title );
200200 if ( $maybeTS !== null ) {
@@ -209,15 +209,17 @@
210210 $sha1 = $maybeSha1;
211211 }
212212 }
213 - # Stabilize the file link
214 - if ( $time ) {
215 - if ( $query != '' ) $query .= '&';
216 - $query = "filetimestamp=" . urlencode( wfTimestamp( TS_MW, $time ) );
217 - }
218 - $options['time'] = $time;
219 - $options['sha1'] = $sha1;
 213+ # Tell Parser what file version to use
220214 if ( $time === '0' ) {
221215 $options['broken'] = true;
 216+ } elseif ( $time !== false ) {
 217+ $options['time'] = $time;
 218+ $options['sha1'] = $sha1;
 219+ # Stabilize the file link
 220+ if ( $query != '' ) {
 221+ $query .= '&';
 222+ }
 223+ $query .= "filetimestamp=" . urlencode( wfTimestamp( TS_MW, $time ) );
222224 }
223225
224226 return true;

Follow-up revisions

RevisionCommit summaryAuthorDate
r112284MFT r112282aaron01:16, 24 February 2012

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r96357Cleanup to r84610 per CR: changed BeforeParserMakeImageLinkObj hook to use a ...aaron18:11, 6 September 2011

Status & tagging log