From: Brion Vibber Date: Sun, 7 Mar 2004 07:26:56 +0000 (+0000) Subject: Replace the random boolean parameters on Title::getURL() with a set of X-Git-Tag: 1.3.0beta1~847 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/exercices/journal.php?a=commitdiff_plain;h=b59ce2294385403bf4da644a0323aa7ba01b8a66;p=lhc%2Fweb%2Fwiklou.git Replace the random boolean parameters on Title::getURL() with a set of 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. --- diff --git a/includes/Article.php b/includes/Article.php index 778d3aa640..d4bb052c89 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -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 ); diff --git a/includes/EditPage.php b/includes/EditPage.php index bc59468028..6f06d0e5ad 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -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"); diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 8e69807324..8322905e24 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -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()" ); } diff --git a/includes/OutputPage.php b/includes/OutputPage.php index c6cc144e54..7288b242fc 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -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

$r\n" ); } diff --git a/includes/PageHistory.php b/includes/PageHistory.php index bfae24ea7c..3e1ff45a92 100644 --- a/includes/PageHistory.php +++ b/includes/PageHistory.php @@ -106,7 +106,7 @@ class PageHistory { global $wgTitle; $this->lastdate = $this->lastline = ""; $s = "\n

" . wfMsg( "histlegend" ) . "\n