r85305 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r85304‎ | r85305 | r85306 >
Date:01:22, 4 April 2011
Author:aaron
Status:ok
Tags:
Comment:
Follow-up changes to r84610:
* Cleaned up mImageTimeKeys format
* ImageMap: Removed redundant addImage call (makeImage handes this)
* ParserFunctions: added time/sha1 to addImage() call
* Removed excess ampersands in hooks
* Added some function doc comments
Modified paths:
  • /trunk/extensions/ImageMap/ImageMap_body.php (modified) (history)
  • /trunk/extensions/ParserFunctions/ParserFunctions_body.php (modified) (history)
  • /trunk/phase3/docs/hooks.txt (modified) (history)
  • /trunk/phase3/includes/ImageGallery.php (modified) (history)
  • /trunk/phase3/includes/OutputPage.php (modified) (history)
  • /trunk/phase3/includes/parser/Parser.php (modified) (history)
  • /trunk/phase3/includes/parser/ParserOutput.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ParserFunctions/ParserFunctions_body.php
@@ -336,7 +336,8 @@
337337 if ( !$file ) {
338338 return $else;
339339 }
340 - $parser->mOutput->addImage( $file->getName() );
 340+ $parser->mOutput->addImage(
 341+ $file->getName(), $file->getTimestamp(), $file->getSha1() );
