Index: branches/wmf/1.18wmf1/extensions/MobileFrontend/MobileFrontend.php |
— | — | @@ -88,7 +88,7 @@ |
89 | 89 | } |
90 | 90 | |
91 | 91 | class ExtMobileFrontend { |
92 | | - const VERSION = '0.5.91'; |
| 92 | + const VERSION = '0.5.95'; |
93 | 93 | |
94 | 94 | /** |
95 | 95 | * @var DOMDocument |
— | — | @@ -443,14 +443,13 @@ |
444 | 444 | // Thus, globalized objects will not be available as expected in the function. |
445 | 445 | // This is stated to be intended behavior, as per the following: [http://bugs.php.net/bug.php?id=40104] |
446 | 446 | |
447 | | - $xDevice = !empty( $_SERVER['HTTP_X_DEVICE'] ) ? $_SERVER['HTTP_X_DEVICE'] : ''; |
| 447 | + $xDevice = isset( $_SERVER['HTTP_X_DEVICE'] ) ? $_SERVER['HTTP_X_DEVICE'] : ''; |
448 | 448 | self::$useFormat = $wgRequest->getText( 'useformat' ); |
449 | 449 | $mobileAction = $wgRequest->getText( 'mobileaction' ); |
450 | 450 | $action = $wgRequest->getText( 'action' ); |
451 | 451 | |
452 | | - if ( self::$useFormat === 'mobile' || |
453 | | - self::$useFormat === 'mobile-wap' || |
454 | | - !empty( $xDevice ) ) { |
| 452 | + if ( self::$useFormat === 'mobile' || self::$useFormat === 'mobile-wap' || |
| 453 | + $xDevice ) { |
455 | 454 | if ( $action !== 'edit' && |
456 | 455 | $mobileAction !== 'view_normal_site' ) { |
457 | 456 | |
— | — | @@ -497,10 +496,10 @@ |
498 | 497 | self::$search = $wgRequest->getText( 'search' ); |
499 | 498 | self::$searchField = $wgRequest->getText( 'search', '' ); |
500 | 499 | |
501 | | - $acceptHeader = !empty( $_SERVER["HTTP_ACCEPT"] ) ? $_SERVER["HTTP_ACCEPT"] : ''; |
| 500 | + $acceptHeader = isset( $_SERVER["HTTP_ACCEPT"] ) ? $_SERVER["HTTP_ACCEPT"] : ''; |
502 | 501 | $device = new DeviceDetection(); |
503 | 502 | |
504 | | - if ( !empty( $xDevice ) ) { |
| 503 | + if ( $xDevice ) { |
505 | 504 | $formatName = $xDevice; |
506 | 505 | } else { |
507 | 506 | $formatName = $device->formatName( $userAgent, $acceptHeader ); |
— | — | @@ -589,9 +588,14 @@ |
590 | 589 | |
591 | 590 | if ( self::$title->isSpecial( 'Userlogin' ) && self::$isBetaGroupMember ) { |
592 | 591 | self::$wsLoginToken = $wgRequest->getSessionData( 'wsLoginToken' ); |
| 592 | + $q = array( 'action' => 'submitlogin', 'type' => 'login' ); |
593 | 593 | $returnToVal = $wgRequest->getVal( 'returnto' ); |
594 | | - $returnto = ( !empty( $returnToVal ) ) ? '&returnto=' . wfUrlencode( $returnToVal ) : ''; |
595 | | - self::$wsLoginFormAction = self::$title->getLocalURL( 'action=submitlogin&type=login' . $returnto ); |
| 594 | + |
| 595 | + if ( $returnToVal ) { |
| 596 | + $q['returnto'] = $returnToVal; |
| 597 | + } |
| 598 | + |
| 599 | + self::$wsLoginFormAction = self::$title->getLocalURL( $q ); |
596 | 600 | } |
597 | 601 | |
598 | 602 | $this->setDefaultLogo(); |
— | — | @@ -618,7 +622,7 @@ |
619 | 623 | $wgRequest->response()->setcookie( 'mfsecure', '1', 0, '' ); |
620 | 624 | } else { |
621 | 625 | $mfSecure = $wgRequest->getCookie( 'mfsecure', '' ); |
622 | | - if ( !empty( $mfSecure ) && $mfSecure == '1' ) { |
| 626 | + if ( $mfSecure && $mfSecure == '1' ) { |
623 | 627 | $wgRequest->response()->setcookie( 'mfsecure', '', 0, '' ); |
624 | 628 | } |
625 | 629 | } |
— | — | @@ -725,7 +729,7 @@ |
726 | 730 | private function sendXDeviceVaryHeader() { |
727 | 731 | global $wgOut, $wgRequest; |
728 | 732 | wfProfileIn( __METHOD__ ); |
729 | | - if ( !empty( $_SERVER['HTTP_X_DEVICE'] ) ) { |
| 733 | + if ( isset( $_SERVER['HTTP_X_DEVICE'] ) ) { |
730 | 734 | $wgRequest->response()->header( 'X-Device: ' . $_SERVER['HTTP_X_DEVICE'] ); |
731 | 735 | $wgOut->addVaryHeader( 'X-Device' ); |
732 | 736 | } |
— | — | @@ -737,11 +741,11 @@ |
738 | 742 | private function sendApplicationVersionVaryHeader() { |
739 | 743 | global $wgOut, $wgRequest; |
740 | 744 | wfProfileIn( __METHOD__ ); |
741 | | - if ( !empty( $_SERVER['HTTP_APPLICATION_VERSION'] ) ) { |
| 745 | + if ( isset( $_SERVER['HTTP_APPLICATION_VERSION'] ) ) { |
742 | 746 | $wgRequest->response()->header( 'Application_Version: ' . $_SERVER['HTTP_APPLICATION_VERSION'] ); |
743 | 747 | $wgOut->addVaryHeader( 'Application_Version' ); |
744 | 748 | } else { |
745 | | - if ( !empty( $_SERVER['HTTP_X_DEVICE'] ) ) { |
| 749 | + if ( isset( $_SERVER['HTTP_X_DEVICE'] ) ) { |
746 | 750 | if ( stripos( $_SERVER['HTTP_X_DEVICE'], 'iphone' ) !== false || |
747 | 751 | stripos( $_SERVER['HTTP_X_DEVICE'], 'android' ) !== false ) { |
748 | 752 | $wgRequest->response()->header( 'Application_Version: ' . $_SERVER['HTTP_X_DEVICE'] ); |
— | — | @@ -1212,7 +1216,7 @@ |
1213 | 1217 | if ( self::$title->isSpecial( 'Userlogin' ) && self::$isBetaGroupMember ) { |
1214 | 1218 | $userlogin = $this->doc->getElementById( 'userloginForm' ); |
1215 | 1219 | |
1216 | | - if ( !empty( $userlogin ) && get_class($userlogin) === 'DOMElement' ) { |
| 1220 | + if ( $userlogin && get_class( $userlogin ) === 'DOMElement' ) { |
1217 | 1221 | $firstHeading = $this->doc->getElementById( 'firstHeading' ); |
1218 | 1222 | if ( !empty( $firstHeading ) ) { |
1219 | 1223 | $firstHeading->nodeValue = ''; |
— | — | @@ -1303,7 +1307,7 @@ |
1304 | 1308 | } |
1305 | 1309 | |
1306 | 1310 | if ( self::$title->isSpecial( 'Userlogin' ) && self::$isBetaGroupMember ) { |
1307 | | - if ( !empty( $userlogin ) && get_class($userlogin) === 'DOMElement' ) { |
| 1311 | + if ( $userlogin && get_class( $userlogin ) === 'DOMElement' ) { |
1308 | 1312 | $login = $this->renderLogin(); |
1309 | 1313 | $loginNode = $this->doc->importNode( $login, true ); |
1310 | 1314 | $userlogin->appendChild( $loginNode ); |