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]: AbstractSerializer isSuccess never getting reset to true #16040

Closed
ALameLlama opened this issue Aug 4, 2022 · 1 comment
Closed

[BUG]: AbstractSerializer isSuccess never getting reset to true #16040

ALameLlama opened this issue Aug 4, 2022 · 1 comment
Labels
5.0 The issues we want to solve in the 5.0 release bug A bug report status: medium Medium

Comments

@ALameLlama
Copy link
Contributor

Describe the bug
Since AbstractSerializer isSuccess is initiated with the class and is set as true and is only is updated to false, if it fails to unserialize one bit of data the rest will also return isSuccess as false but getData will return valid data.

To Reproduce
This example isn't the best but it should give you a way to recreate it:

$this->_di->setShared('cache', function () {
  $redisCache =  new \Phalcon\Cache\Adapter\Redis(
      new \Phalcon\Storage\SerializerFactory()),
      $redisConfig
  );

  return new \Phalcon\Cache\Cache($redisCache);
});

$cache = \Phalcon\Di\Di::getDefault()->getShared('cache');

for ($x = 0; $x <= 5; $x++) {
    var_dump($x);
    if ($x < 3 || $x > 3) {
        if ($cache->has('testing_1')) {
            var_dump($cache->get('testing_1'));
            $cache->set('testing_1', ['fake' => 'data']);
        } else {
            var_dump('no cache');
            $cache->set('testing_1', ['fake' => 'data']);
        }
    } else {
        $cache->set('testing_1', false);
        var_dump($cache->get('testing_1'));
    }
}

var_dump('end');
die();

You can see, if the first loop, no cache so we set it an an array, 2-3 loop, it returns the cache, 4th loop it set it as false which on line phalcon\Storage\Serializer\Php.zep::70 checks if the result === false which causes it to set isSuccess as false. and then because of that the rest are returning null cause it's failing on phalcon\Storage\Adapter\AbstractAdapter.zep::328 since isSuccess is now false.
image

Details

  • Phalcon version: 5.0.0RC3
  • PHP Version: 7.4.30
  • Operating System: Ubuntu 20.04.4
  • Installation type: Any
  • Zephir version (if any): NA
  • Server: Apache
@ALameLlama ALameLlama added bug A bug report status: unverified Unverified labels Aug 4, 2022
@niden niden added status: medium Medium 5.0 The issues we want to solve in the 5.0 release and removed status: unverified Unverified labels Aug 5, 2022
@niden niden added this to Working on it in Phalcon Roadmap Aug 5, 2022
@niden
Copy link
Sponsor Member

niden commented Aug 5, 2022

Resolved in #16041

@niden niden closed this as completed Aug 5, 2022
Phalcon Roadmap automation moved this from Working on it to Implemented Aug 5, 2022
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
  
Implemented
Development

No branches or pull requests

2 participants