Task #89176

Provide better way to traverse array in TS conditions

Added by Markus Klein about 1 year ago. Updated 5 months ago.

Status:
Closed
Priority:
Should have
Assignee:
Category:
Documentation
Target version:
-
Start date:
2019-09-14
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
9
PHP Version:
Tags:
Complexity:
Sprint Focus:
On Location Sprint

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]

Related issues

Related to TYPO3 Core - Bug #88756: TypoScript – Symfony Expressions: request.getQueryParams() should do an "is defined" validationRejectedFrank Naegler2019-07-15

Actions
Related to TYPO3 Core - Bug #88252: Route Results are not available via TypoScriptClosedBenni Mack2019-04-30

Actions
Related to TYPO3 Core - Bug #88928: routeEnhancers and GP conditions (TS) not workingClosed2019-08-07

Actions
Related to TYPO3 Core - Bug #90685: RST docs of symfony expression language for TypoScript conditions has a typoClosedMarkus Klein2020-03-09

Actions
#1

Updated by Markus Klein about 1 year ago

  • Related to Bug #88756: TypoScript – Symfony Expressions: request.getQueryParams() should do an "is defined" validation added
#2

Updated by Gerrit Code Review about 1 year 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

#3

Updated by Markus Klein about 1 year ago

  • Related to Bug #88252: Route Results are not available via TypoScript added
#4

Updated by Wolfgang Klinger about 1 year 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]
#5

Updated by Markus Klein about 1 year 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.

#6

Updated by Sven Juergens almost 1 year 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.

#7

Updated by Gerrit Code Review 11 months 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

#8

Updated by Markus Klein 11 months ago

  • Related to Bug #88928: routeEnhancers and GP conditions (TS) not working added
#9

Updated by Susanne Moog 11 months ago

  • Sprint Focus set to On Location Sprint
#10

Updated by Gerrit Code Review 11 months 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

#11

Updated by Gerrit Code Review 11 months 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

#12

Updated by Markus Klein 11 months ago

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

Updated by Gerrit Code Review 11 months 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

#14

Updated by Markus Klein 11 months ago

  • Status changed from Under Review to Resolved
#15

Updated by Benni Mack 9 months ago

  • Status changed from Resolved to Closed
#16

Updated by Markus Klein 9 months ago

  • Related to Bug #90685: RST docs of symfony expression language for TypoScript conditions has a typo added
#17

Updated by Florian Rival 5 months 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.

Also available in: Atom PDF