CakePHP does not redirect properly when pages are cached

I am having some problems with a website that is working correctly until I have fully cached the pages in CakePHP.

I followed the instructions in the manual and had my $ session-> flash session in a block without a cache:

<cake:nocache> <? if($session->check('Message.flash')){ $session->flash(); } ?> </cake:nocache> 

However, whenever the controller sets a flash message and redirects to a cached page, the page loads before the tag and then gives an error:

 Notice (8): Trying to get property of non-object [CORE/cake/libs/view/helpers/session.php, line 145] Fatal error: Call to undefined method stdClass::renderLayout() in /home/decipherd/domains/example.com/public_html/beta/cake/libs/view/helpers/session.php on line 14 

If you then go to the page created by another controller, the correct (pending) message is displayed and the page loads correctly.

Now I sent this to CakePHP trac as ticket 282

+4
source share
3 answers

It looks like it could be a kernel problem, have you tried sending a bug report ?

+1
source

Are you sure there is something in the flash message? Try:

 debug($session->read()); 

OR to output it to debug.log

 $this->log($session->read(), LOG_DEBUG); // this might not work in the view? 
+1
source

Looking at the error message, it looks like SessionHelper is unavailable for some reason.

I'm not sure why, this helper usually loads automatically when using AuthComponent or SessionComponent in your application.

Just guess, but it would be worth putting $helpers = array('Session', ...); to your control controller or AppController for a good measure.

You can view all available for viewing with debug($this);

Ultimately, I would make Matt's decision and upgrade it to the latest stable version.

+1
source

All Articles