MaxSem has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/103658


Change subject: Add variable to disable WAP
......................................................................

Add variable to disable WAP

Change-Id: I429484b9687ff09ce43eae3d89b6d7c91338ea99
---
M MobileFrontend.php
M includes/MobileFrontend.hooks.php
M includes/formatters/MobileFormatter.php
M includes/skins/SkinMobile.php
4 files changed, 25 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend 
refs/changes/58/103658/1

diff --git a/MobileFrontend.php b/MobileFrontend.php
index 7c8b9de..388b9ca 100644
--- a/MobileFrontend.php
+++ b/MobileFrontend.php
@@ -435,3 +435,16 @@
  * Controls whether new 1-column diffs should be used
  */
 $wgMFEnableBetaDiff = false;
+
+/**
+ * Controls the use of WAP view. Possible values:
+ *   enabled      - WAP is enabled;
+ *   transitional - disabled but output still varied by X-WAP and requests 
with X-WAP: yes have shorter expiry time;
+ *   disabled     - WAP is disabled;
+ */
+$wgMFWap = 'enabled';
+
+/**
+ * Maximum HTTP lifetime for page views with $wgMFWap = 'transitional'
+ */
+$wgMFTransitionalWapLifetime = 3 * 86400;
diff --git a/includes/MobileFrontend.hooks.php 
b/includes/MobileFrontend.hooks.php
index 9bd19e3..35da4ee 100644
--- a/includes/MobileFrontend.hooks.php
+++ b/includes/MobileFrontend.hooks.php
@@ -41,7 +41,7 @@
         * @return bool
         */
        public static function onRequestContextCreateSkin( $context, &$skin ) {
-               global $wgMFEnableDesktopResources, $wgMFDefaultSkinClass, 
$wgULSPosition;
+               global $wgMFEnableDesktopResources, $wgMFDefaultSkinClass, 
$wgULSPosition, $wgMFWap;
 
                // check whether or not the user has requested to toggle their 
view
                $mobileContext = MobileContext::singleton();
@@ -78,7 +78,7 @@
                // log whether user is using alpha/beta/stable
                $mobileContext->logMobileMode();
 
-               if ( $mobileContext->getContentFormat() == 'WML' ) {
+               if ( $mobileContext->getContentFormat() == 'WML' && $wgMFWap == 
'enabled' ) {
                        # Grab the skin class and initialise it.
                        $skin = new SkinMobileWML( $context );
                } else {
diff --git a/includes/formatters/MobileFormatter.php 
b/includes/formatters/MobileFormatter.php
index 4bb2304..314d371 100644
--- a/includes/formatters/MobileFormatter.php
+++ b/includes/formatters/MobileFormatter.php
@@ -48,6 +48,8 @@
         * @return MobileFormatter
         */
        public static function newFromContext( $context, $html ) {
+               global $wgMFWap;
+
                wfProfileIn( __METHOD__ );
 
                $title = $context->getTitle();
@@ -56,7 +58,7 @@
                $isSpecialPage = $title->isSpecialPage();
 
                $html = self::wrapHTML( $html );
-               if ( $context->getContentFormat() === 'WML' ) {
+               if ( $context->getContentFormat() === 'WML' && $wgMFWap === 
'enabled' ) {
                        $wmlContext = new WmlContext( $context );
                        $formatter = new MobileFormatterWML( $html, $title, 
$wmlContext );
                } else {
diff --git a/includes/skins/SkinMobile.php b/includes/skins/SkinMobile.php
index dd19524..0757f1f 100644
--- a/includes/skins/SkinMobile.php
+++ b/includes/skins/SkinMobile.php
@@ -15,7 +15,7 @@
        }
 
        public function outputPage( OutputPage $out = null ) {
-               global $wgMFNoindexPages;
+               global $wgMFNoindexPages, $wgMFWap, 
$wgMFTransitionalWapLifetime;
                wfProfileIn( __METHOD__ );
                if ( !$out ) {
                        $out = $this->getOutput();
@@ -25,6 +25,12 @@
                }
 
                wfRunHooks( 'BeforePageDisplayMobile', array( &$out ) );
+
+               # Restrict cache lifetime for potentially WAPy requests during 
the transitional period
+               if ( $wgMFWap == 'transitional' ) {
+                       $out->setSquidMaxage( min( $out->mSquidMaxage, 
$wgMFTransitionalWapLifetime ) );
+               }
+
                parent::outputPage( $out );
        }
 

-- 
To view, visit https://gerrit.wikimedia.org/r/103658
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I429484b9687ff09ce43eae3d89b6d7c91338ea99
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: MaxSem <[email protected]>

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

Reply via email to