From fa4ae23332189ec1e2e9a5eff47d80a82fbb27cf Mon Sep 17 00:00:00 2001
From: sgiehl <stefan@piwik.org>
Date: Mon, 19 Jan 2015 00:17:29 +0100
Subject: [PATCH] fixed device detector cache; added fallback for old windows
 short codes

---
 core/DeviceDetectorCache.php           | 27 +++++++++++++++++++++++---
 plugins/DevicesDetection/Visitor.php   |  2 +-
 plugins/DevicesDetection/functions.php | 13 +++++++++++++
 3 files changed, 38 insertions(+), 4 deletions(-)

diff --git a/core/DeviceDetectorCache.php b/core/DeviceDetectorCache.php
index c337b1b0a4..bd66523519 100644
--- a/core/DeviceDetectorCache.php
+++ b/core/DeviceDetectorCache.php
@@ -18,7 +18,7 @@ use Exception;
  *
  * Static caching speeds up multiple detections in one request, which is the case when sending bulk requests
  */
-class DeviceDetectorCache implements \DeviceDetector\Cache\CacheInterface
+class DeviceDetectorCache implements \DeviceDetector\Cache\Cache
 {
     protected static $staticCache = array();
 
@@ -37,7 +37,7 @@ class DeviceDetectorCache implements \DeviceDetector\Cache\CacheInterface
      * @param string $id The cache entry ID
      * @return array|bool  False on error, or array the cache content
      */
-    public function get($id)
+    public function fetch($id)
     {
         if (empty($id)) {
             return false;
@@ -58,7 +58,7 @@ class DeviceDetectorCache implements \DeviceDetector\Cache\CacheInterface
      * @throws \Exception
      * @return bool  True if the entry was succesfully stored
      */
-    public function set($id, $content)
+    public function save($id, $content, $ttl=0)
     {
         if (empty($id)) {
             return false;
@@ -69,4 +69,25 @@ class DeviceDetectorCache implements \DeviceDetector\Cache\CacheInterface
         return $this->cache->save($id, $content, $this->ttl);
     }
 
+    public function contains($id)
+    {
+        return !empty(self::$staticCache[$id]) && $this->cache->contains($id);
+    }
+
+    public function delete($id)
+    {
+        if (empty($id)) {
+            return false;
+        }
+
+        unset(self::$staticCache[$id]);
+
+        return $this->cache->delete($id);
+    }
+
+    public function flushAll()
+    {
+        return $this->cache->flushAll();
+    }
+
 }
diff --git a/plugins/DevicesDetection/Visitor.php b/plugins/DevicesDetection/Visitor.php
index aa5b16c2ae..63e67a53a4 100644
--- a/plugins/DevicesDetection/Visitor.php
+++ b/plugins/DevicesDetection/Visitor.php
@@ -31,7 +31,7 @@ class Visitor
 
     public function getOperatingSystem()
     {
-        return getOsFullName($this->details['config_os']);
+        return getOsFullName($this->details['config_os'] . ";" . $this->details['config_os_version']);
     }
 
     public function getOperatingSystemIcon()
diff --git a/plugins/DevicesDetection/functions.php b/plugins/DevicesDetection/functions.php
index 8ab0ffe925..1aff9a6fb7 100644
--- a/plugins/DevicesDetection/functions.php
+++ b/plugins/DevicesDetection/functions.php
@@ -240,6 +240,19 @@ function _mapLegacyOsShortCodes($shortCode)
         'DSI' => 'NDS', // Nintendo DSi => Nintendo Mobile
         'PSV' => 'PSP', // PlayStation Vita => PlayStation Portable
         'MAE' => 'SMG', // Maemo => MeeGo
+        'W10' => 'WIN',
+        'W2K' => 'WIN',
+        'W31' => 'WIN',
+        'WI7' => 'WIN',
+        'WI8' => 'WIN',
+        'W81' => 'WIN',
+        'W95' => 'WIN',
+        'W98' => 'WIN',
+        'WME' => 'WIN',
+        'WNT' => 'WIN',
+        'WS3' => 'WIN',
+        'WVI' => 'WIN',
+        'WXP' => 'WIN',
         //'VMS' => '', // OpenVMS => ??
     );
     return array_key_exists($shortCode, $legacyShortCodes) ? $legacyShortCodes[$shortCode] : $shortCode;
-- 
GitLab