Bug #86915
closedSymfony Expression TypoScript conditions fail at nested arrays
Added by Lars Peter Søndergaard about 6 years ago. Updated over 5 years ago.
100%
Description
Hi,
conditions that try to access values of nested array do not yet work properly with the new symfony expression language.
Example
This works:
[request.getQueryParams()["foobar"] == "baz"] page.16 = TEXT page.16.value = FOOBAR [END]
This does not:
[request.getQueryParams()["tx_news_pi1"]["action"] == "detail"] page.16 = TEXT page.16.value = FOOBAR [END]
The condition passed to Resolver::evaluate
turns out to be:
request.getQueryParams()["tx_news_pi1"
in the latter case, presumably splitting at ][
due to old syntax (just a guess though).
Updated by Josef Glatz almost 6 years ago
- Priority changed from Should have to Must have
Updated by Josef Glatz almost 6 years ago
I also can reproduce the issue in another way:¶
# Default PAGE object:
page = PAGE
page.10 = TEXT
page.10.value = HELLO WORLD! Please open the page with e.g. Get parameter: ?type=1
foo = PAGE
foo.typeNum = 1
[request.getParsedBody()['type'] > 0 || request.getQueryParams()['type'] > 0]
foo.1 = TEXT
foo.1.value = <h1>1</h1>
[ (request.getParsedBody()['type'] > 0) || (request.getQueryParams()['type'] > 0) ]
foo.2 = TEXT
foo.2.value = <h1>2</h1>
[ (request.getParsedBody()['type'] > 0) or (request.getQueryParams()['type'] > 0) ]
foo.3 = TEXT
foo.3.value = <h1>3</h1>
[request.getParsedBody()['type'] > 0] || [request.getQueryParams()['type'] > 0]
foo.4 = TEXT
foo.4.value = <h1>4</h1>
[request.getParsedBody()['type'] > 0] or [request.getQueryParams()['type'] > 0]
foo.5 = TEXT
foo.5.value = <h1>5</h1>
[global]
For clarification: the actual working foo.4
and foo.5
objects are deprecated in v9. One of the first three should at least work - if I understand Frank correct.
While discussing with Frank,¶
he came up with the conclusion that the pre-v9 existing TypoScript condition matcher is not completely aware of the new possibilities. As the way to add multiple condition blocks is deprecated, this issue must be fixed.
The following condition work for me as an example¶
[{$site.dummyFrontend} == 1 && request.getQueryParams()['preview'] != 1]
Updated by Gerrit Code Review almost 6 years ago
- Status changed from New 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/58935
Updated by Gerrit Code Review almost 6 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/58935
Updated by Josef Glatz almost 6 years ago
Patch set 2 fits at first glance, but it works partially¶
All 5 objects are displayed with patch set 2.Using the following test scenario, the following object does not match
foo.8
→/?type=1&tx_news_pi1[news]=1
I've extended the test scenario "v2", now it looks like¶
foo = PAGE
foo.typeNum = 1
[request.getParsedBody()['type'] > 0 || request.getQueryParams()['type'] > 0]
foo.1 = TEXT
foo.1.value = <h1>1 <small>combined</small></h1>
[ (request.getParsedBody()['type'] > 0) || (request.getQueryParams()['type'] > 0) ]
foo.2 = TEXT
foo.2.value = <h1>2 <small>combined</small></h1>
[ (request.getParsedBody()['type'] > 0) or (request.getQueryParams()['type'] > 0) ]
foo.3 = TEXT
foo.3.value = <h1>3 <small>combined</small></h1>
[request.getParsedBody()['type'] > 0] || [request.getQueryParams()['type'] > 0]
foo.4 = TEXT
foo.4.value = <h1>4</h1>
[request.getParsedBody()['type'] > 0] or [request.getQueryParams()['type'] > 0]
foo.5 = TEXT
foo.5.value = <h1>5</h1>
[request.getParsedBody()['type'] > 1] or [request.getQueryParams()['type'] > 1]
foo.6 = TEXT
foo.6.value = <h1>6 <small>greater then 1</small></h1>
[request.getParsedBody()['type'] > 0 or request.getQueryParams()['type'] == 1]
foo.7 = TEXT
foo.7.value = <h1>7 <small>combined</small></h1>
[request.getParsedBody()['tx_news_pi1']['news'] > 0 || request.getQueryParams()['tx_news_pi1']['news'] > 0]
foo.8 = TEXT
foo.8.value = <h1>8, tx_news_pi1|news <small>combined</small> </h1>
[request.getQueryParams()['tx_news_pi1']['news'] > 0]
foo.9 = TEXT
foo.9.value = <h1>9, tx_news_pi1|news only getQuery</h1>
[global]
Snippet also available as raw version: https://pastebin.com/raw/gmxeRJLa
Adopting the Get Params to /?type=1&tx_news_pi1[news]=1
¶
... doesn't match
foo.8
which looks like[request.getParsedBody()['tx_news_pi1']['news'] > 0 || request.getQueryParams()['tx_news_pi1']['news'] > 0]
Updated by Wolfgang Klinger almost 6 years ago
@ Josef: this one can't be fixed by TYPO3 if the parsing is completely left to symfony's expression language … because the symfony parser throws an exception if an array in a condition does not exist and therefore the whole condition fails (even if there's an OR condition like in your example … see \Symfony\Component\ExpressionLanguage\Node\GetAttrNode::evaluate for details)
Updated by Josef Glatz almost 6 years ago
- Related to Bug #87021: Using "getTSFE().beUserLogin == 1" as expression in an TypoScript condition leads to an error in the Symfony Expression Language added
Updated by Gerrit Code Review almost 6 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/58935
Updated by Gerrit Code Review almost 6 years ago
Patch set 4 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/58935
Updated by Gerrit Code Review almost 6 years ago
Patch set 5 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/58935
Updated by Gerrit Code Review almost 6 years ago
Patch set 6 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/58935
Updated by Gerrit Code Review almost 6 years ago
Patch set 7 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/58935
Updated by Gerrit Code Review almost 6 years ago
Patch set 8 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/58935
Updated by Wolfgang Klinger almost 6 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset c443d5cc0f09ba83f48ed4ce246098151fee4c41.
Updated by Wolfgang Klinger almost 6 years ago
This works without any patch (TYPO3 9.5.3):
[(request.getQueryParams()['tx_news_pi1'])['news'] > 0]