Pass array to Title::getLocalURL instead of an urlencoded string
authorumherirrender <umherirrender_de.wp@web.de>
Fri, 19 Apr 2013 12:53:20 +0000 (14:53 +0200)
committerGerrit Code Review <gerrit@wikimedia.org>
Sat, 27 Apr 2013 08:22:01 +0000 (08:22 +0000)
This makes code easier to read and the urlencode is done inside
getLocalURL or friends

Change-Id: I21b988890356d11835eedba12a90a347bf0905b2

12 files changed:
includes/ChangesFeed.php
includes/FeedUtils.php
includes/OutputPage.php
includes/Preferences.php
includes/SkinLegacy.php
includes/SpecialPageFactory.php
includes/UserMailer.php
includes/Wiki.php
includes/WikiPage.php
includes/parser/Parser.php
includes/specials/SpecialRevisiondelete.php
includes/specials/SpecialUndelete.php

index 8e710de..1d89888 100644 (file)
@@ -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();
index 6f3b42c..1d3b3c8 100644 (file)
@@ -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 ),
index bf3c084..08eb3ae 100644 (file)
@@ -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'.
                                        );
                                }
index 5518eb3..64b48dd 100644 (file)
@@ -1093,7 +1093,7 @@ class Preferences {
                        }
 
                        # Create preview link
-                       $mplink = htmlspecialchars( $mptitle->getLocalURL( "useskin=$skinkey" ) );
+                       $mplink = htmlspecialchars( $mptitle->getLocalURL( array( 'useskin' => $skinkey ) ) );
                        $linkTools[] = "<a target='_blank' href=\"$mplink\">$previewtext</a>";
 
                        # Create links to user CSS/JS pages
index ae65b9d..6f11837 100644 (file)
@@ -220,7 +220,7 @@ class LegacyTemplate extends BaseTemplate {
 
                                $s = $wgLang->pipeList( array(
                                        $s,
-                                       '<a href="' . htmlspecialchars( $title->getLocalURL( 'variant=' . $code ) ) . '" lang="' . $code . '" hreflang="' . $code . '">' . htmlspecialchars( $varname ) . '</a>'
+                                       '<a href="' . htmlspecialchars( $title->getLocalURL( array( 'variant' => $code ) ) ) . '" lang="' . $code . '" hreflang="' . $code . '">' . htmlspecialchars( $varname ) . '</a>'
                                ) );
                        }
                }
index 675fb83..19adf70 100644 (file)
@@ -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 );
index 7eca76f..370bac9 100644 (file)
@@ -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;
index 2fd12d5..3f7e19c 100644 (file)
@@ -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'] );
index c2aad76..8c00e1b 100644 (file)
@@ -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
index 47a09c4..836ddf5 100644 (file)
@@ -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();
index 771132a..9249f27 100644 (file)
@@ -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() ) .
index 70a34e3..9050724 100644 (file)
@@ -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() ) .