r108648 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r108647‎ | r108648 | r108649 >
Date:18:44, 11 January 2012
Author:preilly
Status:ok
Tags:
Comment:
use wfAppendQuery fix for r107649 c29362
Modified paths:
  • /trunk/extensions/ZeroRatedMobileAccess/ZeroRatedMobileAccess.body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ZeroRatedMobileAccess/ZeroRatedMobileAccess.body.php
@@ -277,11 +277,9 @@
278278 foreach ( $zeroRatedLinks as $zeroRatedLink ) {
279279 $zeroRatedLinkHref = $zeroRatedLink->getAttribute( 'href' );
280280 if ( $zeroRatedLinkHref && substr( $zeroRatedLinkHref, 0, 1 ) !== '#' ) {
281 - $zeroPartnerUrl = $this->appendQueryString( $zeroRatedLinkHref,
282 - array( array( 'name' => 'zeropartner',
283 - 'value' => ( isset( self::$carrier['partnerId'] ) ) ? self::$carrier['partnerId'] : 0 ),
284 - array('name' => 'renderZeroRatedBanner',
285 - 'value' => 'true') ) );
 281+ $partnerId = isset( self::$carrier['partnerId'] ) ? self::$carrier['partnerId'] : 0;
 282+ $zeroPartnerUrl = wfAppendQuery( $zeroRatedLinkHref,
 283+ array( 'zeropartner' => $partnerId, 'renderZeroRatedBanner' => 'true' ) );
286284 if ( $zeroPartnerUrl ) {
287285 $zeroRatedLink->setAttribute( 'href', $zeroPartnerUrl );
288286 }
@@ -292,11 +290,9 @@
293291 foreach ( $zeroRatedExternalLinks as $zeroRatedExternalLink ) {
294292 $zeroRatedExternalLinkHref = $zeroRatedExternalLink->getAttribute( 'href' );
295293 if ( $zeroRatedExternalLinkHref && substr( $zeroRatedExternalLinkHref, 0, 1 ) !== '#' ) {
296 - $zeroPartnerUrl = $this->appendQueryString( $zeroRatedLinkHref,
297 - array( array( 'name' => 'zeropartner',
298 - 'value' => ( isset( self::$carrier['partnerId'] ) ) ? self::$carrier['partnerId'] : 0 ),
299 - array('name' => 'renderZeroRatedBanner',
300 - 'value' => 'true') ) );
 294+ $partnerId = isset( self::$carrier['partnerId'] ) ? self::$carrier['partnerId'] : 0;
 295+ $zeroPartnerUrl = wfAppendQuery( $zeroRatedLinkHref,
 296+ array( 'zeropartner' => $partnerId, 'renderZeroRatedBanner' => 'true' ) );
301297 if ( $zeroPartnerUrl ) {
302298 $zeroRatedExternalLink->setAttribute( 'href', '?renderZeroRatedRedirect=true&returnto=' . urlencode($zeroRatedExternalLinkHref) );
303299 }
@@ -309,56 +305,6 @@
310306 }
311307
312308 /**
313 - * Returns the url with querystring parameters appended
314 - *
315 - * @param String $url: valid url to append querystring
316 - * @param Array $queryStringParameters: array of parameters to add to querystring
317 - * @return String
318 - */
319 - private function appendQueryString( $url, $queryStringParameters ) {
320 - wfProfileIn( __METHOD__ );
321 - $parsedUrl = parse_url( $url );
322 - if ( isset( $parsedUrl['query'] ) ) {
323 - parse_str( $parsedUrl['query'], $queryString );
324 - foreach ( $queryStringParameters as $queryStringParameter ) {
325 - $queryString[$queryStringParameter['name']] = $queryStringParameter['value'];
326 - }
327 - $parsedUrl['query'] = http_build_query( $queryString );
328 - } else {
329 - $parsedUrl['query'] = '';
330 - foreach ( $queryStringParameters as $queryStringParameter ) {
331 - $parsedUrl['query'] .= "{$queryStringParameter['name']}={$queryStringParameter['value']}&";
332 - }
333 - if ( substr( $parsedUrl['query'], -1, 1 ) === '&' ) {
334 - $parsedUrl['query'] = substr( $parsedUrl['query'], 0, -1 );
335 - }
336 - }
337 - wfProfileOut( __METHOD__ );
338 - return $this->unParseUrl( $parsedUrl );
339 - }
340 -
341 - /**
342 - * Returns the full url
343 - *
344 - * @param Array $parsedUrl: the array returned from parse_url
345 - * @return String
346 - */
347 - private function unParseUrl( $parsedUrl ) {
348 - wfProfileIn( __METHOD__ );
349 - $scheme = isset( $parsedUrl['scheme'] ) ? $parsedUrl['scheme'] . '://' : '';
350 - $host = isset( $parsedUrl['host'] ) ? $parsedUrl['host'] : '';
351 - $port = isset( $parsedUrl['port'] ) ? ':' . $parsedUrl['port'] : '';
352 - $user = isset( $parsedUrl['user'] ) ? $parsedUrl['user'] : '';
353 - $pass = isset( $parsedUrl['pass'] ) ? ':' . $parsedUrl['pass'] : '';
354 - $pass = ( $user || $pass ) ? "$pass@" : '';
355 - $path = isset( $parsedUrl['path'] ) ? $parsedUrl['path'] : '';
356 - $query = isset( $parsedUrl['query'] ) ? '?' . $parsedUrl['query'] : '';
357 - $fragment = isset( $parsedUrl['fragment'] ) ? '#' . $parsedUrl['fragment'] : '';
358 - wfProfileOut( __METHOD__ );
359 - return "$scheme$user$pass$host$port$path$query$fragment";
360 - }
361 -
362 - /**
363309 * Adds object to debugOutput Array
364310 *
365311 * @param Object $object: any valid PHP object

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r107649add aditional functionalitypreilly19:25, 30 December 2011

Status & tagging log