Skip to content

APC Cache cannot deserialize numerical values #12340

Closed
@dkarp0

Description

Expected and Actual Behavior

When saving numerical values with Phalcon\Cache\Frontend\Data and Phalcon\Cache\Backend\Apc, values are not serialized on save but Phalcon tries to deserialize them on get.

                $frontend = new \Phalcon\Cache\Frontend\Data(['lifetime' => 24 * 3600]);
                $cache = new \Phalcon\Cache\Backend\Apc(
                    $frontend,
                    ['prefix' => $di->get('store')->getStoreName()]
                );
                $cache->save('test-key', 1);
                $cache->get('test-key');

throws the following exception:

Shared\Error\PhpErrorException: [Notice] unserialize(): Error at offset 0 of 1 bytes

I believe the issue is related to 4e3989a.

The beforeStore method is now bypassed in the Frontend for numerical values, however the afterRetrieve method is not being bypassed for numerical values.

Details

  • Phalcon version: 3.0.1
  • PHP Version: 5.6.27
  • Operating System: Ubuntu 14.04.5 LTS
  • Installation type: installing via package manager
  • Server: Nginx

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions