-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
I had a bug with translatable, it was firing queries even though registering the walker and hinting the right locale was done properly. After tracing the problem i came to the conclusion that Query Caching should be disabled for queries using Translatable.
To disable the query cache on a query: $query->useQueryCache(false);
Reasoning:
If query cache is used the Parser is never invoked:
https://github.com/doctrine/doctrine2/blob/5c44dd38234f2e143e376ac94d2e7f945d7f9328/lib/Doctrine/ORM/Query.php#L248
If the Parser does not run then no custom output walkers are checked:
https://github.com/doctrine/doctrine2/blob/4f585a3d6372ef1115a30663fe0005f611decd76/lib/Doctrine/ORM/Query/Parser.php#L357
I think the difference between a HINT_CUSTOM_TREE_WALKERS
(SQL Walker) and HINT_CUSTOM_OUTPUT_WALKER
(output walker) is that the first changes the actual DQL query and the latter always has to be done afterwards.
This is possibly a limitation of Doctrine
To do: gedmo translatable should automatically turn off query caching when it needs to register an output walker