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

!!![FEATURE] Allow using complex filter values in FlexForm #3703

Merged
merged 1 commit into from
Oct 12, 2023

Conversation

echavaillaz
Copy link
Contributor

@echavaillaz echavaillaz commented Jun 21, 2023

With this PR it is now possible to use complex query in FlexForm filter value.

I add a regex to prevent a too big breaking change. The old behaviour is still working, so if a string value contains space(s) and no special characters of the solr query parser, the string is always wrapped with double quotes. But if the string contains special characters no wrapping happen (special characters are + - && || ! ( ) { } [ ] ^ " ~ * ? : \.

There is some cases where this PR can break, for example if the filter value is something like toto AND tata or music (rock) or my "flow" is. Here the wrapping and the escaping of the inner double quote have to be manually updated like this "toto AND tata", "music (rock)" and "my \"flow\" is".

Fixes: #2151

Copy link
Collaborator

@dkd-kaehm dkd-kaehm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code base LGTM!
Please add

@dkd-kaehm
Copy link
Collaborator

@echavaillaz
Please fix the issues from GH-actions:
https://github.com/TYPO3-Solr/ext-solr/actions/runs/5334225100/jobs/9668256731?pr=3703

For CS fixes just run this command:
TYPO3_VERSION=12.4.x-dev composer tests:setup && composer t3:standards:fix

The unit test and/or method ConfigurationService::getFilterFromFlexForm() must be adjusted:

1) ApacheSolrForTypo3\Solr\Tests\Unit\System\Service\ConfigurationServiceTest::canOverrideConfigurationWithFlexFormSettings with data set "simpleInteger" ('id', 4711, 'id:4711')
TypeError: ApacheSolrForTypo3\Solr\Tests\Unit\System\Service\ConfigurationServiceTest::canOverrideConfigurationWithFlexFormSettings(): Argument #2 ($filterValue) must be of type string, int given, called in /home/runner/work/ext-solr/ext-solr/.Build/vendor/phpunit/phpunit/src/Framework/TestCase.php on line 1608

/home/runner/work/ext-solr/ext-solr/Tests/Unit/System/Service/ConfigurationServiceTest.php:107
/home/runner/work/ext-solr/ext-solr/.Build/bin/phpunit:123

--

There was 1 failure:

1) ApacheSolrForTypo3\Solr\Tests\Unit\System\Service\ConfigurationServiceTest::canOverrideConfigurationWithFlexFormSettings with data set "escapedString" ('id', 'foo"bar', 'id:"foo\"bar"')
Failed asserting that two arrays are equal.
--- Expected
+++ Actual
@@ @@
 Array (
-    0 => 'id:"foo\"bar"'
+    0 => 'id:foo"bar'
 )

@echavaillaz
Copy link
Contributor Author

Ready to test?

With this change it is now possible to use complex query in FlexForm filter value.

The old behaviour is still working,
so if a string value contains space(s) and no special characters of the solr query parser,
the string is always wrapped with double quotes.
But if the string contains special characters no wrapping happen
special characters are: `+ - && || ! ( ) { } [ ] ^ " ~ * ? : \`.

There is some cases where this change can break,
for example if the filter value is something like
`toto AND tata` or `music (rock)` or `my "flow" is`.
Here the wrapping and the escaping of the inner double quote have to be manually updated like this
`"toto AND tata"` or `"music (rock)"` and `"my \"flow\" is"`.

Fixes: TYPO3-Solr#2151
@dkd-kaehm dkd-kaehm changed the title [FEATURE] Allow using complex filter values in FlexForm !!![FEATURE] Allow using complex filter values in FlexForm Oct 12, 2023
@dkd-kaehm dkd-kaehm merged commit 61d1a92 into TYPO3-Solr:main Oct 12, 2023
8 checks passed
@dkd-kaehm dkd-kaehm mentioned this pull request Oct 13, 2023
1 task
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.

FlexForm filter values are force quoted
2 participants