Project

General

Profile

Actions

Task #89176

closed

Provide better way to traverse array in TS conditions

Added by Markus Klein over 4 years ago. Updated over 3 years 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 5 (0 open5 closed)

Related to TYPO3 Core - Bug #88756: TypoScript – Symfony Expressions: request.getQueryParams() should do an "is defined" validationRejectedFrank Nägler2019-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
Is duplicate of TYPO3 Core - Bug #95781: PHP Warning: Undefined array key "uid" in /app/vendor/symfony/expression-language/Node/GetAttrNode.phpRejected2021-10-26

Actions
Actions #1

Updated by Markus Klein over 4 years ago

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

Updated by Gerrit Code Review over 4 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

Actions #3

Updated by Markus Klein over 4 years ago

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

Updated by Wolfgang Klinger over 4 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]
Actions #5

Updated by Markus Klein over 4 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.

Actions #6

Updated by Sven Juergens over 4 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.

Actions #7

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/+/61708

Actions #8

Updated by Markus Klein about 4 years ago

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

Updated by Susanne Moog about 4 years ago

  • Sprint Focus set to On Location Sprint
Actions #10

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/+/61708

Actions #11

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

Actions #12

Updated by Markus Klein about 4 years ago

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

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

Actions #14

Updated by Markus Klein about 4 years ago

  • Status changed from Under Review to Resolved
Actions #15

Updated by Benni Mack about 4 years ago

  • Status changed from Resolved to Closed
Actions #16

Updated by Markus Klein about 4 years ago

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

Updated by Florian Rival over 3 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.

Actions #18

Updated by Sybille Peters 12 months ago

  • Is duplicate of Bug #95781: PHP Warning: Undefined array key "uid" in /app/vendor/symfony/expression-language/Node/GetAttrNode.php added
Actions

Also available in: Atom PDF