I noticed that when adding/removing view modes, the form for configuring which view modes ("Allowed Entity Embed Display plugins") is not cleared in the cache, so the changed view modes are not present until you manually rebuild the cache.

From my limited understanding of the cache API, I think we just need to attach the proper cache tag to the form item that renders the display modes. I tried with "config:entity_view_display_list" but it didn't purge the cache when I added a new display mode. It's tough trying to find the proper cache tags to use.

CommentFileSizeAuthor
#5 2828608-5.patch1.15 KBwim leers

Comments

bkosborne created an issue. See original summary.

dave reid’s picture

Project: Embed » Entity Embed

This is an issue with Entity Embed. We are discussing reverting the change that makes each view mode its own option in #2845085: Avoid conflating @EntityEmbedDisplay plugins and view modes which would resolve this issue.

marcoscano’s picture

Issue tags: +D8Media
wim leers’s picture

wim leers’s picture

Title: Embed button form cache needs to be invalidated when view modes change » Embed button form lists cached @EntityEmbedDisplay plugin definitions; view mode-based ones need to be invalidated
Status: Active » Reviewed & tested by the community
Issue tags: +D8 cacheability
Related issues: +#3001284: Allow plugin derivers to specify cache tags for their definitions
StatusFileSize
new1.15 KB

Actually, this is just a simple oversight. The problem is that \Drupal\entity_embed\Plugin\Derivative\ViewModeDeriver's computation is not being invalidated when it should. It should be refreshed when config:entity_view_mode_list is invalidated.

This is a problem many plugin derivers face, hence the #3001284: Allow plugin derivers to specify cache tags for their definitions core issue.

But until #3001284 lands, this solves it.

Status: Reviewed & tested by the community » Needs work

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

wim leers’s picture

Status: Needs work » Reviewed & tested by the community

Once again, the 3 usual failures that are known in HEAD.

phenaproxima’s picture

Status: Reviewed & tested by the community » Fixed

Looks great. Thanks! Committed and pushed.

Status: Fixed » Closed (fixed)

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