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]: fatal error when using the model cache #14408

Closed
ekmst opened this issue Sep 23, 2019 · 7 comments
Assignees
Labels
Projects

Comments

@ekmst
Copy link
Contributor

@ekmst ekmst commented Sep 23, 2019

Describe the bug
fatal error when using the model cache

To Reproduce
Steps to reproduce the behavior:

// services: modelsCache
$serializerFactory = new SerializerFactory();
$adapterFactory    = new AdapterFactory($serializerFactory);
 $options = [
    'defaultSerializer' => 'Json',
    'lifetime'                => 30,
    'cacheDir'             => 'cache/models',
];
$adapter = $adapterFactory->newInstance('stream', $options);
$cache = new Cache($adapter);
$di->set('modelsCache', $cache);


// controller
 $options['cache'] = [
    'key'      => 'uniqkey',
    'lifetime' => 50,
];
$result = Users::find($options);
// output: 
Fatal error: Uncaught Phalcon\Mvc\Model\Exception: Cache didn't return a valid resultset in phalcon/Mvc/Model/Query.zep on line 3672

Details

  • Phalcon version: 4.0.0-rc.1
  • PHP Version: 7.3.1
  • Operating System: linux (ubuntu18.04)
  • Installation type: installing via package manager
  • Server: Nginx
  • Other related info (Database, table schema): mysql
Version => 4.0.0-rc.1
Build Date => Sep 23 2019 13:10:02
Powered by Zephir => Version 0.12.4-b386980

Directive => Local Value => Master Value
phalcon.db.escape_identifiers => On => On
phalcon.db.force_casting => Off => Off
phalcon.orm.case_insensitive_column_map => Off => Off
phalcon.orm.cast_last_insert_id_to_int => Off => Off
phalcon.orm.cast_on_hydrate => Off => Off
phalcon.orm.column_renaming => On => On
phalcon.orm.disable_assign_setters => Off => Off
phalcon.orm.enable_implicit_joins => On => On
phalcon.orm.enable_literals => On => On
phalcon.orm.events => On => On
phalcon.orm.exception_on_failed_save => Off => Off
phalcon.orm.exception_on_failed_metadata_save => On => On
phalcon.orm.ignore_unknown_columns => Off => Off
phalcon.orm.late_state_binding => Off => Off
phalcon.orm.not_null_validations => On => On
phalcon.orm.update_snapshot_on_save => On => On
phalcon.orm.virtual_foreign_keys => On => On
@ruudboon ruudboon self-assigned this Sep 24, 2019
@ruudboon

This comment has been minimized.

Copy link
Member

@ruudboon ruudboon commented Sep 25, 2019

@ekmst I think I located the issue. Will try to bug fix this soon.
Probally this will work if you set your serialiser to Php.

$adapterFactory    = new AdapterFactory($serializerFactory);
 $options = [
    'defaultSerializer' => 'Php',
    'lifetime'                => 30,
    'cacheDir'             => 'cache/models',
];
@ekmst

This comment has been minimized.

Copy link
Contributor Author

@ekmst ekmst commented Sep 25, 2019

@ruudboon Yes, I did. Thank!

@ekmst

This comment has been minimized.

Copy link
Contributor Author

@ekmst ekmst commented Sep 25, 2019

@ruudboon I think the problem is that json_decode returns an array by default

@ruudboon

This comment has been minimized.

Copy link
Member

@ruudboon ruudboon commented Sep 25, 2019

@ruudboon Yes it's related to that. But not directly on the serializer. We also have this with the None serializer.
There are few ways to fix this. Just need to figure out the best way. Will check this later today.

@niden niden added this to To do in 4.0 Release via automation Sep 27, 2019
@niden niden moved this from To do to In progress in 4.0 Release Sep 27, 2019
@niden niden referenced this issue Sep 27, 2019
4 of 5 tasks complete
@niden

This comment has been minimized.

Copy link
Member

@niden niden commented Sep 28, 2019

Resolved

@niden niden closed this Sep 28, 2019
4.0 Release automation moved this from In progress to Done Sep 28, 2019
@bain2018

This comment has been minimized.

Copy link

@bain2018 bain2018 commented Nov 18, 2019

$di->setShared('modelsCache', function () {
$config = $this->getConfig();
$serializerFactory = new \Phalcon\Storage\SerializerFactory();
$adapterFactory = new \Phalcon\Cache\AdapterFactory($serializerFactory);
$options = [

    //here get an errror:Cache didn't return a valid resultset ,but change defaultSerializer to Php it works well
    'defaultSerializer' => 'Json',  
    'lifetime'          => 7200,
    'host' => $config->redis->host,
    'port' => $config->redis->port,
    'auth' => $config->redis->auth,
    'persistent' => $config->redis->persistent,
    'index' =>1,
    'storageDir' => STORAGE_PATH.'cache/',
];
$adapter = $adapterFactory->newInstance('redis', $options);
return new \Phalcon\Cache($adapter);

});

@niden

This comment has been minimized.

Copy link
Member

@niden niden commented Nov 18, 2019

@bain2018 can you please open a new issue with what you are trying to store (and then seeing the error you are seeing)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
4.0 Release
  
Done
4 participants
You can’t perform that action at this time.