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

FIX Default GridField search fields with an index of 0 to use StartWithFilter #10211

Conversation

emteknetnz
Copy link
Member

array_search will return 0 if it matched the first value in an array

Also add a unit test for #9991

Copy link
Contributor

@maxime-rainville maxime-rainville left a comment

Choose a reason for hiding this comment

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

Love the extra unit tests. Just need to fix that rogue import.

@@ -347,7 +348,7 @@ public function scaffoldSearchFields($dataClass)
// so we need to check the original setting.
// If the field is defined $searchable_fields = array('MyField'),
// then default to StartsWith filter, which makes more sense in this context.
if (!$customSearchableFields || array_search($name, $customSearchableFields)) {
if (!$customSearchableFields || array_search($name, $customSearchableFields) !== false) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm a little confused why we think StartsWith makes more sense in this context then PartialMatch.

But otherwise, the fix address a legitimate mismatch between the intention of the class and the actual behaviour.

@emteknetnz emteknetnz force-pushed the pulls/4.10/seach-filter-tests branch from 2b9633f to 740d087 Compare March 22, 2022 03:17
@maxime-rainville maxime-rainville merged commit 77e8787 into silverstripe:4.10 Mar 22, 2022
@maxime-rainville maxime-rainville deleted the pulls/4.10/seach-filter-tests branch March 22, 2022 22:37
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.

None yet

3 participants