Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Flash message behavior changed #28991

Closed
@XWB

Description

@XWB

Symfony version(s) affected: 4.1.3

Description

When saving a boolean to the flash bag, the value is converted to an integer.

The code example below has worked for years, and is currently broken. Has something changed in Symfony?

How to reproduce

if ($form->isSubmitted() && $form->isValid()) {
    $this->addFlash('status', true);

    return $this->redirectToRoute(...);
}

$this->addFlash('status', false);
{% from 'general/notify.html.twig' import error, success %}

{% for status in app.flashes('status') %}
    {% if status is same as(true) %}
        {% success('Saved successfully' | trans) %}
    {% elseif status is same as(false) %}
        {% error('An error occurred' | trans) %}
    {% endif %}
{% endfor %}

The message will not be printed. After some digging, it turns out that boolean values are converted to integers.

image

Note: our session data is saved in Memcached.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions