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]: ph 4.x, phalcon/Mvc/Model/Binder cache problem #14743

Closed
AdamWawrzynowski opened this issue Jan 21, 2020 · 2 comments
Closed

[BUG]: ph 4.x, phalcon/Mvc/Model/Binder cache problem #14743

AdamWawrzynowski opened this issue Jan 21, 2020 · 2 comments

Comments

@AdamWawrzynowski
Copy link

@AdamWawrzynowski AdamWawrzynowski commented Jan 21, 2020

Describe the bug
While using phalcon/Mvc/Model/Binder with cache enabled, we receive an error, because Binder still uses removed methods (exists() and save()), which are not available in AdapterInterface

$serializer = new \Phalcon\Storage\SerializerFactory();
$dispatcher->setModelBinder(new \Phalcon\Mvc\Model\Binder(), new \Phalcon\Cache\Adapter\Apcu($serializer));

First Error

'message' => string 'Call to undefined method Phalcon\Cache\Adapter\Apcu::exists()'
'function' => string 'getParamsFromCache'
'class' => string 'Phalcon\Mvc\Model\Binder'

if cache === null || !cache->exists(cacheKey) {

Second Error

'message' => string 'Call to undefined method Phalcon\Cache\Adapter\Apcu::save()'
'function' => string 'getParamsFromCache'
'class' => string 'Phalcon\Mvc\Model\Binder'

cache->save(cacheKey, paramsCache);

Working Quick Fix with Apcu

class Apcu extends \Phalcon\Cache\Adapter\Apcu
{    
    public function exists($key)
    {
        return $this->has($key);
    }
    
    public function save(string $key, $value, $ttl = null)
    {
        return $this->set($key, $value, $ttl);
    }
}

Renaming method exists() to has() and save() to set() inside /Mvc/Model/Binder should solve the problem.

Details

  • Phalcon version: 4.0.0
  • PHP Version: 7.2
  • Operating System: Windows 10
  • Server: Apache
@Jurigag

This comment has been minimized.

Copy link
Member

@Jurigag Jurigag commented Jan 21, 2020

Thanks for this, yea obvious fix for next release.

@Jurigag Jurigag added the 4.0.3 label Jan 21, 2020
@ruudboon ruudboon added this to Current Sprint (Ends January 24th) in Phalcon Roadmap Jan 21, 2020
niden added a commit to niden/cphalcon that referenced this issue Jan 21, 2020
niden added a commit to niden/cphalcon that referenced this issue Jan 21, 2020
@niden niden mentioned this issue Jan 21, 2020
3 of 5 tasks complete
@niden niden moved this from Current Sprint (Ends January 24th) to Working on it in Phalcon Roadmap Jan 21, 2020
niden added a commit that referenced this issue Jan 21, 2020
niden added a commit that referenced this issue Jan 21, 2020
@niden

This comment has been minimized.

Copy link
Member

@niden niden commented Jan 21, 2020

Resolved in #14747

Thank you @AdamWawrzynowski

@niden niden closed this Jan 21, 2020
Phalcon Roadmap automation moved this from Working on it to Implemented Jan 21, 2020
niden added a commit that referenced this issue Jan 21, 2020
niden added a commit that referenced this issue Jan 21, 2020
@niden niden moved this from Implemented to Released in Phalcon Roadmap Jan 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Phalcon Roadmap
  
Released
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.