zend framework FlashMessenger problem

血红的双手。 提交于 2019-12-06 09:32:54

To fix this problem you need to edit library/Zend/Controller/Action/Helper/FlashMessenger.php

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

and change it to
//self::$_session->{$this->_namespace}[] = $message;
$sessionMessages = self::$_session->{$this->_namespace};
$sessionMessages[] = $message;
self::$_session->{$this->_namespace} = $sessionMessages;

This issue only affects php 5.2 and so they have decided not to fix it and instead suggest upgrading the PHP version.

rahim asgari

i upgrade from php 5.2.0 to 5.2.9 and the problem solved.

aside from the function/classname capitalization issues, make sure your Zend_Session is set up, started, and has a storage method that works. It will use your session storage method that comes from a new Zend_Session_Namespace('FlashMessenger')

There are PHP 5.2.x Versions, that have a problem with

// Zend_Controller_Action_Helper_FlashMessenger::addMessage() (line 143)
self::$_session->{$this->_namespace}[] = $message;

Upgrading PHP would be a solution (as you did) or replacing the above line with the following code:

$messages = self::$_session->{$this->_namespace};

$messages[] = $message;

self::$_session->{$this->_namespace} = $messages;

I had a problem that came from having two ajax calls that used the flashMessenger and were finishing loading in random order. So the first ajax call was sometimes loaded first and thus using the messages and left none for the second; and I was expecting the error messages in the second ajax call and wondered why do they show just approx 50% of the cases.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!