Project

General

Profile

Actions

Bug #91259

closed

New symfony expression syntax provides no replacement for [else] and does not document this removal either

Added by Stefanos Karasavvidis almost 4 years ago. Updated about 3 years ago.

Status:
Closed
Priority:
Must have
Assignee:
-
Category:
TypoScript
Target version:
-
Start date:
2020-05-01
Due date:
% Done:

100%

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

Description

I'm on TYPO3 10.4.1 and try to use a typoscript condition with ELSE part. The following is a sample to the default typoscript setup section of a new installation

page.20 = TEXT
[{$someconstant} > 50]
    page.20.value = IN FIRST
[ELSE]
    page.20.value = IN ELSE
[END]

If someconstant is indeed > 50, everything is fine. If someconstant is less than 50, the condition works, but in the TYPO3 log I get

Expression could not be parsed. - {"expression":"ELSE"}

which is confusing as it suggests that something is wrong

Actions #1

Updated by Simon Gilli almost 4 years ago

  • Status changed from New to Needs Feedback

I've tested your example in 10.4.1 and master and both are logging this error.

Actions #2

Updated by Simon Gilli almost 4 years ago

  • Status changed from Needs Feedback to Accepted
Actions #3

Updated by Stefan P almost 4 years ago

  • Subject changed from Confusing error message with typoscript ELSE conditions "Expression could not be parsed. - {"expression":"ELSE"}" to New symfony expression syntax provides no replacement for [else] and does not document this removal either
  • Priority changed from Should have to Must have
  • TYPO3 Version changed from 10 to 9
  • Is Regression set to Yes

This is because [else] does not exist as Symfony expression. It was silently dropped without further notice (like so many thinks these days). If you enabled strict syntax in TYPO3 9 then this was already marked as deprecated (without hint to any replacement).

A very ugly workaround is to write

[end]
[negatedCondition]

as an replacment for [else].

Actions #4

Updated by Riccardo De Contardi almost 4 years ago

Ok so the documentation here: https://docs.typo3.org/m/typo3/reference-coreapi/master/en-us/ApiOverview/TypoScriptSyntax/Syntax/Conditions.html

is wrong and the example

page.typeNum = 0
page = PAGE
page.10 = TEXT

[loginUser = *]
page.10.value = Logged in

[ELSE]
page.10.value = Not logged in

[END]

page.10.stdWrap.wrap = <strong>|</strong>

should become:

page.typeNum = 0
page = PAGE
page.10 = TEXT

[loginUser = *]
page.10.value = Logged in

[end]
page.10.value = Not logged in

[negatecondition]

page.10.stdWrap.wrap = <strong>|</strong>

am I correct?

Actions #5

Updated by Stefanos Karasavvidis almost 4 years ago

I really do not know whether the documentation is wrong or the error message. What I can confirm is that the condition from the bug report does work as it should. It just produces the error message. However, it may work only because of some weird parsing error.

Actions #6

Updated by Riccardo De Contardi over 3 years ago

I have totally misunderstood Stefan P's suggestion; Looking at the documentation https://docs.typo3.org/m/typo3/reference-coreapi/master/en-us/ApiOverview/TypoScriptSyntax/Syntax/Conditions.html, the syntax should be:

page.typeNum = 0
page = PAGE
page.10 = TEXT

[loginUser('*')]
page.10.value = Logged in
[end]

[!loginUser('*')]
page.10.value = Not logged in
[end]

page.10.stdWrap.wrap = <strong>|</strong>
Actions #7

Updated by Gerrit Code Review about 3 years ago

  • Status changed from Accepted to Under Review

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/67572

Actions #8

Updated by Gerrit Code Review about 3 years ago

Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/67572

Actions #9

Updated by Stefanos Karasavvidis about 3 years ago

I am now confused with the latest patch.

The patch description suggests that the [ELSE] statement in typoscript is still supported, and the patch just removes the warning.

The Subject of this ticket suggests that [ELSE] is no longer supported, and typoscript should be changed using a negated condition.

So which is true? If [ELSE] is still supported, the Subject of this ticket should be changed again.

Actions #10

Updated by Gerrit Code Review about 3 years ago

Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/67572

Actions #11

Updated by Torben Hansen about 3 years ago

[ELSE] is still supported, but as you wrote, it is unknown to Symfony Expression Language which should not try to evaluate the [ELSE] condition. Actually the parsing error should not be logged / the condition should not be evaluated by Symfony Expression Language, since the whole ELSE logic is handled by the TypoScriptParser (see https://github.com/TYPO3/TYPO3.CMS/blob/master/typo3/sysext/core/Classes/TypoScript/Parser/TypoScriptParser.php#L257).

Actions #12

Updated by Gerrit Code Review about 3 years ago

Patch set 1 for branch 10.4 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/67937

Actions #13

Updated by Torben Hansen about 3 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #14

Updated by Benni Mack about 3 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF