Jira issue originally created by user benno:
We have an SQLFilter to filter on entities with a specific Trait implemented. The filter is very easy:
bq. $res = $targetTableAlias . '.agency_id = ' . $this->getCurrentAgencyId();
On our system we have the query cache enabled, this works as long the "AgencyId" doesn't change. When the ID changes, the query cache seems to return the wrong (old cache) query.
Comment created by @ocramius:
I'm not sure if this case should be contemplated by the ORM. Filters are low-level and supposed to be stateless (services).
Comment created by benno:
OK, we can disable the query cache for this case. But then should at least the documentation be updated, which explicitly mentions to use filter for locales, which are also not stateless: http://doctrine-orm.readthedocs.org/en/latest/reference/filters.html#example-filter-class
Also in the query cache chapter: http://doctrine-orm.readthedocs.org/en/latest/reference/caching.html#query-cache
bq. It is highly recommended that in a production environment you cache the transformation of a DQL query to its SQL counterpart. It doesn’t make sense to do this parsing multiple times as it doesn’t change unless you alter the DQL query.
[~benno] can you eventually provide a pull request?
Comment created by jamesblizzardbrowserlondon:
I would just like to say that we're having exactly the same issue. I'd love some method (official or not) of having filters being taken into account in this situation.
Comment created by telegu:
I have the same problem when is generated QueryCacheId It consider only the name of active filters and not the value of the filter
This is the code at line 646 of class \Doctrine\ORM\Query
protected function _getQueryCacheId()
$this->getDql() . var*export($this->*hints, true) .
($this->*em->hasFilters() ? $this->*em->getFilters()->getHash() : '') .
'&firstResult=' . $this->*firstResult . '&maxResult=' . $this->*maxResults .
Comment created by odiaseo:
I also have the same issue, there are circumstances where filters are dynamic and not stateless particularly when dealing with multi-site / multi-lingual platforms. Is there an appetite for the ORM to take this into consideration.
Comment created by bramstroker:
I have the same issue. We are using SQL filters a lot to filter entities by website and locale. It would be nice if the filter values can be taken into account as well. For now I disabled the query cache in the concerning repositories.
Comment created by csolis:
Same issue here, we are using filters for soft deletion and it would be nice if we can use query cache.
Comment created by tom.pryor:
We are currently working around this by naming the filter based on the value we apply in the filter. So in the agencyid example if we were filtering on an agency_id of 5 we'd name the filter something like 'agency_filter5'. Would be good if Doctrine took into account the parameter values of the filters when generating the cache id though.