Bmansurov has uploaded a new change for review.
https://gerrit.wikimedia.org/r/278408
Change subject: Do not redirect Samsung TV browser to mobile site
......................................................................
Do not redirect Samsung TV browser to mobile site
Bug: T127021
Change-Id: I2e72c86e6ecf6ff5299fa520fa542265c8db87e5
---
M includes/DeviceDetection.php
M tests/phpunit/DeviceDetectionTest.php
2 files changed, 14 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend
refs/changes/08/278408/1
diff --git a/includes/DeviceDetection.php b/includes/DeviceDetection.php
index b98aa90..c1afd77 100644
--- a/includes/DeviceDetection.php
+++ b/includes/DeviceDetection.php
@@ -176,6 +176,17 @@
$regex = '/^(' . implode( '|', $patternsStart ) . ')|(' .
implode( '|', $patterns ) . ')/i';
$isMobile = (bool)preg_match( $regex, $this->userAgent );
+ if ( $isMobile ) {
+ // Ignore the following patterns
+ $patternsIgnore = array(
+ 'SMART-TV.*SamsungBrowser'
+ );
+ $regex = '/(' . implode( '|', $patternsIgnore ) . ')/';
+ if ( preg_match( $regex, $this->userAgent ) ) {
+ $isMobile = false;
+ }
+ }
+
return $isMobile;
}
diff --git a/tests/phpunit/DeviceDetectionTest.php
b/tests/phpunit/DeviceDetectionTest.php
index 1ccdd39..7dba814 100644
--- a/tests/phpunit/DeviceDetectionTest.php
+++ b/tests/phpunit/DeviceDetectionTest.php
@@ -110,6 +110,7 @@
array( true, 'DoCoMo/2.0 P07A3(c500;TB;W24H15)'
),
array( true, 'KDDI-HI31 UP.Browser/6.2.0.5
(GUI) MMP/2.0' ),
array( true, 'Mozilla/4.0 (compatible; MSIE
6.0; KDDI-SA39) Opera 8.60 [ja]' ),
+ array( true, 'Mozilla/5.0 (Linux; Android
4.2.2; nl-nl; SAMSUNG GT-I9505 Build/JDQ39) AppleWebKit/535.19 (KHTML, like
Gecko) Version/1.0 Chrome/18.0.1025.308 Mobile Safari/535.19'),
// ...and some desktop browsers
array( false, 'Mozilla/5.0 (X11; U; Linux i686;
en-US; rv:1.8.0.7) Gecko/20060928 (Debian|Debian-1.8.0.7-1) Epiphany/2.14' ),
array( false, 'Mozilla/4.0 (compatible; MSIE
8.0; Windows NT 6.0)' ),
@@ -128,6 +129,8 @@
array( false, 'Mozilla/5.0 (compatible;
googlebot/2.1; +http://www.google.com/bot.html)' ),
array( false, 'Wget/1.9' ),
array( false, 'Mozilla/5.0 (compatible;
YandexBot/3.0)' ),
+ // ... and some TV browsers
+ array( false, 'Mozilla/5.0 (SMART-TV; Linux;
Tizen 2.3) AppleWebkit/538.1 (KHTML, like Gecko) SamsungBrowser/1.0 TV
Safari/538.1' ),
)
);
// @codingStandardsIgnoreEnd
--
To view, visit https://gerrit.wikimedia.org/r/278408
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I2e72c86e6ecf6ff5299fa520fa542265c8db87e5
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Bmansurov <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits