开发者

Cakephp is not redirecting properly when pages are cached

开发者 https://www.devze.com 2022-12-10 19:30 出处:网络
I am having some issues with a site that was working correctly until i implemented full page caching in CakePHP.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消