I am having some issues with a site that was working correctly until i implemented full page caching in CakePHP.
I have followed the guidance in the Manual and have my $session->flash in 开发者_JAVA技巧a no-cache block as so:
<cake:nocache>
<?
if($session->check('Message.flash')){
$session->flash();
}
?>
</cake:nocache>
However, whenever a controller sets a flash message and redirects to a cached page the page loads down to the tag and then gives the 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 i then go to a page created by another controller the correct (delayed) message is displayed and the page loads correctly.
I have now submitted this to the CakePHP trac as ticket 282
Sounds like it might be an issue with the core, have you tried submitting a bug report?
Are you sure that there is something in the flash message? Try:
debug($session->read());
OR to output it to the debug.log
$this->log($session->read(), LOG_DEBUG); // this might not work in the view?
Looking at the error message, it seems as is SessionHelper is not available for some reason.
I am not sure why exactly, this helper is usually loaded automatically when using AuthComponent or SessionComponent in your application.
Just a guess, but it might be worth putting $helpers = array('Session', ...);
in your problem controller or AppController for good measure.
You can inspect everything available to your view with debug($this);
Ultimately, I would take Matt's advice and upgrade to the latest stable version anyway.
精彩评论