Skip to content

Commit

Permalink
refs #5288 - include version number in cache keys, so old cache keys …
Browse files Browse the repository at this point in the history
…will not be used anymore as soon as the DD was updated to a new version
  • Loading branch information
sgiehl committed Nov 25, 2014
1 parent 4798e2b commit a76f214
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
7 changes: 6 additions & 1 deletion DeviceDetector.php
Expand Up @@ -18,6 +18,11 @@

class DeviceDetector
{
/**
* Current version number of DeviceDetector
*/
const VERSION = '2.7';

/**
* Holds all registered client types
* @var array
Expand Down Expand Up @@ -543,7 +548,7 @@ static public function getInfoFromUserAgent($ua)
$processed = array(
'user_agent' => $deviceDetector->getUserAgent(),
'os' => $deviceDetector->getOs(),
'client' => $deviceDetector->getClient(),
'client' => $deviceDetector->getClient(),
'device' => array(
'type' => $deviceDetector->getDeviceName(),
'brand' => $deviceDetector->getBrand(),
Expand Down
5 changes: 3 additions & 2 deletions Parser/ParserAbstract.php
Expand Up @@ -9,6 +9,7 @@

use DeviceDetector\Cache\CacheInterface;
use DeviceDetector\Cache\CacheStatic;
use DeviceDetector\DeviceDetector;
use \Spyc;

/**
Expand Down Expand Up @@ -140,7 +141,7 @@ public function getName()
protected function getRegexes()
{
if (empty($this->regexList)) {
$cacheKey = 'DeviceDetector-regexes-'.$this->getName();
$cacheKey = 'DeviceDetector-'.DeviceDetector::VERSION.'regexes-'.$this->getName();
$cacheKey = preg_replace('/([^a-z0-9_-]+)/i', '', $cacheKey);
$this->regexList = $this->getCache()->get($cacheKey);
if (empty($this->regexList)) {
Expand Down Expand Up @@ -227,7 +228,7 @@ protected function preMatchOverall()

static $overAllMatch;

$cacheKey = $this->parserName.'-all';
$cacheKey = $this->parserName.DeviceDetector::VERSION.'-all';
$cacheKey = preg_replace('/([^a-z0-9_-]+)/i', '', $cacheKey);

if (empty($overAllMatch)) {
Expand Down

0 comments on commit a76f214

Please sign in to comment.