Index: trunk/extensions/ParserFunctions/ParserFunctions_body.php |
— | — | @@ -336,7 +336,8 @@ |
337 | 337 | if ( !$file ) { |
338 | 338 | return $else; |
339 | 339 | } |
340 | | - $parser->mOutput->addImage( $file->getName() ); |
| 340 | + $parser->mOutput->addImage( |
| 341 | + $file->getName(), $file->getTimestamp(), $file->getSha1() ); |
341 | 342 | return $file->exists() ? $then : $else; |
342 | 343 | } elseif ( $title->getNamespace() == NS_SPECIAL ) { |
343 | 344 | /* Don't bother with the count for special pages, |
Index: trunk/extensions/ImageMap/ImageMap_body.php |
— | — | @@ -76,7 +76,6 @@ |
77 | 77 | $parser->replaceLinkHolders( $imageHTML ); |
78 | 78 | $imageHTML = $parser->mStripState->unstripBoth( $imageHTML ); |
79 | 79 | $imageHTML = Sanitizer::normalizeCharReferences( $imageHTML ); |
80 | | - $parser->mOutput->addImage( $imageTitle->getDBkey() ); |
81 | 80 | |
82 | 81 | $domDoc = new DOMDocument(); |
83 | 82 | wfSuppressWarnings(); |
Index: trunk/phase3/docs/hooks.txt |
— | — | @@ -563,15 +563,15 @@ |
564 | 564 | &$skin: Skin object |
565 | 565 | |
566 | 566 | '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 |
569 | 569 | &$time: the image timestamp (use '0' to force a broken thumbnail) |
570 | 570 | &$sha1: image base 36 sha1 (used to specify the file, $nt will be ignored if this is set) |
571 | 571 | &$descQuery: query string to add to thumbnail URL |
572 | 572 | |
573 | 573 | '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 |
576 | 576 | &$skip: skip this template and link it? |
577 | 577 | &$id: the id of the revision being parsed |
578 | 578 | |
Index: trunk/phase3/includes/ImageGallery.php |
— | — | @@ -242,7 +242,7 @@ |
243 | 243 | # Give extensions a chance to select the file revision for us |
244 | 244 | $time = $sha1 = false; |
245 | 245 | wfRunHooks( 'BeforeParserFetchFileAndTitle', |
246 | | - array( $this->mParser, &$nt, &$time, &$sha1, &$descQuery ) ); |
| 246 | + array( $this->mParser, $nt, &$time, &$sha1, &$descQuery ) ); |
247 | 247 | # Fetch and register the file (file title may be different via hooks) |
248 | 248 | list( $img, $nt ) = $this->mParser->fetchFileAndTitle( $nt, $time, $sha1 ); |
249 | 249 | } else { |
Index: trunk/phase3/includes/parser/Parser.php |
— | — | @@ -1903,7 +1903,7 @@ |
1904 | 1904 | # Give extensions a chance to select the file revision for us |
1905 | 1905 | $time = $sha1 = $descQuery = false; |
1906 | 1906 | wfRunHooks( 'BeforeParserFetchFileAndTitle', |
1907 | | - array( $this, &$nt, &$time, &$sha1, &$descQuery ) ); |
| 1907 | + array( $this, $nt, &$time, &$sha1, &$descQuery ) ); |
1908 | 1908 | # Fetch and register the file (file title may be different via hooks) |
1909 | 1909 | list( $file, $nt ) = $this->fetchFileAndTitle( $nt, $time, $sha1 ); |
1910 | 1910 | # Cloak with NOPARSE to avoid replacement in replaceExternalLinks |
— | — | @@ -3336,7 +3336,7 @@ |
3337 | 3337 | # Give extensions a chance to select the revision instead |
3338 | 3338 | $id = false; # Assume current |
3339 | 3339 | wfRunHooks( 'BeforeParserFetchTemplateAndtitle', |
3340 | | - array( $parser, &$title, &$skip, &$id ) ); |
| 3340 | + array( $parser, $title, &$skip, &$id ) ); |
3341 | 3341 | |
3342 | 3342 | if ( $skip ) { |
3343 | 3343 | $text = false; |
— | — | @@ -3423,8 +3423,8 @@ |
3424 | 3424 | } else { // get by (name,timestamp) |
3425 | 3425 | $file = wfFindFile( $title, array( 'time' => $time ) ); |
3426 | 3426 | } |
3427 | | - $time = $file ? $file->getTimestamp() : null; |
3428 | | - $sha1 = $file ? $file->getSha1() : null; |
| 3427 | + $time = $file ? $file->getTimestamp() : false; |
| 3428 | + $sha1 = $file ? $file->getSha1() : false; |
3429 | 3429 | # Register the file as a dependency... |
3430 | 3430 | $this->mOutput->addImage( $title->getDBkey(), $time, $sha1 ); |
3431 | 3431 | if ( $file && !$title->equals( $file->getTitle() ) ) { |
— | — | @@ -4685,7 +4685,7 @@ |
4686 | 4686 | # Give extensions a chance to select the file revision for us |
4687 | 4687 | $time = $sha1 = $descQuery = false; |
4688 | 4688 | wfRunHooks( 'BeforeParserFetchFileAndTitle', |
4689 | | - array( $this, &$title, &$time, &$sha1, &$descQuery ) ); |
| 4689 | + array( $this, $title, &$time, &$sha1, &$descQuery ) ); |
4690 | 4690 | # Fetch and register the file (file title may be different via hooks) |
4691 | 4691 | list( $file, $title ) = $this->fetchFileAndTitle( $title, $time, $sha1 ); |
4692 | 4692 | |
Index: trunk/phase3/includes/parser/ParserOutput.php |
— | — | @@ -260,17 +260,21 @@ |
261 | 261 | } |
262 | 262 | |
263 | 263 | /** |
| 264 | + * Register a file dependency for this output |
264 | 265 | * @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) |
267 | 268 | * @return void |
268 | 269 | */ |
269 | 270 | function addImage( $name, $timestamp = null, $sha1 = null ) { |
270 | 271 | $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 | + } |
272 | 275 | } |
273 | 276 | |
274 | 277 | /** |
| 278 | + * Register a template dependency for this output |
275 | 279 | * @param $title Title |
276 | 280 | * @param $page_id |
277 | 281 | * @param $rev_id |
Index: trunk/phase3/includes/OutputPage.php |
— | — | @@ -1281,6 +1281,7 @@ |
1282 | 1282 | * Get the templates used on this page |
1283 | 1283 | * |
1284 | 1284 | * @return Array (namespace => dbKey => revId) |
| 1285 | + * @since 1.18 |
1285 | 1286 | */ |
1286 | 1287 | public function getTemplateIds() { |
1287 | 1288 | return $this->mTemplateIds; |
— | — | @@ -1290,6 +1291,7 @@ |
1291 | 1292 | * Get the files used on this page |
1292 | 1293 | * |
1293 | 1294 | * @return Array (dbKey => array('time' => MW timestamp or null, 'sha1' => sha1 or '')) |
| 1295 | + * @since 1.18 |
1294 | 1296 | */ |
1295 | 1297 | public function getImageTimeKeys() { |
1296 | 1298 | return $this->mImageTimeKeys; |