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]: modelCache Error "Data for JSON serializer cannot be of type object" #14528

Closed
bain2018 opened this issue Nov 11, 2019 · 1 comment
Closed

Comments

@bain2018
Copy link

Describe the bug
A clear and concise description of what the bug is.

// set a modelCache di

$di->setShared('modelsCache', function () {

$config = $this->getConfig();

$serializerFactory = new \Phalcon\Storage\SerializerFactory();
$adapterFactory    = new \Phalcon\Cache\AdapterFactory($serializerFactory);

$options = [
    'defaultSerializer' => 'Json',
    'lifetime'          => 7200,
    'host' => $config->redis->host,
    'port' => $config->redis->port,
    'auth' => $config->redis->auth,
    'index' =>1,
];

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

return new \Phalcon\Cache($adapter);

});

find a result:
$data=config::find([
'conditions'=>'status=1',
'cache'=>[
'key' => 'model-config',
'lifetime' => 3600247,
],
]);

get error :
"Data for JSON serializer cannot be of type object"

debugtrace

#0 [internal function]: Phalcon\Storage\Serializer\Json->serialize()
#1 [internal function]: Phalcon\Storage\Adapter\AbstractAdapter->getSerializedData(NULL)
#2 [internal function]: Phalcon\Storage\Adapter\Redis->set('model-config', Object(Phalcon\Mvc\Model\Resultset\Simple), 604800)
#3 [internal function]: Phalcon\Cache->set('model-config', Object(Phalcon\Mvc\Model\Resultset\Simple), 604800)
#4 [internal function]: Phalcon\Mvc\Model\Query->execute()

Details

  • Phalcon version:4.0 rc2
  • PHP Version: 7.3.11
  • Operating System: ubuntu
@niden
Copy link
Sponsor Member

niden commented Nov 11, 2019

Resolved in: #14529

@niden niden closed this as completed Nov 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants