Bug #91259
closedNew symfony expression syntax provides no replacement for [else] and does not document this removal either
100%
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
Updated by Simon Gilli almost 5 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.
Updated by Simon Gilli almost 5 years ago
- Status changed from Needs Feedback to Accepted
Updated by S P over 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]
.
Updated by Riccardo De Contardi over 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?
Updated by Stefanos Karasavvidis over 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.
Updated by Riccardo De Contardi over 4 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>
Updated by Gerrit Code Review about 4 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
Updated by Gerrit Code Review about 4 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
Updated by Stefanos Karasavvidis about 4 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.
Updated by Gerrit Code Review about 4 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
Updated by Torben Hansen about 4 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).
Updated by Gerrit Code Review about 4 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
Updated by Torben Hansen about 4 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset 5456ab51ecff485608d6cd48b6508500a3efa1e0.