We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Unexpected behaviour after app update to 3.0 / php7

After updating my app from 2.0.13 to 3.0 and php from 5.6 to 7.0, my logout function stop working, unless I comment the code used to clear caches


        public function endAction()
    {
             $keys =  $this->di->get('modelsCache')->queryKeys(); // --> this line cause problem
             foreach ($keys as $k) {
                   $this->di->get('modelsCache')->delete($k);
              }

        $this->session->remove('logging');
        $this->session->remove('auth');
        $this->flash->success('à bientôt!');
        return $this->response->redirect('index');
    }

php logs no error...instead of being logged out and redirected to login page, a redirection occur to the same page acl do when not allowed, and session is not destroyed

sidenote: except that, everything is really running faster..

edited Jul '16

Create issue on github please.



11.6k
Accepted
answer

solved thank to Jurigag :

you need to add 'statsKey'=>'_PHCR' to use queryKeys

when initializing the redis cache:


        $di->setShared('modelsCache', function () {
       $frontCache = new Phalcon\Cache\Frontend\Data(
          array(
              "lifetime" => 86400
           )
       );
       //Create the Cache setting redis connection options
       $cache = new Phalcon\Cache\Backend\Redis(
           $frontCache, array(
                 'host' => '127.0.0.1',
                 'port' => 6379,
                  'auth' => '',
                  'statsKey'=>'_PHCR'   /// --> needed
          ));
       return $cache;
    });