Project

General

Profile

Actions

Bug #91174

closed

if-viewhelper condition 0="text"

Added by Roman Büchler over 4 years ago. Updated 5 months ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Fluid
Target version:
-
Start date:
2020-04-22
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
9
PHP Version:
7.2
Tags:
Complexity:
Is Regression:
Sprint Focus:

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.

Actions #1

Updated by Simon Praetorius over 1 year ago

  • Status changed from New to Resolved

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)

Actions #2

Updated by Benni Mack 5 months ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF