https://www.mediawiki.org/wiki/Special:Code/MediaWiki/113202

Revision: 113202
Author:   awjrichards
Date:     2012-03-07 00:00:24 +0000 (Wed, 07 Mar 2012)
Log Message:
-----------
Mild cleanup of beforePageRedirect() combining cases for Special:Randompage and 
Special:Search and added early return if we should not be displaying the mobile 
view. Also added some explanation to method comments.

Modified Paths:
--------------
    trunk/extensions/MobileFrontend/MobileFrontend.body.php

Modified: trunk/extensions/MobileFrontend/MobileFrontend.body.php
===================================================================
--- trunk/extensions/MobileFrontend/MobileFrontend.body.php     2012-03-06 
23:51:31 UTC (rev 113201)
+++ trunk/extensions/MobileFrontend/MobileFrontend.body.php     2012-03-07 
00:00:24 UTC (rev 113202)
@@ -304,6 +304,9 @@
        }
 
        /**
+        * Invocation of BeforePageRedirect hook.
+        * 
+        * Ensures URLs are handled properly for select special pages.
         * @param $out OutputPage
         * @param $redirect
         * @param $code
@@ -311,21 +314,21 @@
         */
        public function beforePageRedirect( $out, &$redirect, &$code ) {
                wfProfileIn( __METHOD__ );
+
                $shouldDisplayMobileView = $this->shouldDisplayMobileView();
+               if ( !$shouldDisplayMobileView ) {
+                       wfProfileOut( __METHOD__ );
+                       return true;
+               }
+
                if ( $out->getTitle()->isSpecial( 'Userlogin' ) ) {
-                       if ( $shouldDisplayMobileView ) {
-                               $forceHttps = true;
-                               $redirect = $this->getMobileUrl( $redirect, 
$forceHttps );
-                       }
-               } else if ( $out->getTitle()->isSpecial( 'Randompage' ) ) {
-                       if ( $shouldDisplayMobileView ) {
-                               $redirect = $this->getMobileUrl( $redirect );
-                       }
-               } else if ( $out->getTitle()->isSpecial( 'Search' ) ) {         
        
-                       if ( $shouldDisplayMobileView ) {
-                               $redirect = $this->getMobileUrl( $redirect );
-                       }
+                       $forceHttps = true;
+                       $redirect = $this->getMobileUrl( $redirect, $forceHttps 
);
+               } else if ( $out->getTitle()->isSpecial( 'Randompage' ) || 
+                               $out->getTitle()->isSpecial( 'Search' ) ) {
+                       $redirect = $this->getMobileUrl( $redirect );
                }
+               
                wfProfileOut( __METHOD__ );
                return true;
        }


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to