We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Phalcon\Flash\Session getMessages bug

Hi,

I did a brief test to the Phalcon\Flash\Session today, and I found the result is quite different than what it used to be (comparing Phalcon 2 to Phalcon 1.3X). The PHP codes directly below is showing the result of Phalcon 2

<?php

$this->flashSession->success("set a 'success' type flash message");
$this->flashSession->getMessages("error", TRUE); // with a "TRUE" as the second argument, all types of flash message are being removed.
$this->flashSession->getMessages("error"); // without the second argument, the result is the same as with a "TRUE" as the second argument.
$this->flashSession->getMessages("error", FALSE); // with a "FALSE as the second argument, all types of flash message are NOT being removed, and the "type" from the first argument is NOT being removed too.

I remember before upgrading to Phalcon 2, the result is:

<?php

$this->flashSession->success("set a 'success' type flash message");
$this->flashSession->getMessages("error", TRUE); // will only remove "error" type, will not remove "success" type.
$this->flashSession->getMessages("success", TRUE); // will remove "success" type ONLY

Does any of you know how to solve this? Is this an actual bug? Should I try to open a issue in GitHub?



77.7k
Accepted
answer

Looks like that won't work anymore: https://github.com/phalcon/cphalcon/blob/phalcon-v2.0.9/phalcon/flash/session.zep#L70

No idea whether the change/deprecation was intentional by the devs... could worth creating an issue on github



25.7k

Thank you very much Lajos, your answer is great, I appreciate it.

Looks like that won't work anymore: https://github.com/phalcon/cphalcon/blob/phalcon-v2.0.9/phalcon/flash/session.zep#L70

No idea whether the change/deprecation was intentional by the devs... could worth creating an issue on github