Follow-up changes to r84610:
authorAaron Schulz <aaron@users.mediawiki.org>
Mon, 4 Apr 2011 01:22:08 +0000 (01:22 +0000)
committerAaron Schulz <aaron@users.mediawiki.org>
Mon, 4 Apr 2011 01:22:08 +0000 (01:22 +0000)
* 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

docs/hooks.txt
includes/ImageGallery.php
includes/OutputPage.php
includes/parser/Parser.php
includes/parser/ParserOutput.php

index 3ab877f..15c89ad 100644 (file)
@@ -563,15 +563,15 @@ $mediaWiki: Mediawiki object
 &$skin: Skin object
 
 'BeforeParserFetchFileAndTitle': before an image is rendered by Parser
-&$parser: Parser object
-&$nt: the image title
+$parser: Parser object
+$nt: the image title
 &$time: the image timestamp (use '0' to force a broken thumbnail)
 &$sha1: image base 36 sha1 (used to specify the file, $nt will be ignored if this is set)
 &$descQuery: query string to add to thumbnail URL
 
 'BeforeParserFetchTemplateAndtitle': before a template is fetched by Parser
-&$parser: Parser object
-&$title: title of the template
+$parser: Parser object
+$title: title of the template
 &$skip: skip this template and link it?
 &$id: the id of the revision being parsed
 
index 925ba24..f490a38 100644 (file)
@@ -242,7 +242,7 @@ class ImageGallery
                                        # Give extensions a chance to select the file revision for us
                                        $time = $sha1 = false;
                                        wfRunHooks( 'BeforeParserFetchFileAndTitle',
-                                               array( $this->mParser, &$nt, &$time, &$sha1, &$descQuery ) );
+                                               array( $this->mParser, $nt, &$time, &$sha1, &$descQuery ) );
                                        # Fetch and register the file (file title may be different via hooks)
                                        list( $img, $nt ) = $this->mParser->fetchFileAndTitle( $nt, $time, $sha1 );
                                } else {
index 03fc907..4fb8c5f 100644 (file)
@@ -1281,6 +1281,7 @@ class OutputPage {
         * Get the templates used on this page
         *
         * @return Array (namespace => dbKey => revId)
+        * @since 1.18
         */
        public function getTemplateIds() {
                return $this->mTemplateIds;
@@ -1290,6 +1291,7 @@ class OutputPage {
         * Get the files used on this page
         *
         * @return Array (dbKey => array('time' => MW timestamp or null, 'sha1' => sha1 or ''))
+        * @since 1.18
         */
        public function getImageTimeKeys() {
                return $this->mImageTimeKeys;
index 6200e1b..30675b4 100644 (file)
@@ -1903,7 +1903,7 @@ class Parser {
                                # Give extensions a chance to select the file revision for us
                                $time = $sha1 = $descQuery = false;
                                wfRunHooks( 'BeforeParserFetchFileAndTitle',
-                                       array( $this, &$nt, &$time, &$sha1, &$descQuery ) );
+                                       array( $this, $nt, &$time, &$sha1, &$descQuery ) );
                                # Fetch and register the file (file title may be different via hooks)
                                list( $file, $nt ) = $this->fetchFileAndTitle( $nt, $time, $sha1 );
                                # Cloak with NOPARSE to avoid replacement in replaceExternalLinks
@@ -3336,7 +3336,7 @@ class Parser {
                        # Give extensions a chance to select the revision instead
                        $id = false; # Assume current
                        wfRunHooks( 'BeforeParserFetchTemplateAndtitle',
-                               array( $parser, &$title, &$skip, &$id ) );
+                               array( $parser, $title, &$skip, &$id ) );
 
                        if ( $skip ) {
                                $text = false;
@@ -3423,8 +3423,8 @@ class Parser {
                } else { // get by (name,timestamp)
                        $file = wfFindFile( $title, array( 'time' => $time ) );
                }
-               $time = $file ? $file->getTimestamp() : null;
-               $sha1 = $file ? $file->getSha1() : null;
+               $time = $file ? $file->getTimestamp() : false;
+               $sha1 = $file ? $file->getSha1() : false;
                # Register the file as a dependency...
                $this->mOutput->addImage( $title->getDBkey(), $time, $sha1 );
                if ( $file && !$title->equals( $file->getTitle() ) ) {
@@ -4685,7 +4685,7 @@ class Parser {
                # Give extensions a chance to select the file revision for us
                $time = $sha1 = $descQuery = false;
                wfRunHooks( 'BeforeParserFetchFileAndTitle',
-                       array( $this, &$title, &$time, &$sha1, &$descQuery ) );
+                       array( $this, $title, &$time, &$sha1, &$descQuery ) );
                # Fetch and register the file (file title may be different via hooks)
                list( $file, $title ) = $this->fetchFileAndTitle( $title, $time, $sha1 );
 
index a0224ac..21bbe47 100644 (file)
@@ -260,17 +260,21 @@ class ParserOutput extends CacheTime {
        }
 
        /**
+        * Register a file dependency for this output
         * @param $name string Title dbKey
-        * @param $timestamp string MW timestamp of file creation
-        * @param $sha string base 36 SHA-1 of file
+        * @param $timestamp string MW timestamp of file creation (or false if non-existing)
+        * @param $sha string base 36 SHA-1 of file (or false if non-existing)
         * @return void
         */
        function addImage( $name, $timestamp = null, $sha1 = null ) {
                $this->mImages[$name] = 1;
-               $this->mImageTimeKeys[$name] = array( 'time' => $timestamp, 'sha1' => $sha1 );
+               if ( $timestamp !== null && $sha1 !== null ) {
+                       $this->mImageTimeKeys[$name] = array( 'time' => $timestamp, 'sha1' => $sha1 );
+               }
        }
 
        /**
+        * Register a template dependency for this output
         * @param $title Title
         * @param $page_id
         * @param $rev_id