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
Labels
Projects

Comments

@bain2018
Copy link

@bain2018 bain2018 commented Nov 11, 2019

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 niden added 4.0 Bug - High and removed Bug - Unverified labels Nov 11, 2019
@niden niden added this to To do in 4.0 Release via automation Nov 11, 2019
@niden niden moved this from To do to In progress in 4.0 Release Nov 11, 2019
niden added a commit that referenced this issue Nov 11, 2019
niden added a commit that referenced this issue Nov 11, 2019
@niden

This comment has been minimized.

Copy link
Member

@niden niden commented Nov 11, 2019

Resolved in: #14529

@niden niden closed this Nov 11, 2019
4.0 Release automation moved this from In progress to Done Nov 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
4.0 Release
  
Done
2 participants
You can’t perform that action at this time.