Task #89176
closedProvide better way to traverse array in TS conditions
100%
Description
[request.getQueryParams()['my_ext']['foo'] > 0]
conditions like these cause errors if my_ext
is not set or if foo
is not set.
For the first case a dirty workaround is:
[request.getQueryParams() && request.getQueryParams()['my_ext'] && request.getQueryParams()['my_ext']['foo'] > 0]
which still crashes for the case when foo
is not set.
My suggestion to solve this is:
[traverse(request.getQueryParams(), 'my_ext/foo') > 0]
Updated by Markus Klein over 5 years ago
- Related to Bug #88756: TypoScript – Symfony Expressions: request.getQueryParams() should do an "is defined" validation added
Updated by Gerrit Code Review over 5 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/c/Packages/TYPO3.CMS/+/61708
Updated by Markus Klein over 5 years ago
- Related to Bug #88252: Route Results are not available via TypoScript added
Updated by Wolfgang Klinger over 5 years ago
I use this all the time and nothing crashes. What do you mean with crashes? An exception? A warning? A notice?
[request.getQueryParams()['tx_news_pi1'] && (request.getQueryParams()['tx_news_pi1'])['news'] > 0]
Updated by Markus Klein over 5 years ago
do you have URLs where tx_news_pi1|* but no tx_news_pi1|news is present?
(archive for instance)
Then you get errors.
Or, much simpler: TS is evaluated in BE context too (eg. belog module), which floods the logs.
Updated by Sven Juergens over 5 years ago
hi,
how are the chances that this comes in the core?
Sorry, but this style of writing conditions are crap
[request.getQueryParams() && request.getQueryParams()['my_ext'] && request.getQueryParams()['my_ext']['foo'] > 0]
technically speaking, using Symfony ExpressionLanguage is a big plus, no question about it.
But if something like that
[globalVar = GP:my_ext|foo> 0]
becoming something like this
[request.getQueryParams() && request.getQueryParams()['my_ext'] && request.getQueryParams()['my_ext']['foo'] > 0] || [request.getQueryParams() && request.getQueryParams()['my_ext'] && request.getQueryParams()['my_ext']['foo'] > 0]
than it's not a friendly system. The learning curve is quite high for beginners as far as TypoScript is concerned. But that makes it a lot harder to use the system. And in my opinion, TypoScript is still one of the great features of TYPO3. Precisely because of the conditions one is as flexible as in no other system.
Updated by Gerrit Code Review about 5 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/+/61708
Updated by Markus Klein about 5 years ago
- Related to Bug #88928: routeEnhancers and GP conditions (TS) not working added
Updated by Susanne Moog about 5 years ago
- Sprint Focus set to On Location Sprint
Updated by Gerrit Code Review about 5 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/+/61708
Updated by Gerrit Code Review about 5 years ago
Patch set 1 for branch 9.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/62857
Updated by Markus Klein about 5 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset 84f059820b01de2427b437194448cbf10bc6a412.
Updated by Gerrit Code Review about 5 years ago
- Status changed from Resolved to Under Review
Patch set 2 for branch 9.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/62857
Updated by Markus Klein about 5 years ago
- Status changed from Under Review to Resolved
Applied in changeset 3f8c961ea780d1803fa8a9f5199107f421270a26.
Updated by Markus Klein about 5 years ago
- Related to Bug #90685: RST docs of symfony expression language for TypoScript conditions has a typo added
Updated by Florian Rival over 4 years ago
- Category changed from TypoScript to Documentation
New traverse condition is not documented in Typo3 V9 condition reference :
https://docs.typo3.org/m/typo3/reference-typoscript/9.5/en-us/Conditions/Index.html
It's only documented in Master.
Updated by Sybille Peters almost 2 years ago
- Is duplicate of Bug #95781: PHP Warning: Undefined array key "uid" in /app/vendor/symfony/expression-language/Node/GetAttrNode.php added