341342 return $file->exists() ? $then : $else;
342343 } elseif ( $title->getNamespace() == NS_SPECIAL ) {
343344 /* Don't bother with the count for special pages,
Index: trunk/extensions/ImageMap/ImageMap_body.php
@@ -76,7 +76,6 @@
7777 $parser->replaceLinkHolders( $imageHTML );
7878 $imageHTML = $parser->mStripState->unstripBoth( $imageHTML );
7979 $imageHTML = Sanitizer::normalizeCharReferences( $imageHTML );
80 - $parser->mOutput->addImage( $imageTitle->getDBkey() );
8180
8281 $domDoc = new DOMDocument();
8382 wfSuppressWarnings();
Index: trunk/phase3/docs/hooks.txt
@@ -563,15 +563,15 @@
564564 &$skin: Skin object
565565
566566 'BeforeParserFetchFileAndTitle': before an image is rendered by Parser
567 -&$parser: Parser object
568 -&$nt: the image title
 567+$parser: Parser object
 568+$nt: the image title
569569 &$time: the image timestamp (use '0' to force a broken thumbnail)
570570 &$sha1: image base 36 sha1 (used to specify the file, $nt will be ignored if this is set)
571571 &$descQuery: query string to add to thumbnail URL
572572
573573 'BeforeParserFetchTemplateAndtitle': before a template is fetched by Parser
574 -&$parser: Parser object
575 -&$title: title of the template
 574+$parser: Parser object
 575+$title: title of the template
576576 &$skip: skip this template and link it?
577577 &$id: the id of the revision being parsed
578578
Index: trunk/phase3/includes/ImageGallery.php
@@ -242,7 +242,7 @@
243243 # Give extensions a chance to select the file revision for us
244244 $time = $sha1 = false;
245245 wfRunHooks( 'BeforeParserFetchFileAndTitle',
246 - array( $this->mParser, &$nt, &$time, &$sha1, &$descQuery ) );
 246+ array( $this->mParser, $nt, &$time, &$sha1, &$descQuery ) );
247247 # Fetch and register the file (file title may be different via hooks)
248248 list( $img, $nt ) = $this->mParser->fetchFileAndTitle( $nt, $time, $sha1 );
249249 } else {
Index: trunk/phase3/includes/parser/Parser.php
@@ -1903,7 +1903,7 @@
19041904 # Give extensions a chance to select the file revision for us
19051905 $time = $sha1 = $descQuery = false;
19061906 wfRunHooks( 'BeforeParserFetchFileAndTitle',
1907 - array( $this, &$nt, &$time, &$sha1, &$descQuery ) );
 1907+ array( $this, $nt, &$time, &$sha1, &$descQuery ) );
19081908 # Fetch and register the file (file title may be different via hooks)
19091909 list( $file, $nt ) = $this->fetchFileAndTitle( $nt, $time, $sha1 );
19101910 # Cloak with NOPARSE to avoid replacement in replaceExternalLinks
@@ -3336,7 +3336,7 @@
33373337 # Give extensions a chance to select the revision instead
33383338 $id = false; # Assume current
33393339 wfRunHooks( 'BeforeParserFetchTemplateAndtitle',
3340 - array( $parser, &$title, &$skip, &$id ) );
 3340+ array( $parser, $title, &$skip, &$id ) );
33413341
33423342 if ( $skip ) {
33433343 $text = false;
@@ -3423,8 +3423,8 @@
34243424 } else { // get by (name,timestamp)
34253425 $file = wfFindFile( $title, array( 'time' => $time ) );
34263426 }
3427 - $time = $file ? $file->getTimestamp() : null;
3428 - $sha1 = $file ? $file->getSha1() : null;
 3427+ $time = $file ? $file->getTimestamp() : false;
 3428+ $sha1 = $file ? $file->getSha1() : false;
34293429 # Register the file as a dependency...
34303430 $this->mOutput->addImage( $title->getDBkey(), $time, $sha1 );
34313431 if ( $file && !$title->equals( $file->getTitle() ) ) {
@@ -4685,7 +4685,7 @@
46864686 # Give extensions a chance to select the file revision for us
46874687 $time = $sha1 = $descQuery = false;
46884688 wfRunHooks( 'BeforeParserFetchFileAndTitle',
4689 - array( $this, &$title, &$time, &$sha1, &$descQuery ) );
 4689+ array( $this, $title, &$time, &$sha1, &$descQuery ) );
46904690 # Fetch and register the file (file title may be different via hooks)
46914691 list( $file, $title ) = $this->fetchFileAndTitle( $title, $time, $sha1 );
46924692
Index: trunk/phase3/includes/parser/ParserOutput.php
@@ -260,17 +260,21 @@
261261 }
262262
263263 /**
 264+ * Register a file dependency for this output
264265 * @param $name string Title dbKey
265 - * @param $timestamp string MW timestamp of file creation
266 - * @param $sha string base 36 SHA-1 of file
 266+ * @param $timestamp string MW timestamp of file creation (or false if non-existing)
 267+ * @param $sha string base 36 SHA-1 of file (or false if non-existing)
267268 * @return void
268269 */
269270 function addImage( $name, $timestamp = null, $sha1 = null ) {
270271 $this->mImages[$name] = 1;
271 - $this->mImageTimeKeys[$name] = array( 'time' => $timestamp, 'sha1' => $sha1 );
 272+ if ( $timestamp !== null && $sha1 !== null ) {
 273+ $this->mImageTimeKeys[$name] = array( 'time' => $timestamp, 'sha1' => $sha1 );
 274+ }
272275 }
273276
274277 /**
 278+ * Register a template dependency for this output
275279 * @param $title Title
276280 * @param $page_id
277281 * @param $rev_id
Index: trunk/phase3/includes/OutputPage.php
@@ -1281,6 +1281,7 @@
12821282 * Get the templates used on this page
12831283 *
12841284 * @return Array (namespace => dbKey => revId)
 1285+ * @since 1.18
12851286 */
12861287 public function getTemplateIds() {
12871288 return $this->mTemplateIds;
@@ -1290,6 +1291,7 @@
12911292 * Get the files used on this page
12921293 *
12931294 * @return Array (dbKey => array('time' => MW timestamp or null, 'sha1' => sha1 or ''))
 1295+ * @since 1.18
12941296 */
12951297 public function getImageTimeKeys() {
12961298 return $this->mImageTimeKeys;

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r84610* Put parser output file version tracking to core...aaron17:35, 23 March 2011

Status & tagging log