From: Daniel Friesen Date: Fri, 12 Aug 2011 19:55:03 +0000 (+0000) Subject: Touch up Title::get[Full|Local]URL. This concept of "if not an existing interwiki... X-Git-Tag: 1.31.0-rc.0~28306 X-Git-Url: http://git.cyclocoop.org/%22%20.%20%20%20%24self2%20.%20%20%20%22&var_mode_affiche=boucle?a=commitdiff_plain;h=17289de2dbce04cb89b9635f4f582cc9291bf350;p=lhc%2Fweb%2Fwiklou.git Touch up Title::get[Full|Local]URL. This concept of "if not an existing interwiki getFullURL calls getLocalURL" and "if external (interwiki) getLocalURL calls getFullURL" is ridiculous. In fact if mInterwiki just happens to not be '' and not exist, you create infinite recursion and php dies. Instead of having getFullURL and getLocalURL call each other, move the interwiki workload into getLocalURL, and make getFullURL simply call getLocalURL then expand it (use the wf method in case it's already a full url) and append the fragment to it. --- diff --git a/includes/Title.php b/includes/Title.php index 65dd8b6a96..ba86d60841 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -837,30 +837,14 @@ class Title { public function getFullURL( $query = '', $variant = false ) { global $wgServer, $wgRequest; - if ( is_array( $query ) ) { - $query = wfArrayToCGI( $query ); - } - - $interwiki = Interwiki::fetch( $this->mInterwiki ); - if ( !$interwiki ) { - $url = $this->getLocalURL( $query, $variant ); - - // Ugly quick hack to avoid duplicate prefixes (bug 4571 etc) - // Correct fix would be to move the prepending elsewhere. - if ( $wgRequest->getVal( 'action' ) != 'render' ) { - $url = $wgServer . $url; - } - } else { - $namespace = $this->getNsText(); - if ( $namespace != '' ) { - # Can this actually happen? Interwikis shouldn't be parsed. - # Yes! It can in interwiki transclusion. But... it probably shouldn't. - $namespace .= ':'; - } - $url = $interwiki->getURL( $namespace . $this->getDBkey() ); - $url = wfAppendQuery( $url, $query ); - } - + # Hand off all the decisions on urls to getLocalURL + $url = $this->getLocalURL( $query, $variant ); + + # Expand the url to make it a full url. Note that getLocalURL has the + # potential to output full urls for a variety of reasons, so we use + # wfExpandUrl instead of simply prepending $wgServer + $url = wfExpandUrl( $url ); + # Finally, add the fragment. $url .= $this->getFragmentForURL(); @@ -887,15 +871,16 @@ class Title { $query = wfArrayToCGI( $query ); } - if ( $this->isExternal() ) { - $url = $this->getFullURL(); - if ( $query ) { - // This is currently only used for edit section links in the - // context of interwiki transclusion. In theory we should - // append the query to the end of any existing query string, - // but interwiki transclusion is already broken in that case. - $url .= "?$query"; + $interwiki = Interwiki::fetch( $this->mInterwiki ); + if ( $interwiki ) { + $namespace = $this->getNsText(); + if ( $namespace != '' ) { + # Can this actually happen? Interwikis shouldn't be parsed. + # Yes! It can in interwiki transclusion. But... it probably shouldn't. + $namespace .= ':'; } + $url = $interwiki->getURL( $namespace . $this->getDBkey() ); + $url = wfAppendQuery( $url, $query ); } else { $dbkey = wfUrlencode( $this->getPrefixedDBkey() ); if ( $query == '' ) {