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?

Comments

hanoii created an issue. See original summary.

hanoii’s picture

The remove might even support wildcards/regular expressions.

berdir’s picture

> 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.

hanoii’s picture

Hmm my initial tests showed otherwise. Will review again

hanoii’s picture

@berdir

This is with the default Tag cache:

X-Drupal-Cache-Tags: config:field.storage.node.field_breadcrumb_label config:field.storage.node.field_key_cta config:field.storage.node.field_key_flexible_tag config:field.storage.node.field_key_image config:field.storage.node.field_key_teaser config:field.storage.node.field_key_title config:field.storage.node.field_key_type_feed config:user.role.anonymous config:views.view.media_feed http_response node:120038 node:121550 node:121560 node:121563 node:122221 node:122341 node:122344 node:126689 node:2160 node:2605 node_list taxonomy_term:13 taxonomy_term:150 taxonomy_term:190 taxonomy_term:196 taxonomy_term:197 taxonomy_term:198 taxonomy_term_list

And this is with the custom tag module and node_list:media as the tag:

X-Drupal-Cache-Tags: config:field.storage.node.field_breadcrumb_label config:field.storage.node.field_key_cta config:field.storage.node.field_key_flexible_tag config:field.storage.node.field_key_image config:field.storage.node.field_key_teaser config:field.storage.node.field_key_title config:field.storage.node.field_key_type_feed config:user.role.anonymous config:views.view.media_feed http_response node_list:media

So it seems that the single entities are also removed or am I understanding it wrong?

berdir’s picture

What 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.

berdir’s picture

Status: Active » Postponed (maintainer needs more info)
hanoii’s picture

Category: Support request » Bug report
Status: Postponed (maintainer needs more info) » Active

It'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.

berdir’s picture

Ok, 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.

hanoii’s picture

Status: Active » Needs review
StatusFileSize
new1.29 KB

Well, 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.

Status: Needs review » Needs work

The last submitted patch, 10: 3045569-n9.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

berdir’s picture

Yes, 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.

hanoii’s picture

Well, something is adding it, the above works. It seems to be

$tags = Cache::mergeTags($tags, $this->view->getQuery()->getCacheTags());

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

$tags = $this->view->storage->getCacheTags();

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?

hanoii’s picture

Tests were failing because of #3045855: Fix tests - views schema and new http_response cache tag, unrelated to this.

hanoii’s picture

Title: Merge tags instead of adding? » Make sure other tags are not lost on rest resources

I worked yesterday on testes for this patch, will send it in a min.

hanoii’s picture

Status: Needs work » Needs review
StatusFileSize
new12.76 KB
new14.05 KB

Adding tests to the patch.

The last submitted patch, 16: 3045569-n16-tests.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

hanoii’s picture

I 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.

berdir’s picture

Issue tags: +Needs tests

Tried 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?

hanoii’s picture

Issue tags: -Needs tests

@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.

  • Berdir committed 88eedc1 on 8.x-1.x authored by hanoii
    Issue #3045569 by hanoii: Make sure other tags are not lost on rest...
berdir’s picture

Status: Needs review » Fixed

I'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 :)

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.