From c0d61543b21d3beed183c109acb326dc90ab7d81 Mon Sep 17 00:00:00 2001 From: umherirrender Date: Fri, 19 Apr 2013 14:53:20 +0200 Subject: [PATCH] Pass array to Title::getLocalURL instead of an urlencoded string This makes code easier to read and the urlencode is done inside getLocalURL or friends Change-Id: I21b988890356d11835eedba12a90a347bf0905b2 --- includes/ChangesFeed.php | 8 ++++---- includes/FeedUtils.php | 7 ++++--- includes/OutputPage.php | 2 +- includes/Preferences.php | 2 +- includes/SkinLegacy.php | 2 +- includes/SpecialPageFactory.php | 1 - includes/UserMailer.php | 4 ++-- includes/Wiki.php | 2 +- includes/WikiPage.php | 2 +- includes/parser/Parser.php | 2 +- includes/specials/SpecialRevisiondelete.php | 9 +++++---- includes/specials/SpecialUndelete.php | 9 +++++---- 12 files changed, 26 insertions(+), 24 deletions(-) diff --git a/includes/ChangesFeed.php b/includes/ChangesFeed.php index 8e710de789..1d89888814 100644 --- a/includes/ChangesFeed.php +++ b/includes/ChangesFeed.php @@ -194,10 +194,10 @@ class ChangesFeed { } if ( $obj->rc_this_oldid ) { - $url = $title->getFullURL( - 'diff=' . $obj->rc_this_oldid . - '&oldid=' . $obj->rc_last_oldid - ); + $url = $title->getFullURL( array( + 'diff' => $obj->rc_this_oldid, + 'oldid' => $obj->rc_last_oldid, + ) ); } else { // log entry or something like that. $url = $title->getFullURL(); diff --git a/includes/FeedUtils.php b/includes/FeedUtils.php index 6f3b42c37b..1d3b3c82de 100644 --- a/includes/FeedUtils.php +++ b/includes/FeedUtils.php @@ -220,9 +220,10 @@ class FeedUtils { * @return string */ protected static function getDiffLink( Title $title, $newid, $oldid = null ) { - $queryParameters = ($oldid == null) - ? "diff={$newid}" - : "diff={$newid}&oldid={$oldid}"; + $queryParameters = array( 'diff' => $newid ); + if ( $oldid != null ) { + $queryParameters['oldid'] = $oldid; + } $diffUrl = $title->getFullURL( $queryParameters ); $diffLink = Html::element( 'a', array( 'href' => $diffUrl ), diff --git a/includes/OutputPage.php b/includes/OutputPage.php index bf3c0842e7..08eb3ae667 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -3324,7 +3324,7 @@ $templates foreach ( $wgAdvertisedFeedTypes as $format ) { $tags[] = $this->feedLink( $format, - $rctitle->getLocalURL( "feed={$format}" ), + $rctitle->getLocalURL( array( 'feed' => $format ) ), $this->msg( "site-{$format}-feed", $wgSitename )->text() # For grep: 'site-rss-feed', 'site-atom-feed'. ); } diff --git a/includes/Preferences.php b/includes/Preferences.php index 5518eb38a6..64b48dd569 100644 --- a/includes/Preferences.php +++ b/includes/Preferences.php @@ -1093,7 +1093,7 @@ class Preferences { } # Create preview link - $mplink = htmlspecialchars( $mptitle->getLocalURL( "useskin=$skinkey" ) ); + $mplink = htmlspecialchars( $mptitle->getLocalURL( array( 'useskin' => $skinkey ) ) ); $linkTools[] = "$previewtext"; # Create links to user CSS/JS pages diff --git a/includes/SkinLegacy.php b/includes/SkinLegacy.php index ae65b9dad1..6f118371ea 100644 --- a/includes/SkinLegacy.php +++ b/includes/SkinLegacy.php @@ -220,7 +220,7 @@ class LegacyTemplate extends BaseTemplate { $s = $wgLang->pipeList( array( $s, - '' . htmlspecialchars( $varname ) . '' + '' . htmlspecialchars( $varname ) . '' ) ); } } diff --git a/includes/SpecialPageFactory.php b/includes/SpecialPageFactory.php index 675fb833c4..19adf700a2 100644 --- a/includes/SpecialPageFactory.php +++ b/includes/SpecialPageFactory.php @@ -463,7 +463,6 @@ class SpecialPageFactory { if ( $name != $page->getLocalName() && !$context->getRequest()->wasPosted() ) { $query = $context->getRequest()->getQueryValues(); unset( $query['title'] ); - $query = wfArrayToCgi( $query ); $title = $page->getTitle( $par ); $url = $title->getFullURL( $query ); $context->getOutput()->redirect( $url ); diff --git a/includes/UserMailer.php b/includes/UserMailer.php index 7eca76fdf0..370bac9fe3 100644 --- a/includes/UserMailer.php +++ b/includes/UserMailer.php @@ -703,14 +703,14 @@ class EmailNotification { if ( $this->oldid ) { // Always show a link to the diff which triggered the mail. See bug 32210. $keys['$NEWPAGE'] = "\n\n" . wfMessage( 'enotif_lastdiff', - $this->title->getCanonicalURL( 'diff=next&oldid=' . $this->oldid ) ) + $this->title->getCanonicalURL( array( 'diff' => 'next', 'oldid' => $this->oldid ) ) ) ->inContentLanguage()->text(); if ( !$wgEnotifImpersonal ) { // For personal mail, also show a link to the diff of all changes // since last visited. $keys['$NEWPAGE'] .= "\n\n" . wfMessage( 'enotif_lastvisited', - $this->title->getCanonicalURL( 'diff=0&oldid=' . $this->oldid ) ) + $this->title->getCanonicalURL( array( 'diff' => '0', 'oldid' => $this->oldid ) ) ) ->inContentLanguage()->text(); } $keys['$OLDID'] = $this->oldid; diff --git a/includes/Wiki.php b/includes/Wiki.php index 2fd12d5e84..3f7e19cf97 100644 --- a/includes/Wiki.php +++ b/includes/Wiki.php @@ -227,7 +227,7 @@ class MediaWiki { if ( $title->getInterwiki() != '' ) { $rdfrom = $request->getVal( 'rdfrom' ); if ( $rdfrom ) { - $url = $title->getFullURL( 'rdfrom=' . urlencode( $rdfrom ) ); + $url = $title->getFullURL( array( 'rdfrom' => $rdfrom ) ); } else { $query = $request->getValues(); unset( $query['title'] ); diff --git a/includes/WikiPage.php b/includes/WikiPage.php index c2aad7687c..8c00e1b526 100644 --- a/includes/WikiPage.php +++ b/includes/WikiPage.php @@ -946,7 +946,7 @@ class WikiPage implements Page, IDBAccessObject { // This can be hard to reverse and may produce loops, // so they may be disabled in the site configuration. $source = $this->mTitle->getFullURL( 'redirect=no' ); - return $rt->getFullURL( 'rdfrom=' . urlencode( $source ) ); + return $rt->getFullURL( array( 'rdfrom' => $source ) ); } else { // External pages pages without "local" bit set are not valid // redirect targets diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index 47a09c4e32..836ddf59cf 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -3805,7 +3805,7 @@ class Parser { return wfMessage( 'scarytranscludedisabled' )->inContentLanguage()->text(); } - $url = $title->getFullURL( "action=$action" ); + $url = $title->getFullURL( array( 'action' => $action ) ); if ( strlen( $url ) > 255 ) { return wfMessage( 'scarytranscludetoolong' )->inContentLanguage()->text(); diff --git a/includes/specials/SpecialRevisiondelete.php b/includes/specials/SpecialRevisiondelete.php index 771132a59b..9249f27341 100644 --- a/includes/specials/SpecialRevisiondelete.php +++ b/includes/specials/SpecialRevisiondelete.php @@ -312,10 +312,11 @@ class SpecialRevisionDelete extends UnlistedSpecialPage { $this->getOutput()->addHTML( Xml::openElement( 'form', array( 'method' => 'POST', - 'action' => $this->getTitle()->getLocalURL( - 'target=' . urlencode( $this->targetObj->getPrefixedDBkey() ) . - '&file=' . urlencode( $archiveName ) . - '&token=' . urlencode( $user->getEditToken( $archiveName ) ) ) + 'action' => $this->getTitle()->getLocalURL( array( + 'target' => $this->targetObj->getPrefixedDBkey(), + 'file' => $archiveName, + 'token' => $user->getEditToken( $archiveName ), + ) ) ) ) . Xml::submitButton( $this->msg( 'revdelete-show-file-submit' )->text() ) . diff --git a/includes/specials/SpecialUndelete.php b/includes/specials/SpecialUndelete.php index 70a34e3639..9050724955 100644 --- a/includes/specials/SpecialUndelete.php +++ b/includes/specials/SpecialUndelete.php @@ -1115,10 +1115,11 @@ class SpecialUndelete extends SpecialPage { $out->addHTML( Xml::openElement( 'form', array( 'method' => 'POST', - 'action' => $this->getTitle()->getLocalURL( - 'target=' . urlencode( $this->mTarget ) . - '&file=' . urlencode( $key ) . - '&token=' . urlencode( $user->getEditToken( $key ) ) ) + 'action' => $this->getTitle()->getLocalURL( array( + 'target' => $this->mTarget, + 'file' => $key, + 'token' => $user->getEditToken( $key ), + ) ), ) ) . Xml::submitButton( $this->msg( 'undelete-show-file-submit' )->text() ) . -- 2.20.1