Hello everybody,

I have a problem with some cakephp (version 1.2.3.8166) code. It
concerns using $this->Session->setFlash in a controller action. Part
of the controller code:

$this->Session->setFlash(__('Everything fine.', true), 'flashinfo');
$this->redirect(array('controller'=>'users','action'=>'index'));

As you can see I use a custom layout for the Flash message called
'flashinfo':

<div id="flashInfoMessage" style="display:none;">
<?php echo $content_for_layout; ?>
</div>
<script language="JavaScript" type="text/javascript">
<!--
Flash.show('flashInfoMessage');
//-->
</script>

code for the javascript Flash class:
Flash={
                show:function(element){
                  $(element).visualEffect('appear');
                        this.timer=setTimeout('Flash.hide("'+element+'")',7000);
                },
                hide:function(element){
                  $(element).visualEffect('fade');
                        clearTimeout(this.timer);
                        return false;
                }
 };

What this does is show the flash message for 7 seconds after which it
will be hidden by using the nice scriptaculous effect Fade.

I have two of these layouts, one for informational messages (green
background) and one for errors (red background).

This all works perfectly fine as long as I do not use cake view
caching. But of course I want to have caching in the site for speed.

To render the flash message I placed this into the layout
(default.ctp):

<cake:nocache>
<?php $session->flash(); ?>
</cake:nocache>

With caching turned on and a cached version of the page being rendered
already present in the cache, this generates the following error as
soon as the redirect is performed and the specified URL in the
redirect is being rendered:

Notice (8): Trying to get property of non-object [CORE/cake_1.2.3.8166/
libs/view/helpers/session.php, line 145]

Code | Context

$key    =       "flash"
$flash  =       array(
        "message" => "Uw contactformulier is verzonden.",
        "layout" => "flashinfo",
        "params" => array()
)
$view   =       false

                } else {
                    $view =& ClassRegistry::getObject('view');
                    list($tmpLayout, $tmpVars, $tmpTitle) = array
($view->layout, $view->viewVars, $view->pageTitle);

SessionHelper::flash() - CORE/cake_1.2.3.8166/libs/view/helpers/
session.php, line 145
include - APP/tmp/cache/views/home.php, line 72
View::renderCache() - CORE/cake_1.2.3.8166/libs/view/view.php, line
495
Dispatcher::cached() - CORE/cake_1.2.3.8166/dispatcher.php, line 678
Dispatcher::dispatch() - CORE/cake_1.2.3.8166/dispatcher.php, line 123
[main] - APP/webroot/index.php, line 88

Fatal error: Call to undefined method stdClass::renderLayout() in /usr/
www/htdocs/afvalcontainer/cake_1.2.3.8166/libs/view/helpers/
session.php on line 147

The error does not occur on first time rendering of the page,
everything works as expected in that case. Also when caching is
globally turned off, everything works as expected.

Any ideas of what I am doing wrong ? Or is this a bug ?

Happy caking,
 Steve

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to