Flash Messenger Bug in Zend Framework + Patch

This is post is now quite old and the the information it contains may be out of date or innacurate.

If you find any errors or have any suggestions to update the information please let us know or create a pull request on GitHub

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.

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

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

and replace with this block

 //self::$_session->{$this->_namespace}[] = $message;
$sessionMessages = self::$_session->{$this->_namespace};
$sessionMessages[] = $message;
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

Tags: phpzend frameworkflashmessengerbug5.2