From d523014918d95c149244370fc5899327af5f55d4 Mon Sep 17 00:00:00 2001 From: hisorange Date: Sun, 8 Dec 2013 05:21:18 +0100 Subject: [PATCH] Fix import mechanism Fix the case where importing datas and query the current agent in the same request. Also now it does not perform self analize before importing data. --- composer.json | 2 +- src/hisorange/browserdetect/Manager.php | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index c422b98..6461f60 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "hisorange/browser-detect", "description": "Browser & Mobile detection package for Laravel.", - "version": "0.9.1", + "version": "0.9.2", "keywords": ["laravel", "user-agent", "browser", "mobile", "tablet", "user agent"], "license": "MIT", "authors": [ diff --git a/src/hisorange/browserdetect/Manager.php b/src/hisorange/browserdetect/Manager.php index 507a292..efef9b5 100644 --- a/src/hisorange/browserdetect/Manager.php +++ b/src/hisorange/browserdetect/Manager.php @@ -31,7 +31,7 @@ class Manager { * * @type array */ - protected $results; + protected $results = array(); /** * Key translations for Browscap. @@ -119,7 +119,7 @@ public function getInfo() } // If the user agent not analized yet. - if ( ! isset($this->results[$this->ua])) { + if ( ! array_key_exists($this->ua, $this->results)) { // Try to load it from the cache if allowed. if (Config::get('browser-detect::cache', false)) { // Generate cache key by prefix_md5_hashed_user_agent_string @@ -353,6 +353,11 @@ protected function _mdFetcher($md, $list) */ public function __call($method, $params) { + // Importing the info. + if (substr($method, 0, 6) == 'import') { + return new Info($params[0]); + } + $info = $this->getInfo(); // Check for browser data.