* (bug 9411) Fix for shared image descriptions using query-string titles
authorBrion Vibber <brion@users.mediawiki.org>
Mon, 26 Mar 2007 14:33:08 +0000 (14:33 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Mon, 26 Mar 2007 14:33:08 +0000 (14:33 +0000)
Extracted URL-query-append logic from Title to wfAppendQuery(), using this in two places now.

RELEASE-NOTES
includes/GlobalFunctions.php
includes/ImagePage.php
includes/Title.php

index dbd5704..15ea122 100644 (file)
@@ -283,6 +283,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * Introduce PageHistoryBeforeList and PageHistoryLineEnding hooks; see docs/hooks.txt
   for more information
 * (bug 9299) Allow user timezones to work with Postgres
+* (bug 9411) Fix for shared image descriptions using query-string titles
+
 
 == Maintenance ==
 * New script maintenance/language/checkExtensioni18n.php used to check i18n
index 6207047..6650c89 100644 (file)
@@ -983,6 +983,26 @@ function wfArrayToCGI( $array1, $array2 = NULL )
        return $cgi;
 }
 
+/**
+ * Append a query string to an existing URL, which may or may not already
+ * have query string parameters already. If so, they will be combined.
+ *
+ * @param string $url
+ * @param string $query
+ * @return string
+ */
+function wfAppendQuery( $url, $query ) {
+       if( $query != '' ) {
+               if( false === strpos( $url, '?' ) ) {
+                       $url .= '?';
+               } else {
+                       $url .= '&';
+               }
+               $url .= $query;
+       }
+       return $url;
+}
+
 /**
  * This is obsolete, use SquidUpdate::purge()
  * @deprecated
index 5b12ed9..d7639d9 100644 (file)
@@ -385,7 +385,9 @@ END
                $wgOut->addHTML($sharedtext);
 
                if ($wgRepositoryBaseUrl && $wgFetchCommonsDescriptions) {
-                       $text = Http::get($url . '?action=render');
+                       $renderUrl = wfAppendQuery( $url, 'action=render' );
+                       wfDebug( "Fetching shared description from $renderUrl\n" );
+                       $text = Http::get( $renderUrl );
                        if ($text)
                                $this->mExtraDescription = $text;
                }
index 3493112..02b5b8c 100644 (file)
@@ -835,14 +835,7 @@ class Title {
                                $namespace .= ':';
                        }
                        $url = str_replace( '$1', $namespace . $this->mUrlform, $baseUrl );
-                       if( $query != '' ) {
-                               if( false === strpos( $url, '?' ) ) {
-                                       $url .= '?';
-                               } else {
-                                       $url .= '&';
-                               }
-                               $url .= $query;
-                       }
+                       $url = wfAppendQuery( $url, $query );
                }
 
                # Finally, add the fragment.