core icon indicating copy to clipboard operation
core copied to clipboard

Cache: TagCollector is not called when collection is empty

Open TonySma opened this issue 1 year ago • 2 comments

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)

TonySma avatar Aug 26 '24 13:08 TonySma

@usu wdyt? could you provide a fix targetting 3.3 @TonySma ?

soyuka avatar Aug 29 '24 20:08 soyuka

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 ?

TonySma avatar Sep 02 '24 10:09 TonySma

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.

stale[bot] avatar Nov 02 '24 10:11 stale[bot]