Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/Tracker/Settings.php16
1 files changed, 12 insertions, 4 deletions
diff --git a/core/Tracker/Settings.php b/core/Tracker/Settings.php
index 3e2a289e0a..8c8ff1a773 100644
--- a/core/Tracker/Settings.php
+++ b/core/Tracker/Settings.php
@@ -11,6 +11,7 @@ namespace Piwik\Tracker;
use Piwik\DeviceDetectorCache;
use Piwik\Tracker;
use DeviceDetector\DeviceDetector;
+use DeviceDetector\Cache\CacheStatic;
class Settings
{
@@ -37,10 +38,17 @@ class Settings
$resolution = $this->request->getParam('res');
$userAgent = $this->request->getUserAgent();
- $deviceDetector = new DeviceDetector($userAgent);
- $deviceDetector->discardBotInformation();
- $deviceDetector->setCache(new DeviceDetectorCache('tracker', 86400));
- $deviceDetector->parse();
+ static $deviceDetectorsCache;
+ $deviceDetectorsCache = new CacheStatic();
+ $deviceDetector = $deviceDetectorsCache->get($userAgent);
+ if (! $deviceDetector) {
+ $deviceDetector = new DeviceDetector($userAgent);
+ $deviceDetector->discardBotInformation();
+ $deviceDetector->setCache(new DeviceDetectorCache('tracker', 86400));
+ $deviceDetector->parse();
+
+ $deviceDetectorsCache->set($userAgent, $deviceDetector);
+ }
$aBrowserInfo = $deviceDetector->getClient();
if ($aBrowserInfo['type'] != 'browser') {