Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

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?



42.3k
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



13.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