Describe the bug
The Igbinary serializer storage adapter is not saving bool and is_numeric() values, because of
isSerializable() check at Phalcon\Storage\Serializer\Igbinary->serialize() function.
$apcCache = new \Phalcon\Cache\Adapter\Apcu(new \Phalcon\Storage\SerializerFactory(), [
'defaultSerializer' => 'Igbinary',
]);
$key = 'cache-key';
$val = '100';
$apcCache->set($key, $val, 10);
var_dump($val); // 100
var_dump($this->apcCache->get($key)); // null <------- SHOULD BE SAME VALUE
// Correct cache save/retrieve with non numeric string
$val = 'i_am_string';
$apcCache->set($key, $val, 10);
var_dump($val); // i_am_string
var_dump($this->apcCache->get($key)); // i_am_string <---- correct behavior
Solution
All values should be serialized with igbinary_serialize(). Remove isSerializable() check from Phalcon\Storage\Serializer\Igbinary->serialize() function.
Details
Phalcon version: 4.1.0
PHP Version: PHP 7.3
Zephir version (if any): No
Describe the bug The Igbinary serializer storage adapter is not saving
bool
andis_numeric()
values, because ofisSerializable()
check atPhalcon\Storage\Serializer\Igbinary->serialize()
function.https://github.com/phalcon/cphalcon/blob/3241d96e4bb01dc7746b74c9ce586250b8887c46/phalcon/Storage/Serializer/Igbinary.zep#L20 isSerializable() function checks for is_numeric/boolean in value that need to be saved and skips
igbinary_serialize()
for it. After that raw value fails toigbinary_unserialize()
andcache->get()
returns null.POC
Solution All values should be serialized with
igbinary_serialize()
. RemoveisSerializable()
check fromPhalcon\Storage\Serializer\Igbinary->serialize()
function.Details Phalcon version: 4.1.0 PHP Version: PHP 7.3 Zephir version (if any): No