Our blog

 

Flash Messenger Bug in Zend Framework + Patch

Arrgh am I going mad.. could something so simple really not work..?

It turns out that I wasn't going mad, and Flash Messenger in Zend Framework really does have a bug. If its not working for you, the following patch may well fix things. You can check if this bug applies by setting your error reporting to E_ALL in your bootstrap.

If you get the following error message then this patch should fix things for you.

CODE:
  1. Notice: Indirect modification of overloaded property Zend_Session_Namespace.....

To fix this problem and get FlashMessenger working correctly, you need to edit library/Zend/Controller/Action/Helper/FlashMessenger.php

find this line

PHP:
  1. self::$_session->{$this->_namespace}[] = $message;

and replace with this block

PHP:
  1. //self::$_session->{$this->_namespace}[] = $message;
  2. $sessionMessages = self::$_session->{$this->_namespace};
  3. $sessionMessages[] = $message;
  4. self::$_session->{$this->_namespace} = $sessionMessages;

Apparently this issue only affects php 5.2 and so they have decided not to fix it and instead suggest upgrading the PHP version. If you need to get it working though the above will fix it for you.

more info

If you want a nice tutorial about flash messenger, check out this page

More Reading:

5 Comments

Johan Nilsson
March 9th, 2009

Thanks for posting this, could not understand why the flashmessenger was working on one server but not on antoher. Thanks again.

 

admin
March 10th, 2009

happy to help :-)

 

Korpz
June 6th, 2009

Someone give this man some money!

 

[...] The messages array was always empty, no error message, nothing. I asked the big G again and I found this article. As you will notice this article was written in may 2009, so more than a year [...]

 

Erik
June 20th, 2010

I'm pretty sure this is a session bug in PHP version 5.2.1 (and below) and not so much a bug in the helper itself. Still, this is a solid fix. Thanks!

 

 

Leave a Reply