Project

General

Profile

Actions

Bug #89159

closed

Ternary condtions stopped working...

Added by Stig Nørgaard Færch about 5 years ago. Updated over 4 years ago.

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

0%

Estimated time:
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.

Actions #1

Updated by Claus Due about 5 years 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?
Actions #2

Updated by Stig Nørgaard Færch about 5 years 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

Actions #3

Updated by Jarvis H about 5 years 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.

Actions #4

Updated by Claus Due about 5 years 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.

Actions #5

Updated by Riccardo De Contardi almost 5 years ago

  • Status changed from New to Needs Feedback

@Stig Nørgaard Færch

May I ask you if you still are able to reproduce this issue?

Actions #6

Updated by Georg Ringer over 4 years ago

I am closing this issue because lack of feedback. feel free to open a new issue and reference this one if still valid

Actions #7

Updated by Georg Ringer over 4 years ago

  • Status changed from Needs Feedback to Closed
Actions

Also available in: Atom PDF