Skip to content

Deprecation notice in AbstractFilter class #1796

Closed
@wilson-ng

Description

@wilson-ng

Hello, i have a trouble about deprecation notice in phpunit, it's say Using "ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\AbstractFilter::apply()" is deprecated since 2.2. Use "ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\AbstractContextAwareFilter::apply()" with the "filters" context key instead, if i disable order filter, the deprecation notice is disappear.

i've been talking about this to @dunglas from Slack api-platform channel, and he suggest me to check if request_stack is null, and when i check the request_stack is null and it's the intendended behaviour.

At method apply in AbstractFilter class, there a @trigger_error triggered.
how if i move @trigger_error after checking

if (null === $this->requestStack || null === $request = $this->requestStack->getCurrentRequest()) {
    return;
}

so, that if request_stack is not null, then apply method will run old behaviour with deprecated error, and if request_stack is null like a new behaviour of filter, there will no deprecated error in apply method triggered.

@trigger_error(sprintf('Using "%s::apply()" is deprecated since 2.2. Use "%s::apply()" with the "filters" context key instead.', __CLASS__, AbstractContextAwareFilter::class), E_USER_DEPRECATED);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions