r105337 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r105336‎ | r105337 | r105338 >
Date:19:28, 6 December 2011
Author:preilly
Status:ok
Tags:
Comment:
1.18wmf1: MFT r105206 - r105333
Modified paths:
  • /branches/wmf/1.18wmf1/extensions/MobileFrontend/MobileFrontend.php (modified) (history)

Diff [purge]

Index: branches/wmf/1.18wmf1/extensions/MobileFrontend/MobileFrontend.php
@@ -88,7 +88,7 @@
8989 }
9090
9191 class ExtMobileFrontend {
92 - const VERSION = '0.5.91';
 92+ const VERSION = '0.5.95';
9393
9494 /**
9595 * @var DOMDocument
@@ -443,14 +443,13 @@
444444 // Thus, globalized objects will not be available as expected in the function.
445445 // This is stated to be intended behavior, as per the following: [http://bugs.php.net/bug.php?id=40104]
446446
447 - $xDevice = !empty( $_SERVER['HTTP_X_DEVICE'] ) ? $_SERVER['HTTP_X_DEVICE'] : '';
 447+ $xDevice = isset( $_SERVER['HTTP_X_DEVICE'] ) ? $_SERVER['HTTP_X_DEVICE'] : '';
448448 self::$useFormat = $wgRequest->getText( 'useformat' );
449449 $mobileAction = $wgRequest->getText( 'mobileaction' );
450450 $action = $wgRequest->getText( 'action' );
451451
452 - if ( self::$useFormat === 'mobile' ||
453 - self::$useFormat === 'mobile-wap' ||
454 - !empty( $xDevice ) ) {
 452+ if ( self::$useFormat === 'mobile' || self::$useFormat === 'mobile-wap' ||
 453+ $xDevice ) {
455454 if ( $action !== 'edit' &&
456455 $mobileAction !== 'view_normal_site' ) {
457456
@@ -497,10 +496,10 @@
498497 self::$search = $wgRequest->getText( 'search' );
499498 self::$searchField = $wgRequest->getText( 'search', '' );
500499
501 - $acceptHeader = !empty( $_SERVER["HTTP_ACCEPT"] ) ? $_SERVER["HTTP_ACCEPT"] : '';
 500+ $acceptHeader = isset( $_SERVER["HTTP_ACCEPT"] ) ? $_SERVER["HTTP_ACCEPT"] : '';
502501 $device = new DeviceDetection();
503502
504 - if ( !empty( $xDevice ) ) {
 503+ if ( $xDevice ) {
505504 $formatName = $xDevice;
506505 } else {
507506 $formatName = $device->formatName( $userAgent, $acceptHeader );
@@ -589,9 +588,14 @@
590589
591590 if ( self::$title->isSpecial( 'Userlogin' ) && self::$isBetaGroupMember ) {
592591 self::$wsLoginToken = $wgRequest->getSessionData( 'wsLoginToken' );
 592+ $q = array( 'action' => 'submitlogin', 'type' => 'login' );
593593 $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 );
596600 }
597601
598602 $this->setDefaultLogo();
@@ -618,7 +622,7 @@
619623 $wgRequest->response()->setcookie( 'mfsecure', '1', 0, '' );
620624 } else {
621625 $mfSecure = $wgRequest->getCookie( 'mfsecure', '' );
622 - if ( !empty( $mfSecure ) && $mfSecure == '1' ) {
 626+ if ( $mfSecure && $mfSecure == '1' ) {
623627 $wgRequest->response()->setcookie( 'mfsecure', '', 0, '' );
624628 }
625629 }
@@ -725,7 +729,7 @@
726730 private function sendXDeviceVaryHeader() {
727731 global $wgOut, $wgRequest;
728732 wfProfileIn( __METHOD__ );
729 - if ( !empty( $_SERVER['HTTP_X_DEVICE'] ) ) {
 733+ if ( isset( $_SERVER['HTTP_X_DEVICE'] ) ) {
730734 $wgRequest->response()->header( 'X-Device: ' . $_SERVER['HTTP_X_DEVICE'] );
731735 $wgOut->addVaryHeader( 'X-Device' );
732736 }
@@ -737,11 +741,11 @@
738742 private function sendApplicationVersionVaryHeader() {
739743 global $wgOut, $wgRequest;
740744 wfProfileIn( __METHOD__ );
741 - if ( !empty( $_SERVER['HTTP_APPLICATION_VERSION'] ) ) {
 745+ if ( isset( $_SERVER['HTTP_APPLICATION_VERSION'] ) ) {
742746 $wgRequest->response()->header( 'Application_Version: ' . $_SERVER['HTTP_APPLICATION_VERSION'] );
743747 $wgOut->addVaryHeader( 'Application_Version' );
744748 } else {
745 - if ( !empty( $_SERVER['HTTP_X_DEVICE'] ) ) {
 749+ if ( isset( $_SERVER['HTTP_X_DEVICE'] ) ) {
746750 if ( stripos( $_SERVER['HTTP_X_DEVICE'], 'iphone' ) !== false ||
747751 stripos( $_SERVER['HTTP_X_DEVICE'], 'android' ) !== false ) {
748752 $wgRequest->response()->header( 'Application_Version: ' . $_SERVER['HTTP_X_DEVICE'] );
@@ -1212,7 +1216,7 @@
12131217 if ( self::$title->isSpecial( 'Userlogin' ) && self::$isBetaGroupMember ) {
12141218 $userlogin = $this->doc->getElementById( 'userloginForm' );
12151219
1216 - if ( !empty( $userlogin ) && get_class($userlogin) === 'DOMElement' ) {
 1220+ if ( $userlogin && get_class( $userlogin ) === 'DOMElement' ) {
12171221 $firstHeading = $this->doc->getElementById( 'firstHeading' );
12181222 if ( !empty( $firstHeading ) ) {
12191223 $firstHeading->nodeValue = '';
@@ -1303,7 +1307,7 @@
13041308 }
13051309
13061310 if ( self::$title->isSpecial( 'Userlogin' ) && self::$isBetaGroupMember ) {
1307 - if ( !empty( $userlogin ) && get_class($userlogin) === 'DOMElement' ) {
 1311+ if ( $userlogin && get_class( $userlogin ) === 'DOMElement' ) {
13081312 $login = $this->renderLogin();
13091313 $loginNode = $this->doc->importNode( $login, true );
13101314 $userlogin->appendChild( $loginNode );

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r105206fix use of __toString to check if is Userloginpreilly19:05, 5 December 2011
r105333More empty removalsdemon18:52, 6 December 2011

Status & tagging log