Orm: We need to add isset to this key

Created on 17 Aug 2018  路  15Comments  路  Source: doctrine/orm

Feature Request

| Q | A
|------------ | ------
| New Feature | yes
| RFC | no
| BC Break | /no

Summary

We need to add isset to this key
image

and in enable too. A can make it

Bug Missing Tests

All 15 comments

@AndreyMashukov a failing test is required FIRST.

I review this file and run a test I think getFilter method already validate at line Doctrine/ORM/Query/FilterCollection.php:135. I still add a test for re-validate it. I send pull request, you can close my pull-request if not necessary test for this problem.

I will make it on weekend.

image

types declarations was added for missing types

And we never can to get line with unset with not enabled filter, because getFilter function checks filter, but we need to have test for it! :)

oh, it's need for latest version (type hinting)

See @delirehberi's patch: he already sent a test case.

I'd rather say that the exception is correct and to be expected there.

@Ocramius It's good, we need more tests

@AndreyMashukov I integrated the test in master, but the test is passing without change, so it does not reproduce the issue in this ticket.

@Ocramius I can't understand why we need this Exception? I think it will be simple if we ignore disabling if filter was not enable. I think it's better way. Then we will not need to check filter before disabling

@Ocramius, something like this:

    /**
     * Disables a filter.
     *
     * @param string $name Name of the filter.
     */
    public function disable($name)
    {
        if (!$this->isEnabled($name)) {
            return;
        }

        unset($this->enabledFilters[$name]);

        // Now the filter collection is dirty
        $this->filtersState = self::FILTERS_STATE_DIRTY;
    }

It will be simple to use outside

First, it is a BC break to remove the exception, as other code may rely on it, second it is correct that you shouldn't blindly enable/disable stuff that is not there, as these filters are not just a collection, but alter the behaviour of everything in the ORM.

@Ocramius it's only about disabling

Yes, we need to check before enable, but why we need to check before disabling?

If not enabled - do nothing. but always before disable I need to check it, why?!

Was this page helpful?
0 / 5 - 0 ratings