Skip to content

Flash message behavior changed #28991

@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

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy