Remote file descriptions are now fetched using the uselang= parameter with $wgContLang.
authorChad Horohoe <demon@users.mediawiki.org>
Tue, 27 Jan 2009 19:34:21 +0000 (19:34 +0000)
committerChad Horohoe <demon@users.mediawiki.org>
Tue, 27 Jan 2009 19:34:21 +0000 (19:34 +0000)
RELEASE-NOTES
includes/filerepo/File.php
includes/filerepo/FileRepo.php
includes/filerepo/ForeignAPIFile.php

index fdf9b69..375c99d 100644 (file)
@@ -65,6 +65,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * (bug 13040) Gender switch in user preferences
 * (bug 13040) {{GENDER:}} magic word for interface messages
 * (bug 3301) Optionally sort user list according to account creation time
+* Remote description pages for foreign file repos are now fetched in the
+  content language.
 
 === Bug fixes in 1.15 ===
 * (bug 16968) Special:Upload no longer throws useless warnings.
index 4f0990a..1b0fb71 100644 (file)
@@ -1068,15 +1068,16 @@ abstract class File {
         * Get the HTML text of the description page, if available
         */
        function getDescriptionText() {
-               global $wgMemc;
+               global $wgMemc, $wgLang;
                if ( !$this->repo->fetchDescription ) {
                        return false;
                }
-               $renderUrl = $this->repo->getDescriptionRenderUrl( $this->getName() );
+               $renderUrl = $this->repo->getDescriptionRenderUrl( $this->getName(), $wgContLang->getCode() );
                if ( $renderUrl ) {
                        if ( $this->repo->descriptionCacheExpiry > 0 ) {
                                wfDebug("Attempting to get the description from cache...");
-                               $key = wfMemcKey( 'RemoteFileDescription', 'url', md5($renderUrl) );
+                               $key = wfMemcKey( 'RemoteFileDescription', 'url', $wgContLang->getCode(), 
+                                                                       $this->getName() );
                                $obj = $wgMemc->get($key);
                                if ($obj) {
                                        wfDebug("success!\n");
@@ -1086,7 +1087,9 @@ abstract class File {
                        }
                        wfDebug( "Fetching shared description from $renderUrl\n" );
                        $res = Http::get( $renderUrl );
-                       if ( $res && $this->repo->descriptionCacheExpiry > 0 ) $wgMemc->set( $key, $res, $this->repo->descriptionCacheExpiry );
+                       if ( $res && $this->repo->descriptionCacheExpiry > 0 ) {
+                               $wgMemc->set( $key, $res, $this->repo->descriptionCacheExpiry );
+                       }
                        return $res;
                } else {
                        return false;
index 5beac73..44f909f 100644 (file)
@@ -294,16 +294,22 @@ abstract class FileRepo {
         * MediaWiki this means action=render. This should only be called by the
         * repository's file class, since it may return invalid results. User code
         * should use File::getDescriptionText().
+        * @param string $name Name of image to fetch
+        * @param string $lang Language to fetch it in, if any.
         */
-       function getDescriptionRenderUrl( $name ) {
+       function getDescriptionRenderUrl( $name, $lang = null ) {
+               $query = 'action=render';
+               if ( !is_null( $lang ) ) {
+                       $query .= '&uselang=' . $lang;
+               }
                if ( isset( $this->scriptDirUrl ) ) {
                        return $this->scriptDirUrl . '/index.php?title=' .
                                wfUrlencode( 'Image:' . $name ) .
-                               '&action=render';
+                               "&$query";
                } else {
                        $descUrl = $this->getDescriptionUrl( $name );
                        if ( $descUrl ) {
-                               return wfAppendQuery( $descUrl, 'action=render' );
+                               return wfAppendQuery( $descUrl, $query );
                        } else {
                                return false;
                        }
index d9fb85d..965981f 100644 (file)
@@ -146,8 +146,8 @@ class ForeignAPIFile extends File {
        }
        
        function purgeDescriptionPage() {
-               global $wgMemc;
-               $url = $this->repo->getDescriptionRenderUrl( $this->getName() );
+               global $wgMemc, $wgContLang;
+               $url = $this->repo->getDescriptionRenderUrl( $this->getName(), $wgContLang->getCode() );
                $key = wfMemcKey( 'RemoteFileDescription', 'url', md5($url) );
                $wgMemc->delete( $key );
        }