Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: Phalcon\Storage\Serializer\Igbinary not saving is_numeric()/bool values #15240

Closed
Aphexx opened this issue Dec 25, 2020 · 1 comment · Fixed by #15342
Closed

[BUG]: Phalcon\Storage\Serializer\Igbinary not saving is_numeric()/bool values #15240

Aphexx opened this issue Dec 25, 2020 · 1 comment · Fixed by #15342
Labels
5.0 The issues we want to solve in the 5.0 release bug A bug report status: medium Medium

Comments

@Aphexx
Copy link

Aphexx commented Dec 25, 2020

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.

if !this->isSerializable(this->data) {

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 to igbinary_unserialize() and cache->get() returns null.

POC

$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

image

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

@niden niden added 4.1.1 The issues we want to solve in the 4.1.1 release bug A bug report status: medium Medium labels Jan 5, 2021
@niden niden linked a pull request Mar 26, 2021 that will close this issue
5 tasks
@niden niden added this to Working on it in Phalcon Roadmap Mar 26, 2021
@niden
Copy link
Sponsor Member

niden commented Mar 26, 2021

@Aphexx Thank you for reporting this.

Resolved in #15342

@niden niden closed this as completed Mar 26, 2021
Phalcon Roadmap automation moved this from Working on it to Implemented Mar 26, 2021
@Jeckerson Jeckerson added 5.0 The issues we want to solve in the 5.0 release and removed 4.1.1 The issues we want to solve in the 4.1.1 release labels Mar 26, 2021
@niden niden moved this from Implemented to Released in Phalcon Roadmap Mar 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
5.0 The issues we want to solve in the 5.0 release bug A bug report status: medium Medium
Projects
Archived in project
Phalcon Roadmap
  
Released
Development

Successfully merging a pull request may close this issue.

3 participants