Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUGFIX] provide some expression matcher variables #4320

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

achimfritz
Copy link
Collaborator

What this pr does

makes (more) TS Condition working when not in FE-Mode

currently: for most conditions the TYPO3.CMS.Core.TypoScript.IncludeTree.Visitor.IncludeTreeConditionMatcherVisitor
logs an Expression could not be parsed. error, e.g.

Expression could not be parsed. - {"expression":"request.getNormalizedParams() && request.getNormalizedParams().getHttpHost() == \"foo.bar.de\""}
Expression could not be parsed. - {"expression":"traverse(page, \"doktype\") == 24"}
Expression could not be parsed. - {"expression":"getTSFE() && page [\"uid\"] == 18"}
Expression could not be parsed. - {"expression":"208 in tree.rootLineIds || 209 in tree.rootLineIds || 217 in tree.rootLineIds"}

we should pass some important variables to the initializeExpressionMatcherWithVariables()

https://github.com/TYPO3/typo3/blob/65aa70e0e8c0bd64566d8726794c71525cbc4152/typo3/sysext/core/Classes/TypoScript/IncludeTree/Visitor/IncludeTreeConditionMatcherVisitor.php#L70

How to test

change Index Configuration

[site("identifier") == "my-site"]
  plugin.tx_solr.index.queue.pages.indexer.frontendDataHelper.host = my-site.ddev.site
[end]

my-site.ddev.site is not used as host

change index Configuration

[request && traverse(request.getQueryParams(), 'search/filter') > 0]
  # so log
[end]

gives an error log

Mon, 17 Feb 2025 08:02:47 +0100 [ERROR] request="4bea2d677e786" component="TYPO3.CMS.Core.TypoScript.IncludeTree.Visitor.IncludeTreeConditionMatcherVisitor": Expression could not be parsed. - {"expression":"request && traverse(request.getQueryParams(), 'search/filter') > 0"}

@dkd-kaehm
Copy link
Collaborator

@achimfritz
Thanks for fixing that issue.

Silences this patch all the log entries regarding TypoScript conditions?

PS: Using the conditions on EXT:solr indexing configs is a Pandora's box, avoid using it.

@achimfritz
Copy link
Collaborator Author

Hi @RafaelKa , i do not know if this "all" possible variable the expression matcher can handle. this PR works for our project, where we have about 15 error log entries per parsing TS.

@dkd-kaehm
Copy link
Collaborator

@achimfritz
Would you check the tests please. The mocks must be added to failed tests.

@achimfritz achimfritz force-pushed the bugfix/expression-matcher-variables branch from 3103dfa to 95f4b4e Compare February 18, 2025 10:23
@achimfritz achimfritz force-pushed the bugfix/expression-matcher-variables branch from 95f4b4e to a0d40b0 Compare February 18, 2025 10:57
@achimfritz
Copy link
Collaborator Author

CI is happy now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants