Also pass a array to wfAppendQuery, which than does the urlencoding.
Prefer a wfScript() over the global or string
Change-Id: Icada534cb4c99c9441938a2e8dcbc11a142360c6
# 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(
# 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'] ) &&
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 );
}
}
$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 {
if ( $this->repo ) {
$script = $this->repo->getThumbScriptUrl();
if ( $script ) {
- $this->transformScript = "$script?f=" . urlencode( $this->getName() );
+ $this->transformScript = wfAppendQuery( $script, array( 'f' => $this->getName() ) );
}
}
}
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 );
* @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' ) {
"};\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" .
// 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.
$apiParams['month'] = $this->opts['month'];
}
- $url = wfScript( 'api' ) . '?' . wfArrayToCgi( $apiParams );
+ $url = wfAppendQuery( wfScript( 'api' ), $apiParams );
$out->redirect( $url, '301' );
return;