Skip to content

Commit

Permalink
Hotfix: Consider result of FilterStrategy in Query Cache
Browse files Browse the repository at this point in the history
With an activate query cache, queries will be cached at a key generated in https://github.com/doctrine/orm/blob/152c04c03d68d39f485d367713dd69dec0f4106d/lib/Doctrine/ORM/Query.php#L792-L803 . If a SQLFilter does not produce static SQL but dynamic SQL, you need to call SQLFilter->setParameter for the dynamic parts, in order for them to be considered for the cache key: https://github.com/doctrine/orm/blob/152c04c03d68d39f485d367713dd69dec0f4106d/lib/Doctrine/ORM/Query/Filter/SQLFilter.php#L178-L181 . I.e. without setParameter() calls, the first generated query was cached and whatever visibility value the FilterStrategy had determined was reused for future requests.

@see doctrine/orm#3955
  • Loading branch information
MalteWunsch committed Mar 9, 2022
1 parent c1f76af commit 1677f11
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/DependencyInjection/OnRequestDependencyInjector.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,6 @@ public function setUpFilter(GetResponseEvent $event): void
$visibilityFilter = $filterCollection->getFilter(VisibilityColumnConsideringSQLFilter::NAME);

$visibilityFilter->injectDependencies($this->filterStrategy, $this->visibilityColumnRetriever);
$visibilityFilter->setParameter('visibility', $this->filterStrategy->getFilterSql(''));
}
}

0 comments on commit 1677f11

Please sign in to comment.