diff --git a/composer.lock b/composer.lock index a9822dc62a1..a440208ae18 100644 --- a/composer.lock +++ b/composer.lock @@ -100,12 +100,12 @@ "source": { "type": "git", "url": "https://github.com/piwik/device-detector.git", - "reference": "d3ccb7938fa272a857c279850ffbb3d8fe04c0b7" + "reference": "863ae43f5c68c15ce110516a0f7b11477e2a01c0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/piwik/device-detector/zipball/d3ccb7938fa272a857c279850ffbb3d8fe04c0b7", - "reference": "d3ccb7938fa272a857c279850ffbb3d8fe04c0b7", + "url": "https://api.github.com/repos/piwik/device-detector/zipball/863ae43f5c68c15ce110516a0f7b11477e2a01c0", + "reference": "863ae43f5c68c15ce110516a0f7b11477e2a01c0", "shasum": "" }, "require": { @@ -139,7 +139,7 @@ "parser", "useragent" ], - "time": "2014-05-25 17:45:14" + "time": "2014-05-29 20:51:28" }, { "name": "symfony/console", diff --git a/core/CacheFile.php b/core/CacheFile.php index 5d9000332f7..f75657f1762 100644 --- a/core/CacheFile.php +++ b/core/CacheFile.php @@ -16,7 +16,7 @@ * It is for example used by the Tracker process to cache various settings and websites attributes in tmp/cache/tracker/* * */ -class CacheFile +class CacheFile implements \DeviceDetector\Cache\CacheInterface { // for testing purposes since tests run on both CLI/FPM (changes in CLI can't invalidate // opcache in FPM, so we have to invalidate before reading) diff --git a/core/Tracker/Settings.php b/core/Tracker/Settings.php index 3eed338f3ba..251046ca298 100644 --- a/core/Tracker/Settings.php +++ b/core/Tracker/Settings.php @@ -38,8 +38,10 @@ protected function loadInfo() $userAgent = $this->request->getUserAgent(); $deviceDetector = new DeviceDetector($userAgent); - #$deviceDetector->setCache(new CacheFile('tracker', 86400)); + $deviceDetector->discardBotInformation(); + $deviceDetector->setCache(new CacheFile('tracker', 86400)); $deviceDetector->parse(); + $aBrowserInfo = $deviceDetector->getClient(); if ($aBrowserInfo['type'] != 'browser') { // for now only track browsers @@ -49,8 +51,12 @@ protected function loadInfo() $browserName = !empty($aBrowserInfo['short_name']) ? $aBrowserInfo['short_name'] : 'UNK'; $browserVersion = !empty($aBrowserInfo['version']) ? $aBrowserInfo['version'] : ''; - $os = $deviceDetector->getOS(); - $os = empty($os['short_name']) ? 'UNK' : $os['short_name']; + if ($deviceDetector->isBot()) { + $os = 'BOT'; + } else { + $os = $deviceDetector->getOS(); + $os = empty($os['short_name']) ? 'UNK' : $os['short_name']; + } $browserLang = substr($this->request->getBrowserLanguage(), 0, 20); // limit the length of this string to match db $configurationHash = $this->getConfigHash( diff --git a/libs/UserAgentParser/UserAgentParser.php b/libs/UserAgentParser/UserAgentParser.php index c0c8fea1ce1..009bc5a7853 100644 --- a/libs/UserAgentParser/UserAgentParser.php +++ b/libs/UserAgentParser/UserAgentParser.php @@ -694,6 +694,9 @@ static public function getOperatingSystemNameFromId($osId) } if(class_exists('DeviceDetector\\Parser\\OperatingSystem')) { + if ($osId == 'BOT') { + return 'Bot'; + } return DeviceDetector\Parser\OperatingSystem::getNameFromId($osId); } return false; diff --git a/piwik.php b/piwik.php index 00c2041a52e..03e405cdd94 100644 --- a/piwik.php +++ b/piwik.php @@ -40,6 +40,16 @@ @ignore_user_abort(true); +/* + * Manually require needed vendor libraries, as composers autorequire would do too much + */ +if (file_exists(PIWIK_INCLUDE_PATH . '/vendor/autoload.php')) { + $vendorDirectory = PIWIK_INCLUDE_PATH . '/vendor'; +} else { + $vendorDirectory = PIWIK_INCLUDE_PATH . '/../..'; +} +require_once $vendorDirectory . '/autoload.php'; + require_once PIWIK_INCLUDE_PATH . '/core/Plugin/Controller.php'; require_once PIWIK_INCLUDE_PATH . '/core/Plugin/ControllerAdmin.php'; @@ -82,16 +92,6 @@ require_once PIWIK_INCLUDE_PATH . '/core/Cookie.php'; require_once PIWIK_INCLUDE_PATH . '/core/Loader.php'; -/* - * Manually require needed vendor libraries, as composers autorequire would do too much - */ -if (file_exists(PIWIK_INCLUDE_PATH . '/vendor/autoload.php')) { - $vendorDirectory = PIWIK_INCLUDE_PATH . '/vendor'; -} else { - $vendorDirectory = PIWIK_INCLUDE_PATH . '/../..'; -} -require_once $vendorDirectory . '/autoload.php'; - session_cache_limiter('nocache'); @date_default_timezone_set('UTC'); diff --git a/plugins/DevicesDetection/DevicesDetection.php b/plugins/DevicesDetection/DevicesDetection.php index 5d6312e8f0a..9b8cf601d18 100644 --- a/plugins/DevicesDetection/DevicesDetection.php +++ b/plugins/DevicesDetection/DevicesDetection.php @@ -244,7 +244,7 @@ public function parseMobileVisitData(&$visitorInfo, \Piwik\Tracker\Request $requ $userAgent = $request->getUserAgent(); $UAParser = new DeviceDetector($userAgent); - #$UAParser->setCache(new CacheFile('tracker', 86400)); + $UAParser->setCache(new CacheFile('tracker', 86400)); $UAParser->parse(); $deviceInfo['config_browser_name'] = $UAParser->getClient("type") == 'browser' ? $UAParser->getClient("short_name") : 'UNK'; $deviceInfo['config_browser_version'] = $UAParser->getClient("type") == 'browser' ? $UAParser->getClient("version") : 'UNK'; diff --git a/plugins/DevicesDetection/functions.php b/plugins/DevicesDetection/functions.php index b8ff3a8854c..085a35814c9 100644 --- a/plugins/DevicesDetection/functions.php +++ b/plugins/DevicesDetection/functions.php @@ -165,6 +165,9 @@ function getModelName($label) function getOSFamilyFullNameExtended($label) { + if ($label == 'BOT') { + return 'Bot'; + } $label = OperatingSystemParser::getOsFamily($label); if($label !== false) { return $label; @@ -183,6 +186,9 @@ function getOsFamilyLogoExtended($label) function getOsFullNameExtended($label) { + if ($label == 'BOT') { + return 'Bot'; + } if (!empty($label) && $label != ";") { $os = substr($label, 0, 3); $ver = substr($label, 4, 15); diff --git a/tests/PHPUnit/bootstrap.php b/tests/PHPUnit/bootstrap.php index 1dcb995b0ea..c951e4a3c62 100644 --- a/tests/PHPUnit/bootstrap.php +++ b/tests/PHPUnit/bootstrap.php @@ -27,6 +27,9 @@ error_reporting(E_ALL | E_NOTICE); @date_default_timezone_set('UTC'); +require_once file_exists(PIWIK_INCLUDE_PATH . '/vendor/autoload.php') + ? PIWIK_INCLUDE_PATH . '/vendor/autoload.php' // Piwik is the main project + : PIWIK_INCLUDE_PATH . '/../../autoload.php'; // Piwik is installed as a dependency require_once PIWIK_INCLUDE_PATH . '/libs/upgradephp/upgrade.php'; require_once PIWIK_INCLUDE_PATH . '/core/testMinimumPhpVersion.php'; @@ -37,9 +40,6 @@ require_once PIWIK_INCLUDE_PATH . '/tests/PHPUnit/FakeAccess.php'; require_once PIWIK_INCLUDE_PATH . '/tests/PHPUnit/MockPiwikOption.php'; require_once PIWIK_INCLUDE_PATH . '/tests/PHPUnit/TestingEnvironment.php'; -require_once file_exists(PIWIK_INCLUDE_PATH . '/vendor/autoload.php') - ? PIWIK_INCLUDE_PATH . '/vendor/autoload.php' // Piwik is the main project - : PIWIK_INCLUDE_PATH . '/../../autoload.php'; // Piwik is installed as a dependency \Piwik\Profiler::setupProfilerXHProf( $mainRun = true ); diff --git a/tests/PHPUnit/proxy/includes.php b/tests/PHPUnit/proxy/includes.php index 0ffce4642b2..2ecb204244a 100644 --- a/tests/PHPUnit/proxy/includes.php +++ b/tests/PHPUnit/proxy/includes.php @@ -9,6 +9,10 @@ define('PIWIK_USER_PATH', PIWIK_INCLUDE_PATH); } +require_once file_exists(PIWIK_INCLUDE_PATH . '/vendor/autoload.php') + ? PIWIK_INCLUDE_PATH . '/vendor/autoload.php' // Piwik is the main project + : PIWIK_INCLUDE_PATH . '/../../autoload.php'; // Piwik is installed as a dependency + require_once PIWIK_INCLUDE_PATH . '/core/Loader.php'; require_once PIWIK_INCLUDE_PATH . '/core/EventDispatcher.php'; require_once PIWIK_INCLUDE_PATH . '/core/Piwik.php';