Skip to content

SearchFilterInterface::STRATEGY_IPARTIAL is not case-insensitive #6052

@ojooss

Description

@ojooss

API Platform version(s) affected: 3.1.*

Description
I changed my filter definition from string 'ipartial' to SearchFilterInterface::STRATEGY_IPARTIAL.
#[ApiFilter(filterClass: SearchFilter::class, properties: ['name' => 'ipartial', 'abbreviation' => 'ipartial'])] to #[ApiFilter(filterClass: SearchFilter::class, properties: ['name' => SearchFilterInterface::STRATEGY_IPARTIAL, 'abbreviation' => SearchFilterInterface::STRATEGY_IPARTIAL])]

After that my case-insensitive tests failed. After some debugging I recognised that the value of ApiPlatform\Doctrine\Common\Filter\SearchFilterInterface::STRATEGY_IPARTIAL is only 'partial' without "I".
Whereas in ApiPlatform\Doctrine\Orm\Filter\SearchFilter::filterProperty:193 there is an explicitly check for the prefix "I".

Same problem for STRATEGY_ISTART, STRATEGY_IEND and STRATEGY_IWORD_START but not for STRATEGY_IEXACT. STRATEGY_IEXACT has the missing "I" and works as expected.

How to reproduce
See https://github.com/api-platform/core/blob/3.2/src/Doctrine/Common/Filter/SearchFilterInterface.php#L42 and https://github.com/api-platform/core/blob/3.2/src/Doctrine/Orm/Filter/SearchFilter.php#L193

Possible Solution
Add missing "I" to value of constants

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions