Bug #91757
closedMultiple TypoScript conditons are not working.
100%
Description
Two or more conditions in a line are not evaluated correctly.
The documentation (https://docs.typo3.org/m/typo3/reference-coreapi/master/en-us/ApiOverview/TypoScriptSyntax/Syntax/Conditions.html#the-syntax-of-conditions) says:
…the line content gets broken down into smaller units ([ condition 1 ] and [ condition 2 ]) which are individually evaluated and connected by a logical OR before they return the resulting TRUE or FALSE value.
The AbstractConditionMatcher doesn't split multiple conditions.
They just remove the first '[' and the last ']'. Then the whole rest of the string are used to evaluate the expression.
Example:
[1 == 0] || [2 == 2]
This results in checking of following expression in AbstractConditionMatcher
method evaluateExpression
1 == 0] || [2 == 2
Normally with the 2==2 the condition should be return "true". But it doesn't.
If I don't write the two ][
[1 == 0 || 2 == 2]
the condition returns true if one of the conditions is true.
I'm not sure where is the bug. In documentation or in code. There are many examples with the wrong syntax if the bug is in the documentation.
I'm wondering that nobody else had the problem. I didn't found the problem on forge or in slack. Maybe I'm searching for the wrong keywords :-).
Updated by Karsten Nowak (undkonsorten) over 4 years ago
- Description updated (diff)
Updated by Karsten Nowak (undkonsorten) over 4 years ago
- Description updated (diff)
Updated by Tobias Schmidt over 4 years ago
I can confirm this behaviour of combined conditions with TYPO3 10.4.6 and PHP 7.4.
Updated by Georg Ringer over 4 years ago
- Status changed from New to Needs Feedback
the docs at https://docs.typo3.org/m/typo3/reference-coreapi/master/en-us/ApiOverview/TypoScriptSyntax/Syntax/Conditions.html#combining-conditions actually state
Before TYPO3 10, it was possible to “chain” multiple condition blocks together with AND, OR, && and || by writing something like [ condition 1 ][ condition 2 ] > or [ condition 1 ] AND [ condition 2 ]. This is no longer possible or necessary, as with the new Symfony Expression Language, only single condition blocks on one line are now allowed. Logical operators like and, or or not are now used inside the condition block to allow for writing complex expressions.
so imo that is fine, isn't it?
Updated by Tobias Schmidt over 4 years ago
Documentation now matches the required syntax. In my opinion this issue can be closed. (This part of the documentation has been changed on June 26th but I'm pretty sure it has not been publicly available when I looked on Juli 29th.)
Updated by Karsten Nowak (undkonsorten) over 4 years ago
- % Done changed from 0 to 100
I think also it's ok and can be closed. Someone should do it.
Updated by Riccardo De Contardi over 4 years ago
- Status changed from Needs Feedback to Closed
@Karsten Hachmeister Nowak (undkonsorten) thank you for your feedback; I. close this issue.
If you think that this is the wrong decision, please reopen it or ping me.
Thank you