Use wfAppendQuery to append a query
authorumherirrender <umherirrender_de.wp@web.de>
Thu, 11 Apr 2013 18:22:11 +0000 (20:22 +0200)
committerGerrit Code Review <gerrit@wikimedia.org>
Fri, 12 Apr 2013 07:31:52 +0000 (07:31 +0000)
Also pass a array to wfAppendQuery, which than does the urlencoding.

Prefer a wfScript() over the global or string

Change-Id: Icada534cb4c99c9441938a2e8dcbc11a142360c6

includes/Linker.php
includes/SpecialPage.php
includes/filerepo/file/File.php
includes/media/ImageHandler.php
includes/resourceloader/ResourceLoaderStartUpModule.php
includes/site/MediaWikiSite.php
includes/specials/SpecialContributions.php

index e4222e3..3e8a3c9 100644 (file)
@@ -238,7 +238,7 @@ class Linker {
                # Note: we want the href attribute first, for prettiness.
                $attribs = array( 'href' => self::linkUrl( $target, $query, $options ) );
                if ( in_array( 'forcearticlepath', $options ) && $oldquery ) {
-                       $attribs['href'] = wfAppendQuery( $attribs['href'], wfArrayToCgi( $oldquery ) );
+                       $attribs['href'] = wfAppendQuery( $attribs['href'], $oldquery );
                }
 
                $attribs = array_merge(
@@ -840,7 +840,7 @@ class Linker {
                # zoom icon still needs it, so we make a unique query for it. See bug 14771
                $url = $title->getLocalURL( $query );
                if ( $page ) {
-                       $url = wfAppendQuery( $url, 'page=' . urlencode( $page ) );
+                       $url = wfAppendQuery( $url, array( 'page' => $page ) );
                }
                if ( $manualthumb &&
                     !isset( $fp['link-title'] ) &&
index d09be87..d8f6fd9 100644 (file)
@@ -842,11 +842,11 @@ class SpecialPage {
        protected function addFeedLinks( $params ) {
                global $wgFeedClasses;
 
-               $feedTemplate = wfScript( 'api' ) . '?';
+               $feedTemplate = wfScript( 'api' );
 
                foreach ( $wgFeedClasses as $format => $class ) {
                        $theseParams = $params + array( 'feedformat' => $format );
-                       $url = $feedTemplate . wfArrayToCgi( $theseParams );
+                       $url = wfAppendQuery( $feedTemplate, $theseParams );
                        $this->getOutput()->addFeedLink( $format, $url );
                }
        }
@@ -1093,10 +1093,9 @@ abstract class RedirectSpecialPage extends UnlistedSpecialPage {
                        $url = $redirect->getFullURL( $query );
                        $this->getOutput()->redirect( $url );
                        return $redirect;
-               // Redirect to index.php with query parameters
                } elseif ( $redirect === true ) {
-                       global $wgScript;
-                       $url = $wgScript . '?' . wfArrayToCgi( $query );
+                       // Redirect to index.php with query parameters
+                       $url = wfAppendQuery( wfScript( 'index' ), $query );
                        $this->getOutput()->redirect( $url );
                        return $redirect;
                } else {
index d72755a..64155e6 100644 (file)
@@ -737,7 +737,7 @@ abstract class File {
                        if ( $this->repo ) {
                                $script = $this->repo->getThumbScriptUrl();
                                if ( $script ) {
-                                       $this->transformScript = "$script?f=" . urlencode( $this->getName() );
+                                       $this->transformScript = wfAppendQuery( $script, array( 'f' => $this->getName() ) );
                                }
                        }
                }
index ad9919b..6ee0399 100644 (file)
@@ -187,7 +187,7 @@ abstract class ImageHandler extends MediaHandler {
                if ( !$this->normaliseParams( $image, $params ) ) {
                        return false;
                }
-               $url = $script . '&' . wfArrayToCgi( $this->getScriptParams( $params ) );
+               $url = wfAppendQuery( $script, $this->getScriptParams( $params ) );
 
                if( $image->mustRender() || $params['width'] < $image->getWidth() ) {
                        return new ThumbnailImage( $image, $url, false, $params );
index 24cdeb0..5919cde 100644 (file)
@@ -185,7 +185,7 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule {
         * @return string
         */
        public function getScript( ResourceLoaderContext $context ) {
-               global $IP, $wgLoadScript, $wgLegacyJavaScriptGlobals;
+               global $IP, $wgLegacyJavaScriptGlobals;
 
                $out = file_get_contents( "$IP/resources/startup.js" );
                if ( $context->getOnly() === 'scripts' ) {
@@ -225,7 +225,7 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule {
                                "};\n";
 
                        // Conditional script injection
-                       $scriptTag = Html::linkedScript( $wgLoadScript . '?' . wfArrayToCgi( $query ) );
+                       $scriptTag = Html::linkedScript( wfAppendQuery( wfScript( 'load' ), $query ) );
                        $out .= "if ( isCompatible() ) {\n" .
                                "\t" . Xml::encodeJsCall( 'document.write', array( $scriptTag ) ) .
                                "}\n" .
index 21226fd..4cd48b8 100644 (file)
@@ -130,7 +130,7 @@ class MediaWikiSite extends Site {
                                // Also consider smaxage if maxage is used.
                        );
 
-                       $url = $this->getFileUrl( 'api.php' ) . '?' . wfArrayToCgi( $args );
+                       $url = wfAppendQuery( $this->getFileUrl( wfScript( 'api' ) ), $args );
 
                        // Go on call the external site
                        //@todo: we need a good way to specify a timeout here.
index e985811..932f05e 100644 (file)
@@ -155,7 +155,7 @@ class SpecialContributions extends SpecialPage {
                                $apiParams['month'] = $this->opts['month'];
                        }
 
-                       $url = wfScript( 'api' ) . '?' . wfArrayToCgi( $apiParams );
+                       $url = wfAppendQuery( wfScript( 'api' ), $apiParams );
 
                        $out->redirect( $url, '301' );
                        return;