Index: trunk/extensions/MobileFrontend/MobileFrontend.php |
— | — | @@ -422,19 +422,22 @@ |
423 | 423 | |
424 | 424 | public function beforePageRedirect( $out, &$redirect, &$code ) { |
425 | 425 | 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']; |
431 | 441 | } |
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']; |
439 | 442 | } |
440 | 443 | return true; |
441 | 444 | } |