What I need is the following:
- remove node_list
- add custom:node_list:type
- keep all (or about all) other tags, specially the node:ID ones
This module is handy, but it removes everything.
I also looked at https://www.drupal.org/project/views_advanced_cache which seems to do that although it does more and seems a much more complex module, and it's not subclassing Tag cache but rather doing everything on its own.
I wonder if you'd accept an extension to this module to be able to achieve something like this?
There are many ways of doing this:
I am thinking providing three replace/add/remove textareas where each will have its own meaning. Maybe adds a radio for (Replace/Merge) and have the textareas display conditionally.
Would you be open for such a change?
| Comment | File | Size | Author |
|---|---|---|---|
| #16 | 3045569-n16.patch | 14.05 KB | hanoii |
| #16 | 3045569-n16-tests.patch | 12.76 KB | hanoii |
Comments
Comment #2
hanoiiThe remove might even support wildcards/regular expressions.
Comment #3
berdir> This module is handy, but it removes everything.
The only thing that this module removes is the default entity list cache tag, it should not remove those from the entities that are listed.
Comment #4
hanoiiHmm my initial tests showed otherwise. Will review again
Comment #5
hanoii@berdir
This is with the default Tag cache:
And this is with the custom tag module and node_list:media as the tag:
So it seems that the single entities are also removed or am I understanding it wrong?
Comment #6
berdirWhat view is this, how does it display the nodes? I just tried on a default D8 site with the /front view and the node:ID cache tags are still there, the only difference is that node_list was replaced with "foo", the cache tag that I configured.
Comment #7
berdirComment #8
hanoiiIt's a rest export and has a custom serializer, but I just tried a brand new one on a local bare d8 and confirmed that it does work as you said on a regular page, but not on a rest export (core serializer) url.
Comment #9
berdirOk, don't really see what we could do differently to not cause this, we do not overwrite anything that could add those cache tags AFAIK. Specifically we do not change anything about getRowCacheTags(), which is the place that adds those cache tags AFAIK for regular page displays.
You'll need to debug when and where those tags are added exactly and why they aren't with the different cache plugin.
Comment #10
hanoiiWell, you are not calling the parent getCacheTags().
See this patch. It was a quick PoC but if may very well be the fix if you are happy with it. I'd say thought that it wasn't clear for me that this module just replaces the entity_list.
Comment #12
berdirYes, on purpose, that's how we don't get the default entity list cache tag. The parent doesn't add per-entity cache tags, $entity_information is an entity type, not an entity.
Comment #13
hanoiiWell, something is adding it, the above works. It seems to be
which is the only thing you are not calling on your own.
From CachePluginBase::getCacheTags()
Commenting it does the same as the module. It seems that on the rest export, the above adds the entity tags on rest, not on regular page. On a regular page view the entity ids come from
I'd think is best to call the parent and then remove so to not depend on what core does.
Looking into the tests though. Is this patch not likely to be accepted?
Comment #14
hanoiiTests were failing because of #3045855: Fix tests - views schema and new http_response cache tag, unrelated to this.
Comment #15
hanoiiI worked yesterday on testes for this patch, will send it in a min.
Comment #16
hanoiiAdding tests to the patch.
Comment #18
hanoiiI tried to keep the test a mirror of the other but assertPageCacheContextsAndTags didn't work nicely for json responses. I overrode it but also submitted #3046128: Extend assertPageCacheContextsAndTags tu support other request formats to core. If that is accepted the overrode method could be removed.
Comment #19
berdirTried to post this but it conflicted with your comments.
I see, good find, missed that line. this class is actually really old, it's possible that core didn't collect cache tags through the query when this was originally implemented.
I think I would prefer to just add that line as opposed to filtering out the others, assuming that actually works and doesn't add the list cache tags too.
Also, an explicit test would be great, I guess conceptually identical to the existing one except it's a rest display?Comment #20
hanoii@Berdir I took me a while but I got what you meant. My rationale behind filtering out is that uf core decides to do something else or different we just need to catch up with the removing of it, not with what is added/changed.
If you are really opposed to it, I can rework the patch.
Comment #22
berdirI'm unsure, it goes both ways, core might also add more that we don't want, but that's fairly unlikely as we'll just filter out the list cache tags anyway and I don't really know what else it could add.
I guess it would be less code, but only if the query cache tags don't contain the list cache tags, then we'd need to filter anyway.
Thanks for your work here, sorry for the unfriendly replies at first, very busy and thought that some very quick replies are better than none :)