core
core copied to clipboard
Cache: TagCollector is not called when collection is empty
API Platform version(s) affected: 3.3.11
Thanks to the new mechanism TagCollector, we move our custom logic to gather tags within a class implementing the interface, removing our decorations of deprecated api_platform.http_cache.listener.response.add_tags
Description
When a collection is empty, the TagCollectorInterface::collect() method is not called, so we just get the tags by default and can't add some by our own logic.
How to reproduce
Just create a class that implement the TagCollectorInterface and call a collection api with no results
Possible Solution
Looking into it now
Additional Context
The TagCollector interface is used in the AbstractItemNormalizer::normalize() method but the supports() is not validated because there is no data (and this is logic btw)
@usu wdyt? could you provide a fix targetting 3.3 @TonySma ?
Yep I will try Iris are collected in the AddTagsProcessor, if we add logic here, i'm not sure we can use the same interface ? The context seems not to be the same here
Do you have some insight / advice to achieve this ?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.