I'm facing a really strange issue with Zend Frameworks flashMessenger and can't find out what's the cause of the problem, nor how to solve it.
When a requested action takes very long, the flashMessenger doesn't work as expected.
Non-working Example:
class AttachmentController extends Zend_Controller_Action {
public function printAction() {
// action takes really long and causes flash message to not appear at all
sleep(11);
$this->_helper->flashMessenger
->setNamespace('success')
->addMessage("It's done!");
$this->_redirect('/attachment/index');
}
}
With the above code, the controller action behind /attachment/index
does not display the flashMessage.
However, if i reduce the runtime of the script, it works:
class AttachmentController extends Zend_Controller_Action {
public function printAction() {
// now the action runs faster and the flashMessage appears!
sleep(1);
$this->_helper->flashMessenger
->setNamespace('success')
->addMessage("It's done!");
$this->_redirect('/attachment/index');
}
}
Question: What may be the cause for the flashMessenger to not display my message? How may i fix that?
Notes:
- Yes, i'm sure this is the problem. I replaced the long-running procedure with
sleep(11)
in production code and it produces the described behaviour. The problem is not caused by the code i replaced for isolating the case. It's really caused by the long runtime of the script. - I can't make the script execute faster. Instead of the
sleep(11)
in the example, in production code something is sent to a printer which takes ~11 seconds to complete.
flashMessenger
? What doesaddMessage
do? Write to db or session?var_dump()
andexit
are your friends =) I can't findaddMessage()
inFlashMessenger
– Metamorphic