From: Brion Vibber Date: Mon, 26 Mar 2007 14:33:08 +0000 (+0000) Subject: * (bug 9411) Fix for shared image descriptions using query-string titles X-Git-Tag: 1.31.0-rc.0~53602 X-Git-Url: http://git.cyclocoop.org/url?a=commitdiff_plain;h=629435171a1f3bf49c7ab0050a6031869b729de1;p=lhc%2Fweb%2Fwiklou.git * (bug 9411) Fix for shared image descriptions using query-string titles Extracted URL-query-append logic from Title to wfAppendQuery(), using this in two places now. --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index dbd570438d..15ea122725 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 620704739d..6650c8972c 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -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 diff --git a/includes/ImagePage.php b/includes/ImagePage.php index 5b12ed9909..d7639d9545 100644 --- a/includes/ImagePage.php +++ b/includes/ImagePage.php @@ -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; } diff --git a/includes/Title.php b/includes/Title.php index 3493112cb8..02b5b8c606 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -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.