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:
authorsgiehl <stefan@piwik.org>2014-06-08 21:51:46 +0400
committersgiehl <stefan@piwik.org>2014-06-08 21:51:46 +0400
commit6229e8ff5403b004e5994cf02d6721367474d17e (patch)
treebb99e41d8c3a6965439063d9307c095467cab6e2 /core/Tracker/Settings.php
parent08537777dacbc8888b2ff4b2bde29480d89a83a6 (diff)
introduce devicedetector factory to get singleton instances of devicedetector based on the given user agent. That provides the possibility to reuse DeviceDetector for bot and visitor data detection.
Diffstat (limited to 'core/Tracker/Settings.php')
-rw-r--r--core/Tracker/Settings.php14
1 files changed, 2 insertions, 12 deletions
diff --git a/core/Tracker/Settings.php b/core/Tracker/Settings.php
index 65bb17fb94..08d4341d20 100644
--- a/core/Tracker/Settings.php
+++ b/core/Tracker/Settings.php
@@ -9,6 +9,7 @@
namespace Piwik\Tracker;
use Piwik\DeviceDetectorCache;
+use Piwik\DeviceDetectorFactory;
use Piwik\Tracker;
use DeviceDetector\DeviceDetector;
@@ -37,18 +38,7 @@ class Settings
$resolution = $this->request->getParam('res');
$userAgent = $this->request->getUserAgent();
- static $deviceDetectorsCache = array();
- if (array_key_exists($userAgent, $deviceDetectorsCache)) {
- $deviceDetector = $deviceDetectorsCache[$userAgent];
- }
- else {
- $deviceDetector = new DeviceDetector($userAgent);
- $deviceDetector->discardBotInformation();
- $deviceDetector->setCache(new DeviceDetectorCache('tracker', 86400));
- $deviceDetector->parse();
-
- $deviceDetectorsCache[$userAgent] = $deviceDetector;
- }
+ $deviceDetector = DeviceDetectorFactory::getInstance($userAgent);
$aBrowserInfo = $deviceDetector->getClient();
if ($aBrowserInfo['type'] != 'browser') {