diff -u b/core/lib/Drupal/Core/Entity/Entity.php b/core/lib/Drupal/Core/Entity/Entity.php --- b/core/lib/Drupal/Core/Entity/Entity.php +++ b/core/lib/Drupal/Core/Entity/Entity.php @@ -496,11 +496,14 @@ * {@inheritdoc} */ public function getListCacheTagsToInvalidate() { - $tags = $this->getEntityType()->getListCacheTags(); + $tags = $this->getEntityType()->getBundleListCacheTagPattern(); $bundle_tags = []; if ($this->getEntityType()->hasKey('bundle')) { foreach ($tags as $key => $tag) { - $bundle_tags[$key] = $tag . ':' . $this->bundle(); + if (strpos($tag, '') !== false) { + $tag = str_replace('', $this->bundle(), $tag); + } + $bundle_tags[$key] = $tag; } $tags = Cache::mergeTags($tags, $bundle_tags); } only in patch2: unchanged: --- a/core/lib/Drupal/Core/Entity/EntityType.php +++ b/core/lib/Drupal/Core/Entity/EntityType.php @@ -336,7 +336,10 @@ public function __construct($definition) { // Ensure a default list cache tag is set. if (empty($this->list_cache_tags)) { - $this->list_cache_tags = [$definition['id'] . '_list']; + $this->list_cache_tags = [ + $definition['id'] . '_list', + $definition['id'] . '_list:', + ]; } } @@ -860,6 +863,19 @@ public function getListCacheContexts() { * {@inheritdoc} */ public function getListCacheTags() { + $list_cache_tags = []; + foreach ($this->list_cache_tags as $key => $tag) { + if (strpos($tag, '') === false) { + $list_cache_tags[$key] = $tag; + } + } + return $list_cache_tags; + } + + /** + * {@inheritdoc} + */ + public function getBundleListCacheTagPattern() { return $this->list_cache_tags; } only in patch2: unchanged: --- a/core/lib/Drupal/Core/Entity/EntityTypeInterface.php +++ b/core/lib/Drupal/Core/Entity/EntityTypeInterface.php @@ -779,6 +779,16 @@ public function getListCacheContexts(); public function getListCacheTags(); /** + * The list cache tags with pattern associated with this entity type. + * + * Enables code listing entities of this type to ensure that newly created + * entities show up immediately. + * + * @return string[] + */ + public function getBundleListCacheTagPattern(); + + /** * Gets the key that is used to store configuration dependencies. * * @return string