r108703 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r108702‎ | r108703 | r108704 >
Date:00:42, 12 January 2012
Author:preilly
Status:ok
Tags:
Comment:
1.18wmf1: MFT r108702
Modified paths:
  • /branches/wmf/1.18wmf1/extensions/MobileFrontend/MobileFrontend.php (modified) (history)

Diff [purge]

Index: branches/wmf/1.18wmf1/extensions/MobileFrontend/MobileFrontend.php
@@ -424,6 +424,29 @@
425425 wfProfileOut( __METHOD__ );
426426 return true;
427427 }
 428+
 429+ /**
 430+ * @param $parsedUrl wfParseUrl Array
 431+ * @return string
 432+ */
 433+ public function parsePageRedirect( $parsedUrl ) {
 434+ global $wgMobileDomain;
 435+ wfProfileIn( __METHOD__ );
 436+ $redirect = '';
 437+ $hostParts = explode( '.', $parsedUrl['host'] );
 438+ $parsedUrl['host'] = $hostParts[0] . $wgMobileDomain . $hostParts[1] . '.' . $hostParts[2];
 439+ $fragmentDelimiter = ( !empty( $parsedUrl['fragment'] ) ) ? '#' : '';
 440+ $queryDelimiter = ( !empty( $parsedUrl['query'] ) ) ? '?' : '';
 441+ $redirect = $parsedUrl['scheme'] . '://' . $parsedUrl['host'] . $parsedUrl['path'];
 442+ if ( isset( $parsedUrl['query'] ) ) {
 443+ $redirect .= $queryDelimiter . $parsedUrl['query'];
 444+ }
 445+ if ( isset( $parsedUrl['fragment'] ) ) {
 446+ $redirect .= $fragmentDelimiter . $parsedUrl['fragment'];
 447+ }
 448+ wfProfileOut( __METHOD__ );
 449+ return $redirect;
 450+ }
428451
429452 /**
430453 * @param $out OutputPage
@@ -445,15 +468,16 @@
446469 if ( $parsedUrl['scheme'] == 'http' ) {
447470 $parsedUrl['scheme'] = 'https';
448471 }
449 - $fragmentDelimiter = ( !empty( $parsedUrl['fragment'] ) ) ? '#' : '';
450 - $queryDelimiter = ( !empty( $parsedUrl['query'] ) ) ? '?' : '';
451 - $redirect = $parsedUrl['scheme'] . '://' . $parsedUrl['host'] . $parsedUrl['path'];
452 - if ( isset( $parsedUrl['query'] ) ) {
453 - $redirect .= $queryDelimiter . $parsedUrl['query'];
 472+
 473+ $redirect = $this->parsePageRedirect( $parsedUrl );
 474+ }
 475+ } else if ($out->getTitle()->isSpecial( 'Randompage' ) ) {
 476+ $xDevice = isset( $_SERVER['HTTP_X_DEVICE'] ) ? $_SERVER['HTTP_X_DEVICE'] : '';
 477+ if ( $xDevice ) {
 478+ $parsedUrl = wfParseUrl( $redirect );
 479+ if ( stristr( $parsedUrl['host'], $wgMobileDomain ) === false ) {
 480+ $redirect = $this->parsePageRedirect( $parsedUrl );
454481 }
455 - if ( isset( $parsedUrl['fragment'] ) ) {
456 - $redirect .= $fragmentDelimiter . $parsedUrl['fragment'];
457 - }
458482 }
459483 }
460484 wfProfileOut( __METHOD__ );

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r108702fix for Bug 33441 - Random button directing to regular websitepreilly00:39, 12 January 2012

Status & tagging log