Repair getDescriptionUrl() and getDescriptionText() Follow up to r69907 and r69908
authorDerk-Jan Hartman <hartman@users.mediawiki.org>
Sun, 1 Aug 2010 22:07:52 +0000 (22:07 +0000)
committerDerk-Jan Hartman <hartman@users.mediawiki.org>
Sun, 1 Aug 2010 22:07:52 +0000 (22:07 +0000)
All this functionality is now moved to File.php. for getDescriptionUrl there was no
real need to subclass this method, for getDescriptionText() there was, but
duplicating the code or changing the inheritence model of LocalFile and ForeignDBFile
seems too much work if an isLocal in File.php suffices.

includes/filerepo/File.php
includes/filerepo/ForeignDBFile.php
includes/filerepo/LocalFile.php

index 1469668..a9c6437 100644 (file)
@@ -1078,8 +1078,19 @@ abstract class File {
 
        /**
         * Get the HTML text of the description page, if available
+        * For local files ImagePage does not use it, because it skips the parser cache.
         */
        function getDescriptionText() {
+               if( $this->isLocal() ) {
+                       global $wgParser;
+                       $revision = Revision::newFromTitle( $this->title );
+                       if ( !$revision ) return false;
+                       $text = $revision->getText();
+                       if ( !$text ) return false;
+                       $pout = $wgParser->parse( $text, $this->title, new ParserOptions() );
+                       return $pout->getText();
+               }
+
                global $wgMemc, $wgLang;
                if ( !$this->repo->fetchDescription ) {
                        return false;
index bec288f..83c12f9 100644 (file)
@@ -36,14 +36,4 @@ class ForeignDBFile extends LocalFile {
        function move( $target ) {
                $this->readOnlyError();
        }
-       
-       function getDescriptionUrl() {
-               // Restore remote behaviour
-               return parent::getDescriptionUrl();
-       }
-
-       function getDescriptionText() {
-               // Restore remote behaviour
-               return parent::getDescriptionText();
-       }
 }
index b35ba0b..3dd294c 100644 (file)
@@ -1121,27 +1121,8 @@ class LocalFile extends File {
        /** scaleHeight inherited */
        /** getImageSize inherited */
 
-       /**
-        * Get the URL of the file description page.
-        */
-       function getDescriptionUrl() {
-               return $this->title->getLocalUrl();
-       }
-
-       /**
-        * Get the HTML text of the description page
-        * This is not used by ImagePage for local files, since (among other things)
-        * it skips the parser cache.
-        */
-       function getDescriptionText() {
-               global $wgParser;
-               $revision = Revision::newFromTitle( $this->title );
-               if ( !$revision ) return false;
-               $text = $revision->getText();
-               if ( !$text ) return false;
-               $pout = $wgParser->parse( $text, $this->title, new ParserOptions() );
-               return $pout->getText();
-       }
+       /** getDescriptionUrl inherited */
+       /** getDescriptionText inherited */
 
        function getDescription() {
                $this->load();