Problem/Motivation

The CACHE_TAG_GENERIC warning of the Views analyzer (modules/audit_views/src/Plugin/AuditAnalyzer/ViewsAnalyzer.php) recommends bundle-specific cache tags (node_list:article) and installing Views Advanced Cache to configure them. But the check only looks at displays whose cache plugin is 'tag' (buildDisplayCacheDetails() sets cache_tag_optimizable only for cache type 'tag', and detectCacheTagIssues() returns early for any other type). It never reads the Advanced Views Cache options.

Verified against views_advanced_cache 2.0.2 (AdvancedViewsCache::getCacheTags()): the plugin always merges the default tags of CachePluginBase, including the generic node_list, and only removes them through the "Cache tags to exclude" (cache_tags_exclude) or "exclude via regular expression" (cache_tags_exclude_regex) options. Checked on a real site with three views filtered to articles:

- Advanced Views Cache with no tag configuration: the display still emits node_list, exactly like the 'tag' plugin, but the warning disappears. Following the recommendation "fixes" the report without fixing the site (false negative).
- node_list excluded and node_list:article added: the display emits node_list:article. This is the intended configuration.
- node_list excluded and no bundle tag added: the display emits NO list tag at all, so creating or publishing an article never invalidates the cached display. This is worse than the generic tag and is not reported.

Additionally CACHE_TYPE_LABELS has no entry for advanced_views_cache, so the report shows the raw plugin id ("Advanced_views_cache").

Steps to reproduce

1. Take a view with a CACHE_TAG_GENERIC warning (tag cache, filtered by content type).
2. Install views_advanced_cache and switch the display's cache plugin to "Advanced Views Cache" without configuring any tag.
3. Run drush audit:run views --format=json: the warning is gone although the display still uses node_list.
4. Now exclude node_list without adding node_list:article: still nothing is reported, although new articles no longer invalidate the display.

Proposed resolution

Compute one cache tag status per display (new protected method getCacheTagStatus()):
- 'tag' plugin with bundles: generic (unchanged behaviour).
- advanced_views_cache: if _list is not excluded (by name or by a matching regular expression; invalid expressions are ignored, as the module does), it is generic when the view is restricted to bundles. If it is excluded, it is 'ok' when the added cache tags include _list: for every listed bundle (or a token such as node_list:{{ raw_arguments.type }}), and 'incomplete' otherwise.

Report 'generic' as CACHE_TAG_GENERIC as today, and 'incomplete' as a new CACHE_TAG_INCOMPLETE warning that names the missing tags. Count both in the cache tags factor, the cache tag issues list and the display warning badges, and add an "Advanced Views Cache" label.

Remaining tasks

- Implement getCacheTagStatus(), the CACHE_TAG_INCOMPLETE item and the label.
- Unit tests: data provider for getCacheTagStatus() (tag with/without bundles, time cache, advanced cache without options, another tag excluded, invalid regex, excluded without tags, excluded by regex, one bundle tag missing, all bundle tags, token tag) and an analyzeDisplays() test reporting CACHE_TAG_INCOMPLETE.

User interface changes

New CACHE_TAG_INCOMPLETE warning ("Incomplete Cache Tags") in the cache tags section, and the "Advanced Views Cache" label in the cache column.

API changes

None.

Data model changes

None.

Comments

trebormc created an issue. See original summary.

  • trebormc committed a887d616 on 1.x
    Issue #3630450 by trebormc: Check the Advanced Views Cache tag settings...
trebormc’s picture

Status: Active » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.