r113202 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r113201‎ | r113202 | r113203 >
Date:00:00, 7 March 2012
Author:awjrichards
Status:ok
Tags:
Comment:
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) (history)

Diff [purge]

Index: trunk/extensions/MobileFrontend/MobileFrontend.body.php
@@ -304,6 +304,9 @@
305305 }
306306
307307 /**
 308+ * Invocation of BeforePageRedirect hook.
 309+ *
 310+ * Ensures URLs are handled properly for select special pages.
308311 * @param $out OutputPage
309312 * @param $redirect
310313 * @param $code
@@ -311,21 +314,21 @@
312315 */
313316 public function beforePageRedirect( $out, &$redirect, &$code ) {
314317 wfProfileIn( __METHOD__ );
 318+
315319 $shouldDisplayMobileView = $this->shouldDisplayMobileView();
 320+ if ( !$shouldDisplayMobileView ) {
 321+ wfProfileOut( __METHOD__ );
 322+ return true;
 323+ }
 324+
316325 if ( $out->getTitle()->isSpecial( 'Userlogin' ) ) {
317 - if ( $shouldDisplayMobileView ) {
318 - $forceHttps = true;
319 - $redirect = $this->getMobileUrl( $redirect, $forceHttps );
320 - }
321 - } else if ( $out->getTitle()->isSpecial( 'Randompage' ) ) {
322 - if ( $shouldDisplayMobileView ) {
323 - $redirect = $this->getMobileUrl( $redirect );
324 - }
325 - } else if ( $out->getTitle()->isSpecial( 'Search' ) ) {
326 - if ( $shouldDisplayMobileView ) {
327 - $redirect = $this->getMobileUrl( $redirect );
328 - }
 326+ $forceHttps = true;
 327+ $redirect = $this->getMobileUrl( $redirect, $forceHttps );
 328+ } else if ( $out->getTitle()->isSpecial( 'Randompage' ) ||
 329+ $out->getTitle()->isSpecial( 'Search' ) ) {
 330+ $redirect = $this->getMobileUrl( $redirect );
329331 }
 332+
330333 wfProfileOut( __METHOD__ );
331334 return true;
332335 }

Status & tagging log