Replace the random boolean parameters on Title::getURL() with a set of
authorBrion Vibber <brion@users.mediawiki.org>
Sun, 7 Mar 2004 07:26:56 +0000 (07:26 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Sun, 7 Mar 2004 07:26:56 +0000 (07:26 +0000)
practical, clear methods:
  Title::getLocalURL() - "/wiki/index.php/Foobar" or "/wiki/index.php?title=Foobar&action=edit"
  Title::getFullUrl() - ditto with $wgServer on the front
  Title::getInternalUrl() - ditto with $wgInternalServer on the front (for some squid-related functions)
  Title::escapeLocalUrl() - local URL escaped for HTML output
  Title::escapeFullUrl() - full URL escaped for HTML output

All take an optional query parameter.

Title::getURL(), wfFullUrl() and wfFullUrlE() are now officially
deprecated and will result in instant death. wfLocalUrl() and wfLocalUrlE()
will be killed shortly; they are still used in the language files.

28 files changed:
includes/Article.php
includes/EditPage.php
includes/GlobalFunctions.php
includes/OutputPage.php
includes/PageHistory.php
includes/Parser.php
includes/QueryPage.php
includes/SearchEngine.php
includes/Skin.php
includes/SkinCologneBlue.php
includes/SkinSmarty.php
includes/SpecialAsksql.php
includes/SpecialBlockip.php
includes/SpecialEmailuser.php
includes/SpecialExport.php
includes/SpecialImagelist.php
includes/SpecialIpblocklist.php
includes/SpecialLockdb.php
includes/SpecialMakesysop.php
includes/SpecialMovepage.php
includes/SpecialPreferences.php
includes/SpecialUndelete.php
includes/SpecialUnlockdb.php
includes/SpecialUpload.php
includes/SpecialUserlogin.php
includes/SpecialWatchlist.php
includes/SquidUpdate.php
includes/Title.php

index 778d3aa..d4bb052 100644 (file)
@@ -154,7 +154,7 @@ class Article {
                                                        return;
                                                }
                                                if ( $rt->getNamespace() == Namespace::getSpecial() ) {
-                                                       $wgOut->redirect( $rt->getURL() );
+                                                       $wgOut->redirect( $rt->getFullURL() );
                                                        return;
                                                }
                                                $rid = $rt->getArticleID();
@@ -430,7 +430,7 @@ class Article {
                # Squid purging
                if ( $wgUseSquid ) {
                        $urlArr = Array( 
-                               $wgInternalServer.$this->mTitle->getURL()
+                               $this->mTitle->getInternalURL()
                        );                      
                        wfPurgeSquidServers($urlArr);
                        /* this needs to be done after LinksUpdate */
@@ -546,7 +546,7 @@ class Article {
                
                if ( $wgUseSquid ) {
                        $urlArr = Array( 
-                               $wgInternalServer.$this->mTitle->getURL()
+                               $this->mTitle->getInternalURL()
                        );                      
                        wfPurgeSquidServers($urlArr);
                }
@@ -577,7 +577,7 @@ class Article {
                        $r = "redirect=no";
                else
                        $r = "";
-               $wgOut->redirect( $this->mTitle->getURL( $r ) );
+               $wgOut->redirect( $this->mTitle->getFullURL( $r ) );
        }
 
        # Add this page to my watchlist
@@ -650,7 +650,7 @@ class Article {
                } else {
                        $log->addEntry( wfMsg( "protectedarticle", $this->mTitle->getPrefixedText() ), "" );
                }
-               $wgOut->redirect( $this->mTitle->getURL() );
+               $wgOut->redirect( $this->mTitle->getFullURL() );
        }
 
        function unprotect()
@@ -766,7 +766,7 @@ class Article {
                $wgOut->setRobotpolicy( "noindex,nofollow" );
                $wgOut->addWikiText( wfMsg( "confirmdeletetext" ) );
 
-               $formaction = $this->mTitle->getURL( $this->mTitle, "action=delete" . $par, true );
+               $formaction = $this->mTitle->escapeLocalURL( "action=delete" . $par );
                
                $confirm = wfMsg( "confirm" );
                $check = wfMsg( "confirmcheck" );
@@ -835,7 +835,7 @@ class Article {
                # Squid purging
                if ( $wgUseSquid ) {
                        $urlArr = Array(
-                               $wgInternalServer.$this->mTitle->getURL()
+                               $this->mTitle->getInternalURL()
                        );
                        wfPurgeSquidServers($urlArr);
 
@@ -845,7 +845,7 @@ class Article {
                        while ( $BL = wfFetchObject ( $res ) )
                        {
                                $tobj = Title::newFromDBkey( $BL->l_from) ; 
-                               $blurlArr[] = $wgInternalServer.$tobj->getURL();
+                               $blurlArr[] = $tobj->getInternalURL();
                        }
                        wfFreeResult ( $res ) ;
                        $u = new SquidUpdate( $this->mTitle, $blurlArr );
index bc59468..6f06d0e 100644 (file)
@@ -129,7 +129,7 @@ class EditPage {
                                # append them and the string comparison fails
                                if ( ( "" == $wpTextbox1 ) ||
                                  ( wfMsg( "newarticletext" ) == rtrim( preg_replace("/\r/","",$wpTextbox1) ) ) ) {
-                                       $wgOut->redirect( $this->mTitle->getURL() );
+                                       $wgOut->redirect( $this->mTitle->getFullURL() );
                                        return;
                                }
                                $this->mArticle->insertNewArticle( $wpTextbox1, $wpSummary, $wpMinoredit, $wpWatchthis );
@@ -227,7 +227,7 @@ class EditPage {
 
                $q = "action=submit";
                if ( "no" == $redirect ) { $q .= "&redirect=no"; }
-               $action = $this->mTitle->getURL( $q, true );
+               $action = $this->mTitle->escapeLocalURL( $q );
 
                $summary = wfMsg( "summary" );
                $subject = wfMsg("subject");
index 8e69807..8322905 100644 (file)
@@ -50,7 +50,7 @@ function wfSeedRandom()
 }
 
 # Generates a URL from a URL-encoded title and a query string
-# Title::getURL() is preferred in most cases
+# Title::getLocalURL() is preferred in most cases
 #
 function wfLocalUrl( $a, $q = "" )
 {
@@ -77,16 +77,15 @@ function wfLocalUrl( $a, $q = "" )
 function wfLocalUrlE( $a, $q = "" )
 {
        return wfEscapeHTML( wfLocalUrl( $a, $q ) );
+       # die( "Call to obsolete function wfLocalUrlE()" );
 }
 
 function wfFullUrl( $a, $q = "" ) {
-       $titleObj = Title::newFromURL( $a );
-       return $titleObj->getURL( $q, false, true );
+       die( "Call to obsolete function wfFullUrl()" );
 }
 
 function wfFullUrlE( $a, $q = "" ) {
-       $titleObj = Title::newFromURL( $a );
-       return $titleObj->getURL( $q, true, true );
+       die( "Call to obsolete function wfFullUrlE()" );
 
 }
 
index c6cc144..7288b24 100644 (file)
@@ -534,7 +534,7 @@ class OutputPage {
                $r = wfMsg( "returnto", $link );
                if ( $auto ) {
                        $titleObj = Title::newFromText( $returnto );
-                       $wgOut->addMeta( "http:Refresh", "10;url=" . $titleObj->getUrl( "", true, true ));
+                       $wgOut->addMeta( "http:Refresh", "10;url=" . $titleObj->escapeFullURL() );
                }
                $wgOut->addHTML( "\n<p>$r\n" );
        }
index bfae24e..3e1ff45 100644 (file)
@@ -106,7 +106,7 @@ class PageHistory {
                global $wgTitle;
                $this->lastdate = $this->lastline = "";
                $s = "\n<p>" . wfMsg( "histlegend" ) . "\n<ul>";
-               $url = $wgTitle->getURL("-");
+               $url = $wgTitle->getLocalURL("-");
                $s .= "<SCRIPT>
                        var sel = -1;
                        function anysel(oid){ 
index 4dbc77f..8d4db95 100644 (file)
@@ -1352,7 +1352,7 @@ class Parser
                        } else {
                                $titleObj = Title::makeTitle( NS_SPECIAL, "Booksources" );
                                $text .= "<a href=\"" .
-                               $titleObj->getUrl( "isbn={$num}", false, true ) .
+                               $titleObj->escapeLocalUrl( "isbn={$num}" ) .
                                        "\" class=\"internal\">ISBN $isbn</a>";
                                $text .= $x;
                        }
index a6ff1ba..b7a19ff 100644 (file)
@@ -140,7 +140,7 @@ class QueryPage {
                        return new FeedItem(
                                $title->getText(),
                                $this->feedItemDesc( $row ),
-                               $title->getURL( "", false, true ) ,
+                               $title->getFullURL(),
                                $date);
                } else {
                        return NULL;
index ee38899..802e6c1 100644 (file)
@@ -130,10 +130,9 @@ class SearchEngine {
                  wfMsg("powersearch") . "\">\n";
                $ret = str_replace( "$9", $tempText, $ret );
 
-               $titleObj = NULL; # this does tricky stuff
-               
+               global $wgScript;
                $ret = "<br><br>\n<form id=\"powersearch\" method=\"get\" " .
-                 "action=\"" . $titleObj->getUrl() . "\">\n{$ret}\n</form>\n";
+                 "action=\"$wgScript\">\n{$ret}\n</form>\n";
 
                if ( isset ( $searchx ) ) {
                        if ( ! $listredirs ) { 
@@ -435,7 +434,7 @@ class SearchEngine {
                }
 
                if ( 0 != $t->getArticleID() ) {
-                       $wgOut->redirect( $t->getURL() );
+                       $wgOut->redirect( $t->getFullURL() );
                        return;
                }
 
@@ -443,7 +442,7 @@ class SearchEngine {
                #
                $t = Title::newFromText( strtolower( $search ) );
                if ( 0 != $t->getArticleID() ) {
-                       $wgOut->redirect( $t->getURL() );
+                       $wgOut->redirect( $t->getFullURL() );
                        return;
                }
 
@@ -451,7 +450,7 @@ class SearchEngine {
                #
                $t = Title::newFromText( ucwords( strtolower( $search ) ) );
                if ( 0 != $t->getArticleID() ) {
-                       $wgOut->redirect( $t->getURL() );
+                       $wgOut->redirect( $t->getFullURL() );
                        return;
                }
 
@@ -459,13 +458,13 @@ class SearchEngine {
                #
                $t = Title::newFromText( strtoupper( $search ) );
                if ( 0 != $t->getArticleID() ) {
-                       $wgOut->redirect( $t->getURL() );
+                       $wgOut->redirect( $t->getFullURL() );
                        return;
                }
 
                # No match, generate an edit URL
                $t = Title::newFromText( $this->mUsertext );
-               $wgOut->addHTML( wfMsg("nogomatch", $t->getURL( "action=edit", true ) ) . "\n<p>" );
+               $wgOut->addHTML( wfMsg("nogomatch", $t->escapeLocalURL( "action=edit" ) ) . "\n<p>" );
 
                # Try a fuzzy title search
                $anyhit = false;
index bbdeaad..306e812 100644 (file)
@@ -181,7 +181,7 @@ class Skin {
                        if ( $oldid && ! isset( $diff ) ) {
                                $oid = "&oldid={$oldid}";
                        }
-                       $s = $wgTitle->getUrl( "action=edit{$oid}{$red}", false, true );
+                       $s = $wgTitle->getFullURL( "action=edit{$oid}{$red}" );
                        $s = "document.location = \"" .$s ."\";";
                        $a += array ("ondblclick" => $s);
 
@@ -692,7 +692,7 @@ class Skin {
                
                $mp = wfMsg( "mainpage" );
                $titleObj = Title::newFromText( $mp );
-               $s = "<a href=\"" . $titleObj->getURL( "", true )
+               $s = "<a href=\"" . $titleObj->escapeLocalURL()
                  . "\"><img{$a} border=0 src=\""
                  . $this->getLogo() . "\" alt=\"" . "[{$mp}]\"></a>";
                return $s;
@@ -1332,7 +1332,7 @@ class Skin {
                        $u = "";
                        if ( "" == $text ) { $text = $nt->getFragment(); }
                } else {
-                       $u = $nt->getURL( $query, true );
+                       $u = $nt->escapeLocalURL( $query );
                }
                if ( "" != $nt->getFragment() ) {
                        $u .= "#" . wfEscapeHTML( $nt->getFragment() );
@@ -1360,11 +1360,12 @@ class Skin {
                $fname = "Skin::makeBrokenLinkObj";
                wfProfileIn( $fname );
 
-               $link = $nt->getPrefixedURL();
-
-               if ( "" == $query ) { $q = "action=edit"; }
-               else { $q = "action=edit&{$query}"; }
-               $u = $nt->getURL( $q );
+               if ( "" == $query ) {
+                       $q = "action=edit";
+               } else {
+                       $q = "action=edit&{$query}";
+               }
+               $u = $nt->escapeLocalURL( $q );
 
                if ( "" == $text ) { $text = $nt->getPrefixedText(); }
                $style = $this->getInternalLinkAttributesObj( $nt, $text, "yes" );
@@ -1394,7 +1395,7 @@ class Skin {
 
                $link = $nt->getPrefixedURL();
 
-               $u = $nt->getURL( $query, true );
+               $u = $nt->escapeLocalURL( $query );
 
                if ( "" == $text ) { $text = $nt->getPrefixedText(); }
                $style = $this->getInternalLinkAttributesObj( $nt, $text, "stub" );
@@ -1522,7 +1523,7 @@ class Skin {
                }
                $alt = htmlspecialchars( $alt );
 
-               $u = $nt->getURL( "", true );
+               $u = $nt->escapeLocalURL();
                $s = "<a href=\"{$u}\" class='image' title=\"{$alt}\">" .
                  "<img border=\"0\" src=\"{$url}\" alt=\"{$alt}\"></a>";
                if ( "" != $align ) {
@@ -1647,7 +1648,7 @@ class Skin {
                
                $thumbUrl = $this->createThumb( $name, $boxwidth );
 
-               $u = $nt->getURL( "", true );
+               $u = $nt->escapeLocalURL();
 
                $more = htmlspecialchars(wfMsg( "thumbnail-more" ));
                
@@ -2148,8 +2149,8 @@ class Skin {
                        $url = wfImageUrl( $img );
                        $rlink = $cur;
                        if ( $wgUser->isSysop() ) {
-                               $link = $wgTitle->getURL( "image=" . $wgTitle->getPartialURL() . 
-                                 "&action=delete", true );
+                               $link = $wgTitle->escapeLocalURL( "image=" . $wgTitle->getPartialURL() . 
+                                 "&action=delete" );
                                $style = $this->getInternalLinkAttributes( $link, $del );
 
                                $dlink = "<a href=\"{$link}\"{$style}>{$del}</a>";
@@ -2237,7 +2238,7 @@ class Skin {
 
                global $wgTitle,$wgUser,$oldid;
                if($oldid) return $head;
-               $url = $wgTitle->getUrl( "action=edit&section=$section", true );
+               $url = $wgTitle->escapeLocalURL( "action=edit&section=$section" );
                return "<span onContextMenu='document.location=\"".$url."\";return false;'>{$head}</span>";
        }
 
index 409f503..6343dd9 100644 (file)
@@ -25,7 +25,7 @@ class SkinCologneBlue extends Skin {
                  "<table width='100%' border=0 cellspacing=0 cellpadding=8><tr>";
 
                $s .= "<td class='top' align=left valign=middle nowrap>";
-               $s .= "<a href=\"" . $mainPageObj->getURL("", true) . "\">";
+               $s .= "<a href=\"" . $mainPageObj->escapeLocalURL() . "\">";
                $s .= "<span id='sitetitle'>" . wfMsg( "sitetitle" ) . "</span></a>";
 
                $s .= "</td><td class='top' align=right valign=bottom width='100%'>";
index c224224..d71a947 100644 (file)
@@ -95,7 +95,7 @@ class SkinSmarty extends Skin {
                        $text = $popup = $title->getPrefixedText();
                }
                
-               $url = $title->getURL( $action, true );
+               $url = $title->escapeLocalURL( $action );
                
                if($params['text']) $text = $params['text'];
                if($params['key']) $text = wfMsg( $params['key'] );
index 7122106..528c0cb 100644 (file)
@@ -37,7 +37,7 @@ class SqlQueryForm {
                $q = wfMsg( "sqlquery" );
                $qb = wfMsg( "querybtn" );
                $titleObj = Title::makeTitle( NS_SPECIAL, "Asksql" );
-               $action = $titleObj->getURL( "action=submit", true );
+               $action = $titleObj->escapeLocalURL( "action=submit" );
 
                $wgOut->addHTML( "<p>
 <form id=\"asksql\" method=\"post\" action=\"{$action}\">
index 52698a2..56deeee 100644 (file)
@@ -40,7 +40,7 @@ class IPBlockForm {
                $mIpbreason = wfMsg( "ipbreason" );
                $mIpbsubmit = wfMsg( "ipbsubmit" );
                $titleObj = Title::makeTitle( NS_SPECIAL, "Blockip" );
-               $action = $titleObj->getURL( "action=submit", true );
+               $action = $titleObj->escapeLocalURL( "action=submit" );
 
                if ( "" != $err ) {
                        $wgOut->setSubtitle( wfMsg( "formerror" ) );
@@ -146,7 +146,7 @@ class IPBlockForm {
 
                # Report to the user
                $titleObj = Title::makeTitle( NS_SPECIAL, "Blockip" );
-               $wgOut->redirect( $titleObj->getURL( "action=success&ip={$wpBlockAddress}" ) );
+               $wgOut->redirect( $titleObj->getFullURL( "action=success&ip={$wpBlockAddress}" ) );
        }
 
        function showSuccess()
index b8e11b2..fe854b2 100644 (file)
@@ -70,7 +70,7 @@ class EmailUserForm {
                $ems = wfMsg( "emailsend" );
 
                $titleObj = Title::makeTitle( NS_SPECIAL, "Emailuser" );
-               $action = $titleObj->getURL( "target={$target}&action=submit", true );
+               $action = $titleObj->escapeLocalURL( "target={$target}&action=submit" );
 
                if ( "" != $err ) {
                        $wgOut->setSubtitle( wfMsg( "formerror" ) );
@@ -115,7 +115,7 @@ class EmailUserForm {
                if (! $mailResult)
                {
                        $titleObj = Title::makeTitle( NS_SPECIAL, "Emailuser" );
-                       $wgOut->redirect( $titleObj->getURL( "target={$target}&action=success" ) );
+                       $wgOut->redirect( $titleObj->getFullURL( "target={$target}&action=success" ) );
                }
                else
                        $wgOut->addHTML( wfMsg( "usermailererror" ) . $mailResult);
index 913ed72..fabc2cb 100644 (file)
@@ -20,7 +20,7 @@ function wfSpecialExport( $page = "" ) {
        
        $wgOut->addWikiText( wfMsg( "exporttext" ) );
        $titleObj = Title::makeTitle( NS_SPECIAL, "Export" );
-       $action = $titleObj->getURL( "", true );
+       $action = $titleObj->escapeLocalURL();
        $wgOut->addHTML( "
 <form method='post' action=\"$action\">
 <input type='hidden' name='action' value='submit' />
index a4e6bf5..855aec0 100644 (file)
@@ -49,7 +49,7 @@ function wfSpecialImagelist()
        $cap = wfMsg( "ilshowmatch" );
        $sub = wfMsg( "ilsubmit" );
        $titleObj = Title::makeTitle( NS_SPECIAL, "Imagelist" );
-       $action = $titleObj->getURL(  "sort=byname&limit={$limit}", true );
+       $action = $titleObj->escapeLocalURL(  "sort=byname&limit={$limit}" );
 
        $wgOut->addHTML( "<form id=\"imagesearch\" method=\"post\" action=\"" .
          "{$action}\">" .
index 300e60f..064a97c 100644 (file)
@@ -39,7 +39,7 @@ class IPUnblockForm {
                $ipr = wfMsg( "ipbreason" );
                $ipus = wfMsg( "ipusubmit" );
                $titleObj = Title::makeTitle( NS_SPECIAL, "Ipblocklist" );
-               $action = $titleObj->getURL( "action=submit", true );
+               $action = $titleObj->escapeLocalURL( "action=submit" );
 
                if ( "" != $err ) {
                        $wgOut->setSubtitle( wfMsg( "formerror" ) );
@@ -88,7 +88,7 @@ class IPUnblockForm {
 
                # Report to the user
                $titleObj = Title::makeTitle( NS_SPECIAL, "Ipblocklist" );
-               $success = $titleObj->getURL( "action=success&ip=" . urlencode($wpUnblockAddress) );
+               $success = $titleObj->getFullURL( "action=success&ip=" . urlencode($wpUnblockAddress) );
                $wgOut->redirect( $success );
        }
 
@@ -131,7 +131,7 @@ function wfAddRow( $block, $tag ) {
        
        if ( !$block->mAuto ) {
                $titleObj = Title::makeTitle( NS_SPECIAL, "Contributions" );
-               $clink = "<a href=\"" . $titleObj->getURL( "target={$block->mAddress}", true ) . "\">" .
+               $clink = "<a href=\"" . $titleObj->escapeLocalURL( "target={$block->mAddress}" ) . "\">" .
                  wfMsg( "contribslink" ) . "</a>";
                $wgOut->addHTML( " ({$clink})" );
        }
@@ -139,7 +139,7 @@ function wfAddRow( $block, $tag ) {
        if ( $wgUser->isSysop() ) {
                $titleObj = Title::makeTitle( NS_SPECIAL, "Ipblocklist" );
                $ublink = "<a href=\"" . 
-                 $titleObj->getURL( "action=unblock&ip=" . urlencode( $addr ), true ) . "\">" .
+                 $titleObj->escapeLocalURL( "action=unblock&ip=" . urlencode( $addr ) ) . "\">" .
                  wfMsg( "unblocklink" ) . "</a>";
                $wgOut->addHTML( " ({$ublink})" );
        }
index 0cdee2a..628ab71 100644 (file)
@@ -36,7 +36,7 @@ class DBLockForm {
                $lb = wfMsg( "lockbtn" );
                $elr = wfMsg( "enterlockreason" );
                $titleObj = Title::makeTitle( NS_SPECIAL, "Lockdb" );
-               $action = $titleObj->getURL( "action=submit", true );
+               $action = $titleObj->escapeLocalURL( "action=submit" );
 
                $wgOut->addHTML( "<p>
 <form id=\"lockdb\" method=\"post\" action=\"{$action}\">
@@ -77,7 +77,7 @@ class DBLockForm {
                fclose( $fp );
 
                $titleObj = Title::makeTitle( NS_SPECIAL, "Lockdb" );
-               $wgOut->redirect( $titleObj->getURL( "action=success" ) );
+               $wgOut->redirect( $titleObj->getFullURL( "action=success" ) );
        }
 
        function showSuccess()
index 350eb92..f062ec2 100644 (file)
@@ -43,7 +43,7 @@ class MakesysopForm {
                $wgOut->addWikiText( wfMsg( "makesysoptext" ) );
 
                $titleObj = Title::makeTitle( NS_SPECIAL, "Makesysop" );
-               $action = $titleObj->getURL( "action=submit",  true );
+               $action = $titleObj->escapeLocalURL( "action=submit" );
 
                if ( "" != $err ) {
                        $wgOut->setSubtitle( wfMsg( "formerror" ) );
index 5752604..8fb9069 100644 (file)
@@ -64,7 +64,7 @@ class MovePageForm {
                $movetalk = wfMsg( "movetalk" );
 
                $titleObj = Title::makeTitle( NS_SPECIAL, "Movepage" );
-               $action = $titleObj->getURL( "action=submit", true );
+               $action = $titleObj->escapeLocalURL( "action=submit" );
 
                if ( "" != $err ) {
                        $wgOut->setSubtitle( wfMsg( "formerror" ) );
@@ -168,9 +168,9 @@ class MovePageForm {
                        /* this needs to be done after LinksUpdate */
                        $urlArr = Array(                                
                                # purge new title
-                               $wgInternalServer.$this->nt->getURL(),
+                               $wgInternalServer.$this->nt->getLocalURL(),
                                # purge old title
-                               $wgInternalServer.$this->ot->getURL())
+                               $wgInternalServer.$this->ot->getLocalURL())
                        );                      
                        wfPurgeSquidServers($urlArr);   
                        # purge pages linking to new title
@@ -225,9 +225,9 @@ class MovePageForm {
                                        /* this needs to be done after LinksUpdate */
                                        $urlArr = Array(                                
                                                # purge new title
-                                               $wgInternalServer.$nt->getURL()),
+                                               $nt->getInternalURL()),
                                                # purge old title
-                                               $wgInternalServer.$ot->getURL())
+                                               $ot->getInternalURL())
                                        );                      
                                        wfPurgeSquidServers($urlArr);   
                                        # purge pages linking to new title
@@ -242,7 +242,7 @@ class MovePageForm {
                        }
                }
                $titleObj = Title::makeTitle( NS_SPECIAL, "Movepage" );
-               $success = $titleObj->getURL( 
+               $success = $titleObj->getFullURL( 
                  "action=success&oldtitle=" . wfUrlencode( $this->ofx ) .
                  "&newtitle=" . wfUrlencode( $this->nfx ) .
                  "&talkmoved={$this->talkmoved}" );
index 69a7a6c..71800ee 100644 (file)
@@ -238,7 +238,7 @@ function wfSpecialPreferences()
        $togs = $wgLang->getUserToggles();
 
        $titleObj = Title::makeTitle( NS_SPECIAL, "Preferences" );
-       $action = $titleObj->getURL( "", true );
+       $action = $titleObj->escapeLocalURL();
 
        $qb = wfMsg( "qbsettings" );
        $cp = wfMsg( "changepassword" );
index e53f2d4..3f88769 100644 (file)
@@ -78,7 +78,7 @@ function wfSpecialUndelete( $par )
     $wgOut->addWikiText( wfMsg( "undeletehistory" ) . "\n<hr>\n" . $row->ar_text );
 
        $titleObj = Title::makeTitle( NS_SPECIAL, "Undelete" );
-       $action = $titleObj->getURL( "action=submit", true );
+       $action = $titleObj->escapeLocalURL( "action=submit" );
        $wgOut->addHTML("<p>
 <form id=\"undelete\" method=\"post\" action=\"{$action}\">
 <input type=hidden name=\"target\" value=\"{$target}\">
index 33ac7a5..b7ef19b 100644 (file)
@@ -32,7 +32,7 @@ class DBUnlockForm {
                $lc = wfMsg( "unlockconfirm" );
                $lb = wfMsg( "unlockbtn" );
                $titleObj = Title::makeTitle( NS_SPECIAL, "Unlockdb" );
-               $action = $titleObj->getURL( "action=submit", true );
+               $action = $titleObj->escapeLocalURL( "action=submit" );
 
                $wgOut->addHTML( "<p>
 <form id=\"unlockdb\" method=\"post\" action=\"{$action}\">
@@ -63,7 +63,7 @@ class DBUnlockForm {
                        return;
                }
                $titleObj = Title::makeTitle( NS_SPECIAL, "Unlockdb" );
-               $success = $titleObj->getURL( "action=success" );
+               $success = $titleObj->getFullURL( "action=success" );
                $wgOut->redirect( $success );
        }
 
index 8fb3764..5b35a58 100644 (file)
@@ -209,7 +209,7 @@ function uploadWarning( $warning )
        $iw = wfMsg( "ignorewarning" );
        $reup = wfMsg( "reuploaddesc" );
        $titleObj = Title::makeTitle( NS_SPECIAL, "Upload" );
-       $action = $titleObj->getURL( "action=submit", true );
+       $action = $titleObj->escapeLocalURL( "action=submit" );
 
        if ( $wgUseCopyrightUpload )
        {
@@ -268,7 +268,7 @@ function mainUploadForm( $msg )
        $iw = wfMsg( "ignorewarning" );
 
        $titleObj = Title::makeTitle( NS_SPECIAL, "Upload" );
-       $action = $titleObj->getURL( "", true );
+       $action = $titleObj->escapeLocalURL();
 
        $source = "
 <td align=right>
index 5ae70e1..98afd91 100644 (file)
@@ -319,7 +319,7 @@ color='red'>$err</font>\n" );
        $q = "action=submit";
        if ( "" != $_REQUEST['returnto'] ) { $q .= "&returnto=" . wfUrlencode($_REQUEST['returnto']); }
        $titleObj = Title::makeTitle( NS_SPECIAL, "Userlogin" );
-       $action = $titleObj->getURL( $q, true );
+       $action = $titleObj->escapeLocalUrl( $q );
 
        $encName = wfEscapeHTML( $name );
        $encPassword = wfEscapeHTML( $pwd );
@@ -391,7 +391,7 @@ $cambutton
        global $wgOut, $wgLang;
 
        $titleObj = Title::makeTitle( NS_SPECIAL, "Userlogin" );
-       $check = $titleObj->getURL( "wpCookieCheck=$type" );
+       $check = $titleObj->getFullURL( "wpCookieCheck=$type" );
 
        return $wgOut->redirect( $check );
 }
index 3dd8806..54c07b7 100644 (file)
@@ -93,7 +93,7 @@ function wfSpecialWatchlist()
                        "<p>" . wfMsg( "watcheditlist" ) . "</p>\n" );
                
                $wgOut->addHTML( "<form action='" .
-                       $specialTitle->getURL( "action=submit", true ) .
+                       $specialTitle->escapeLocalUrl( "action=submit" ) .
                        "' method='post'>\n" .
                        "<ul>\n" );
                $sql = "SELECT wl_namespace,wl_title FROM watchlist WHERE wl_user=$uid";
@@ -135,7 +135,7 @@ function wfSpecialWatchlist()
        
        $wgOut->addHTML( "<i>" . wfMsg( "watchdetails",
                $wgLang->formatNum( $nitems ), $wgLang->formatNum( $npages ), $y,
-               $specialTitle->getURL( "magic=yes", true ) ) . "</i><br>\n" );
+               $specialTitle->escapeLocalUrl( "magic=yes" ) ) . "</i><br>\n" );
         
 
        $sql = "SELECT
index 669342d..651478c 100644 (file)
@@ -21,7 +21,7 @@ class SquidUpdate {
                         while ( $BL = wfFetchObject ( $res ) )
                         {
                                 $t = Title::newFromDBkey( $BL->l_from) ; 
-                                $this->urlArr[] = $wgInternalServer.$t->getURL() ;
+                                $this->urlArr[] = $wgInternalServer.$t->getLocalURL() ;
                         }
                         wfFreeResult ( $res ) ;
 
index d45d2c4..62bc12d 100644 (file)
@@ -300,20 +300,21 @@ class Title {
        }
 
        # Get a real URL referring to this title, with interwiki link and fragment
-       function getFullURL()
+       function getFullURL( $query = "" )
        {
                global $wgLang, $wgArticlePath, $wgServer, $wgScript;
 
                if ( "" == $this->mInterwiki ) {
                        $p = $wgArticlePath;
-               } else {
-                       $p = $this->getInterwikiLink( $this->mInterwiki );
+                       return $wgServer . $this->getLocalUrl( $query );
                }
+               
+               $p = $this->getInterwikiLink( $this->mInterwiki );
                $n = $wgLang->getNsText( $this->mNamespace );
                if ( "" != $n ) { $n .= ":"; }
                $u = str_replace( "$1", $n . $this->mUrlform, $p );
                if ( "" != $this->mFragment ) {
-                       $u .= "#" . $this->mFragment;
+                       $u .= "#" . wfUrlencode( $this->mFragment );
                }
                return $u;
        }
@@ -324,9 +325,14 @@ class Title {
        # * Optionally adds the server and escapes for HTML
        # * Setting $query to "-" makes an old-style URL with nothing in the
        #   query except a title
-       function getURL( $query = "", $escape = false, $full = false )
+       
+       function getURL() {
+               die( "Call to obsolete obsolete function Title::getURL()" );
+       }
+       
+       function getLocalURL( $query = "" )
        {
-               global $wgLang, $wgArticlePath, $wgScript, $wgServer;
+               global $wgLang, $wgArticlePath, $wgScript;
                
                if ( $this->isExternal() ) {
                        return $this->getFullURL();
@@ -343,19 +349,26 @@ class Title {
                                $url = "{$wgScript}?title={$dbkey}&{$query}";
                        } else {
                                # Top level wiki
-                               $url = "/{$dbkey}&{$query}";
+                               $url = "/{$dbkey}?{$query}";
                        }
                }
-               
-               if ( $full ) {
-                       $url = $wgServer . $url;
-               }
-
-               if ( $escape ) {
-                       $url = wfEscapeHTML( $url );
-               }
                return $url;
        }
+       
+       function escapeLocalURL( $query = "" ) {
+               return wfEscapeHTML( $this->getLocalURL( $query ) );
+       }
+       
+       function escapeFullURL( $query = "" ) {
+               return wfEscapeHTML( $this->getFullURL( $query ) );
+       }
+       
+       function getInternalURL( $query = "" ) {
+               # Used in various Squid-related code, in case we have a different
+               # internal hostname for the server than the exposed one.
+               global $wgInternalServer;
+               return $wgInternalServer . $this->getLocalURL( $query );
+       }
 
        # Get the edit URL, or a null string if it is an interwiki link
        function getEditURL()
@@ -363,7 +376,7 @@ class Title {
                global $wgServer, $wgScript;
 
                if ( "" != $this->mInterwiki ) { return ""; }
-               $s = $this->getURL( "action=edit" );
+               $s = $this->getLocalURL( "action=edit" );
 
                return $s;
        }