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]: Cache\AdapterFactory - Get Key with value of zero returns NULL #15904

Closed
dz3n opened this issue Feb 11, 2022 · 2 comments · Fixed by #15923
Closed

[BUG]: Cache\AdapterFactory - Get Key with value of zero returns NULL #15904

dz3n opened this issue Feb 11, 2022 · 2 comments · Fixed by #15923
Assignees
Labels
5.0 The issues we want to solve in the 5.0 release bug A bug report status: high High

Comments

@dz3n
Copy link

dz3n commented Feb 11, 2022

Describe the bug
Not able to set value of zero through Phalcon\Cache\AdapterFactory

To Reproduce

        $di->setShared(
            'cache',
            function () use ($config) {
                $serializerFactory = new SerializerFactory();
                $adapterFactory = new AdapterFactory($serializerFactory);
                $options = [
                    'host' => $config->redis->host,
                    'port' => $config->redis->port,
                    'index' => 1,
                    'lifetime' => 86400,
                    'prefix' => 'api-',
                ];

                $adapter = $adapterFactory->newInstance('redis', $options);

                return new Cache($adapter);
            }
        );

Provide minimal script to reproduce the issue

        $cache = Di::getDefault()->get('cache');

        $cache->set('key', 0);
        $result = $cache->get('key');
        var_dump($result); //return NULL;

Expected behavior
it should return int(0)

Details

  • Phalcon version: 5.0.0beta2
  • PHP Version: PHP 8.0.14
  • Redis Version: 5.3.5
  • Operating System:
  • Installation type: Ubuntu + Docker
  • Server: Nginx
@dz3n dz3n added bug A bug report status: unverified Unverified labels Feb 11, 2022
@niden niden self-assigned this Feb 12, 2022
@niden niden added 5.0 The issues we want to solve in the 5.0 release status: high High and removed status: unverified Unverified labels Feb 12, 2022
@niden niden added this to Working on it in Phalcon Roadmap Feb 12, 2022
@niden
Copy link
Sponsor Member

niden commented Feb 12, 2022

@dz3n Thank you for reporting this.

The issue appears when the if (!$content) { condition is true It will return the default value (null) at the time.

I am going to introduce a store structure that will allow checking for failures on the adapter (say apcu_store fails and returns false) vs. actual values.

More on this shortly.

@niden niden mentioned this issue Mar 15, 2022
5 tasks
@niden niden linked a pull request Mar 15, 2022 that will close this issue
5 tasks
@niden
Copy link
Sponsor Member

niden commented Mar 16, 2022

Resolved in #15923

Thank you @dz3n for reporting this

@niden niden closed this as completed Mar 16, 2022
Phalcon Roadmap automation moved this from Working on it to Implemented Mar 16, 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: high High
Projects
Archived in project
Phalcon Roadmap
  
Implemented
Development

Successfully merging a pull request may close this issue.

2 participants