r106164 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r106163‎ | r106164 | r106165 >
Date:04:26, 14 December 2011
Author:preilly
Status:deferred
Tags:mobile 
Comment:
fix redirect issue
Modified paths:
  • /trunk/extensions/MobileFrontend/MobileFrontend.php (modified) (history)

Diff [purge]

Index: trunk/extensions/MobileFrontend/MobileFrontend.php
@@ -422,19 +422,22 @@
423423
424424 public function beforePageRedirect( $out, &$redirect, &$code ) {
425425 if ( $out->getTitle()->isSpecial( 'Userlogin' ) ) {
426 - global $wgMobileDomain;
427 - $parsedUrl = wfParseUrl( $redirect );
428 - if ( stristr( $parsedUrl['host'], $wgMobileDomain ) === false ) {
429 - $hostParts = explode( '.', $parsedUrl['host'] );
430 - $parsedUrl['host'] = $hostParts[0] . $wgMobileDomain . $hostParts[1] . '.' . $hostParts[2];
 426+ global $wgMobileDomain, $wgRequest;
 427+ $requestURL = $wgRequest->getFullRequestURL();
 428+ if ( stristr( $requestURL, $wgMobileDomain ) !== false ) {
 429+ $parsedUrl = wfParseUrl( $redirect );
 430+ if ( stristr( $parsedUrl['host'], $wgMobileDomain ) === false ) {
 431+ $hostParts = explode( '.', $parsedUrl['host'] );
 432+ $parsedUrl['host'] = $hostParts[0] . $wgMobileDomain . $hostParts[1] . '.' . $hostParts[2];
 433+ }
 434+ if ( $parsedUrl['scheme'] == 'http' ) {
 435+ $parsedUrl['scheme'] = 'https';
 436+ }
 437+ $fragmentDelimiter = ( !empty( $parsedUrl['fragment'] ) ) ? '#' : '';
 438+ $queryDelimiter = ( !empty( $parsedUrl['query'] ) ) ? '?' : '';
 439+ $redirect = $parsedUrl['scheme'] . '://' . $parsedUrl['host'] . $parsedUrl['path']
 440+ . $queryDelimiter . $parsedUrl['query'] . $fragmentDelimiter . $parsedUrl['fragment'];
431441 }
432 - if ( $parsedUrl['scheme'] == 'http' ) {
433 - $parsedUrl['scheme'] = 'https';
434 - }
435 - $fragmentDelimiter = ( !empty( $parsedUrl['fragment'] ) ) ? '#' : '';
436 - $queryDelimiter = ( !empty( $parsedUrl['query'] ) ) ? '?' : '';
437 - $redirect = $parsedUrl['scheme'] . '://' . $parsedUrl['host'] . $parsedUrl['path']
438 - . $queryDelimiter . $parsedUrl['query'] . $fragmentDelimiter . $parsedUrl['fragment'];
439442 }
440443 return true;
441444 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r1061651.18wmf1: MFT r106164preilly04:26, 14 December 2011

Status & tagging log