Issue Bug Closed

#91174if-viewhelper condition 0="text"

Roman Büchler 04/22/20, 13:53 updated 07/09/24, 12:00

Description

The following condition seems to evaluate wrongly:

<f:debug>Result from condition '0 == "text"': {f:if(condition: '0 == "text"', then: 1, else: 0)}</f:debug>

The result is:

Result from condition '0 == "text"': 1

This might be hard to debug in case the test is against a variable that is of type integer or string:

{f:if(condition: '{test} == "text"',

When type casting it works as expected:

{f:if(condition: '{test as string} == "text"',

If in the above example test=1 then the condition doesn’t pass. Without type casting it passes.

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.

History 2

  1. Simon Praetorius commented and changed status New Resolved 06/19/23, 07:49

    PHP7 behaved differently here than PHP8. I just checked the examples you described with the latest Fluid version and PHP 8.2, everything works as expected.

    These all evaluate to false now:

    0 == 'text'
    {test} == 'text' (with test = 0)
    {test as string} == 'text' (with test = 0)
    {test} == 'text' (with test = 1)
    {test as string} == 'text' (with test = 1)
  2. Benni Mack changed status Resolved Closed 07/09/24, 12:00