Bug #89159

Ternary condtions stopped working...

Added by Stig Nørgaard Færch 9 days ago. Updated 2 days ago.

Status:
New
Priority:
Should have
Assignee:
-
Category:
Fluid
Target version:
-
Start date:
2019-09-12
Due date:
% Done:

0%

TYPO3 Version:
9
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

When updating to the latest 2.6.2 version, it seems like that the ternary condtions feature (as described here: https://usetypo3.com/24-fluid-tips.html#c442) stopped working.

History

#1 Updated by Claus Due 8 days ago

Can you add a bit more information - for example:

  • What is the template code?
  • What are the variables involved with the expression?
  • What is the context (inside or outside ViewHelper arguments)?
  • What is your PHP version?

#2 Updated by Stig Nørgaard Færch 8 days ago

Claus Due wrote:

Can you add a bit more information - for example:

Sorry for not supplying with much data on the issue.
I was also a bit too quick to blame the shift from typo3fluid/fluid 2.6.1 to 2.6.2, as downgrading does not seem to fix anything.
Also, I'm not sure at what point it stopped working, or if it have been working at all then.
The thing I can conclude though, is that it still doesn't work as I expect.

  • What is the template code?
  • What are the variables involved with the expression?
  • What is the context (inside or outside ViewHelper arguments)?

Instead of showing my code, just trying out the example from usetypo3.com also demonstrates the problem on my installation

<f:variable name="variableToCheck" value="0" />
<f:variable name="option1" value="Option one" />
<f:variable name="option2" value="Option two" />
One of two options: {variableToCheck ? option1 : option2}<br/>
Fallback if variable not set: {option1 ? option1 : option2}<br/>

This should output:
One of two options: Option two
Fallback if variable not set: Option one

But instead it outputs:
One of two options: Option one
Fallback if variable not set: Option one

  • What is your PHP version?

Local: PHP 7.2.1 (MAMP)
Server: PHP 7.2.22

#3 Updated by Jarvis H 8 days ago

I believe it may be the issue described here: https://github.com/TYPO3/Fluid/issues/389

The viewhelper only checks for null values, and '0' is not null.

#4 Updated by Claus Due 2 days ago

https://github.com/TYPO3/Fluid/issues/389 is very unlikely to be related unless you also used `f:or` - the ternary condition does not use the same condition logic; and `f:or` is designed explicitly to only trigger alternative on null.

I am unable to confirm the problem. Fluid 2.x performs the code correctly:

pro:~ claus$ ./vendor/bin/fluid
<f:variable name="variableToCheck" value="0" />
<f:variable name="option1" value="Option one" />
<f:variable name="option2" value="Option two" />
One of two options: {variableToCheck ? option1 : option2}<br/>
Fallback if variable not set: {option1 ? option1 : option2}<br/>
^D

One of two options: Option two<br/>
Fallback if variable not set: Option one<br/>

You can test yourself using the command. Enter the Fluid code and disconnect (CTRL-D) to render.

Also available in: Atom PDF