Skip to content
Permalink
Browse files

Removed all occurences of crc32 in dbo_source as a cache key,

 which is not only a stupid idea but should be actually considered a bug!
It does collide with a .1% propability for every 1.6mio queries processed
(which is not to uncommon in a shell process).
  • Loading branch information...
hmic committed Aug 23, 2014
1 parent 3c64a7b commit 72105c2487d9235c400210ad8dc52b909dccb943
Showing with 4 additions and 4 deletions.
  1. +4 −4 cake/libs/model/datasources/dbo_source.php
@@ -54,7 +54,7 @@ class DboSource extends DataSource {
/**
* Caches result from query parsing operations. Cached results for both DboSource::name() and
* DboSource::conditions() will be stored here. Method caching uses `crc32()` which is
* DboSource::conditions() will be stored here. Method caching uses `md5()` which is
* fast but can collisions more easily than other hashing algorithms. If you have problems
* with collisions, set DboSource::$cacheMethods to false.
*
@@ -538,7 +538,7 @@ function name($data) {
}
return $data;
}
$cacheKey = crc32($this->startQuote.$data.$this->endQuote);
$cacheKey = md5($this->startQuote.$data.$this->endQuote);
if ($return = $this->cacheMethod(__FUNCTION__, $cacheKey)) {
return $return;
}
@@ -1972,7 +1972,7 @@ function fields(&$model, $alias = null, $fields = array(), $quote = true) {
$fields,
$quote
);
$cacheKey = crc32(serialize($cacheKey));
$cacheKey = md5(serialize($cacheKey));
if ($return = $this->cacheMethod(__FUNCTION__, $cacheKey)) {
return $return;
}
@@ -2098,7 +2098,7 @@ function conditions($conditions, $quoteValues = true, $where = true, $model = nu
} else {
$cacheKey = array($conditions, $quoteValues, $where);
}
$cacheKey = crc32(serialize($cacheKey));
$cacheKey = md5(serialize($cacheKey));
if ($return = $this->cacheMethod(__FUNCTION__, $cacheKey)) {
return $return;
}

0 comments on commit 72105c2

Please sign in to comment.
You can’t perform that action at this time.