https://www.mediawiki.org/wiki/Special:Code/MediaWiki/114937
Revision: 114937
Author: awjrichards
Date: 2012-04-17 17:18:35 +0000 (Tue, 17 Apr 2012)
Log Message:
-----------
Fix for bug 36024, MFG Change-Id: I9676454ebd0c552ade4d375d3b1577c8f1568d7a
Modified Paths:
--------------
branches/wmf/1.19wmf1/extensions/MobileFrontend/MobileFrontend.body.php
branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/application.js
branches/wmf/1.19wmf1/extensions/MobileFrontend/templates/ApplicationTemplate.php
Modified:
branches/wmf/1.19wmf1/extensions/MobileFrontend/MobileFrontend.body.php
===================================================================
--- branches/wmf/1.19wmf1/extensions/MobileFrontend/MobileFrontend.body.php
2012-04-17 12:50:26 UTC (rev 114936)
+++ branches/wmf/1.19wmf1/extensions/MobileFrontend/MobileFrontend.body.php
2012-04-17 17:18:35 UTC (rev 114937)
@@ -961,10 +961,13 @@
'wgScriptPath' => $wgScriptPath,
'isFilePage' => $isFilePage,
'zeroRatedBanner' =>
self::$zeroRatedBanner,
- 'useFormatCookieName' =>
'stopMobileRedirect',
- 'useFormatCookieDuration' =>
$this->getUseFormatCookieDuration(),
+ 'stopMobileRedirectCookieName'
=> 'stopMobileRedirect',
+
'stopMobileRedirectCookieDuration' => $this->getUseFormatCookieDuration(),
+
'stopMobileRedirectCookieDomain' => $this->getBaseDomain(),
+ 'useFormatCookieName' =>
$this->getUseFormatCookieName(),
+ 'useFormatCookieDuration' => -1,
'useFormatCookiePath' =>
$wgCookiePath,
- 'useFormatCookieDomain' =>
$this->getBaseDomain(),
+ 'useFormatCookieDomain' =>
$_SERVER['HTTP_HOST'],
);
$applicationTemplate->setByArray( $options );
wfProfileOut( __METHOD__ );
@@ -1280,8 +1283,8 @@
}
// check cookies for what to display
- $useFormatCookie = $this->getUseFormatCookie();
- if ( $useFormatCookie == 'mobile' ) {
+ $useMobileFormat = $this->getUseFormatCookie();
+ if ( $useMobileFormat == 'true' ) {
return true;
}
$stopMobileRedirect = $this->getStopMobileRedirectCookie();
@@ -1392,7 +1395,7 @@
* @param int $string The expiration to set
* @param bool $force Whether or not to force the cookie getting set
*/
- public function setUseFormatCookie( $cookieFormat, $expiry = null,
$force = false ) {
+ public function setUseFormatCookie( $cookieFormat = 'true', $expiry =
null, $force = false ) {
global $wgCookiePath, $wgCookieSecure;
// sanity check before setting the cookie
@@ -1404,7 +1407,7 @@
$expiry = $this->getUseFormatCookieExpiry();
}
- setcookie( $this->getUseFormatCookieName(), $cookieFormat,
$expiry, $wgCookiePath, $this->getBaseDomain(), $wgCookieSecure );
+ setcookie( $this->getUseFormatCookieName(), $cookieFormat,
$expiry, $wgCookiePath, $_SERVER['HTTP_HOST'], $wgCookieSecure );
wfIncrStats( 'mobile.useformat_' . $cookieFormat .
'_cookie_set' );
}
@@ -1420,7 +1423,7 @@
public function getUseFormatCookieName() {
if ( !isset( self::$useFormatCookieName ) ) {
- self::$useFormatCookieName = 'mf_useformat';
+ self::$useFormatCookieName = 'mf_mobileFormat';
}
return self::$useFormatCookieName;
}
@@ -1506,7 +1509,7 @@
// if no mobileurl template, set mobile cookie
if ( !strlen( trim( $wgMobileUrlTemplate ) ) ) {
- if ( !$temporary ) $this->setUseFormatCookie(
$view );
+ if ( !$temporary ) $this->setUseFormatCookie();
$this->setUseFormat( $view );
} else {
// else redirect to mobile domain
@@ -1517,12 +1520,16 @@
}
} elseif ( $view == 'desktop' ) {
// set stopMobileRedirect cookie
- if ( !$temporary ) $this->setStopMobileRedirectCookie();
+ if ( !$temporary ) {
+ $this->setStopMobileRedirectCookie();
+ // unset useformat cookie
+ if ( $this->getUseFormatCookie() == "true" ) {
+ $this->unsetUseFormatCookie();
+ }
+ }
// if no mobileurl template, unset useformat cookie
if ( !strlen( trim( $wgMobileUrlTemplate ) ) ) {
- // unset useformat cookie
- if ( !$temporary )
$this->unsetUseFormatCookie();
$this->setUseFormat( $view );
} else {
// if mobileurl template, redirect to desktop
domain
Modified:
branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/application.js
===================================================================
--- branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/application.js
2012-04-17 12:50:26 UTC (rev 114936)
+++ branches/wmf/1.19wmf1/extensions/MobileFrontend/javascripts/application.js
2012-04-17 17:18:35 UTC (rev 114937)
@@ -36,16 +36,28 @@
utilities( document.getElementById( 'logo' ) ).bind( 'click',
logoClick );
function desktopViewClick() {
- var cookieName = MobileFrontend.setting(
'useFormatCookieName' );
- var cookieDuration = MobileFrontend.setting(
'useFormatCookieDuration' );
+ // get mf_mobileFormat cookie info
+ var formatCookieName = MobileFrontend.setting(
'useFormatCookieName' );
+ var formatCookieDuration = MobileFrontend.setting(
'useFormatCookieDuration' );
var cookiePath = MobileFrontend.setting(
'useFormatCookiePath' );
- var cookieDomain = MobileFrontend.setting(
'useFormatCookieDomain' );
-
+ var formatCookieDomain = MobileFrontend.setting(
'useFormatCookieDomain' );
+
// convert from seconds to days
- cookieDuration = cookieDuration / ( 24 * 60 * 60 );
+ formatCookieDuration = formatCookieDuration / ( 24 * 60
* 60 );
- // get the top part of the domain to make the cookie
work across subdomains
- MobileFrontend.banner.writeCookie( cookieName, 'true',
cookieDuration, cookiePath, cookieDomain );
+ // expire the mf_mobileFormat cookie
+ MobileFrontend.banner.writeCookie( formatCookieName,
'', formatCookieDuration, cookiePath, formatCookieDomain );
+
+ // get stopMobileRedirect cookie info
+ var stopMobileRedirectCookieName =
MobileFrontend.setting( 'stopMobileRedirectCookieName' );
+ var stopMobileRedirectCookieDuration =
MobileFrontend.setting( 'stopMobileRedirectCookieDuration' );
+ var stopMobileRedirectCookieDomain =
MobileFrontend.setting( 'stopMobileRedirectCookieDomain' );
+
+ // convert from seconds to days
+ stopMobileRedirectCookieDuration =
stopMobileRedirectCookieDuration / ( 24 * 60 *60 );
+
+ // set the stopMobileRedirect cookie
+ MobileFrontend.banner.writeCookie(
stopMobileRedirectCookieName, 'true', stopMobileRedirectCookieDuration,
cookiePath, stopMobileRedirectCookieDomain );
}
utilities( document.getElementById( 'mf-display-toggle' )
).bind( 'click', desktopViewClick );
Modified:
branches/wmf/1.19wmf1/extensions/MobileFrontend/templates/ApplicationTemplate.php
===================================================================
---
branches/wmf/1.19wmf1/extensions/MobileFrontend/templates/ApplicationTemplate.php
2012-04-17 12:50:26 UTC (rev 114936)
+++
branches/wmf/1.19wmf1/extensions/MobileFrontend/templates/ApplicationTemplate.php
2012-04-17 17:18:35 UTC (rev 114937)
@@ -50,6 +50,9 @@
'useFormatCookieDuration' => (
$this->data['useFormatCookieDuration'] ),
'useFormatCookieDomain' => (
$this->data['useFormatCookieDomain'] ),
'useFormatCookiePath' => (
$this->data['useFormatCookiePath'] ),
+ 'stopMobileRedirectCookieName' => (
$this->data['stopMobileRedirectCookieName'] ),
+ 'stopMobileRedirectCookieDuration' => (
$this->data['stopMobileRedirectCookieDuration'] ),
+ 'stopMobileRedirectCookieDomain' => (
$this->data['stopMobileRedirectCookieDomain'] ),
),
);
if ( $this->data['title']->isMainPage() ) {
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs