mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-09-07 20:12:42 +00:00
Handle negative numbers in Redis correctly.
Update number sniff to handle negative numbers. We need to do number sniffing so we can maintain compatbility between write() and increment()/decrement(). Refs #8364
This commit is contained in:
parent
eae7a8926b
commit
3ed321dff4
2 changed files with 19 additions and 3 deletions
|
@ -133,11 +133,11 @@ class RedisEngine extends CacheEngine {
|
|||
*/
|
||||
public function read($key) {
|
||||
$value = $this->_Redis->get($key);
|
||||
if (ctype_digit($value)) {
|
||||
$value = (int)$value;
|
||||
if (preg_match('/^[-]?\d+$/', $value)) {
|
||||
return (int)$value;
|
||||
}
|
||||
if ($value !== false && is_string($value)) {
|
||||
$value = unserialize($value);
|
||||
return unserialize($value);
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue