Change record status: 
Project: 
Introduced in branch: 
8.0.x
Introduced in version: 
8.0.x-BETA13
Description: 

New interface added to ensure request context-dependent values do not break cacheability allows to add additional cache tags to entities during runtime. These additional cache tags are only meant to be used as cacheability metadata when the entity is being displayed.

To avoid those additional cache tags getting invalidated when the entity is invalidated, a separate EntityInterface::getCacheTagstoInvalidate() method was added. This method must only be used when getting the cache tags to invalidate with Cache::invalidateTags()

Before


// Invalidation.
\Drupal\Core\Cache\Cache::invalidateTags($entity->getCacheTags());

// Other usage.
$build['#cache']['tags'] = $entity->getCacheTags();

After


// Invalidation.
\Drupal\Core\Cache\Cache::invalidateTags($entity->getCacheTagstoInvalidate());

// Other usage remains the same.
$build['#cache']['tags'] = $entity->getCacheTags();

That getCacheTagstoInvalidate() method should only be needed very rarely. Entities are automatically invalidated when saved.

Impacts: 
Module developers
Updates Done (doc team, etc.)
Online documentation: 
Not done
Theming guide: 
Not done
Module developer documentation: 
Not done
Examples project: 
Not done
Coder Review: 
Not done
Coder Upgrade: 
Not done
Other: 
Other updates done