diff --git a/core/lib/Drupal/Core/Entity/Entity.php b/core/lib/Drupal/Core/Entity/Entity.php index 69e06a6..7f0c950 100644 --- a/core/lib/Drupal/Core/Entity/Entity.php +++ b/core/lib/Drupal/Core/Entity/Entity.php @@ -370,15 +370,15 @@ public function referencedEntities() { * {@inheritdoc} */ public function changed() { - $referenced_entity_ids = array( + $referenced_entities = array( $this->entityType() => array($this->id() => $this), ); foreach ($this->referencedEntities() as $referenced_entity) { - $referenced_entity_ids[$referenced_entity->entityType()][$referenced_entity->id()] = $referenced_entity; + $referenced_entities[$referenced_entity->entityType()][$referenced_entity->id()] = $referenced_entity; } - foreach ($referenced_entity_ids as $entity_type => $entities) { + foreach ($referenced_entities as $entity_type => $entities) { if (\Drupal::entityManager()->hasController($entity_type, 'view_builder')) { \Drupal::entityManager()->getViewBuilder($entity_type)->resetCache($entities); } diff --git a/core/lib/Drupal/Core/Entity/EntityViewBuilderInterface.php b/core/lib/Drupal/Core/Entity/EntityViewBuilderInterface.php index fcb9364..0d026f2 100644 --- a/core/lib/Drupal/Core/Entity/EntityViewBuilderInterface.php +++ b/core/lib/Drupal/Core/Entity/EntityViewBuilderInterface.php @@ -79,8 +79,8 @@ public function viewMultiple(array $entities = array(), $view_mode = 'full', $la /** * Resets the entity render cache. * - * @param array|null $entities - * (optional) If specified, the cache is reset for the given entities only. + * @param \Drupal\Core\Entity\EntityInterface[] $entities + * (optional) If specified, the cache is reset for the given entities only. */ public function resetCache(array $entities = NULL); diff --git a/core/modules/views/lib/Drupal/views/Entity/View.php b/core/modules/views/lib/Drupal/views/Entity/View.php index 2fcd761..1fe63b4 100644 --- a/core/modules/views/lib/Drupal/views/Entity/View.php +++ b/core/modules/views/lib/Drupal/views/Entity/View.php @@ -279,6 +279,8 @@ public function getExportProperties() { public function postSave(EntityStorageControllerInterface $storage_controller, $update = TRUE) { parent::postSave($storage_controller, $update); + // Clear cache tags for this view. + // @todo Remove if views implements a view_builder controller. $id = $this->id(); Cache::deleteTags(array('view' => array($id => $id))); views_invalidate_cache(); @@ -321,9 +323,17 @@ public static function postDelete(EntityStorageControllerInterface $storage_cont parent::postDelete($storage_controller, $entities); $tempstore = \Drupal::service('user.tempstore')->get('views'); + $tags = array(); + foreach ($entities as $entity) { - $tempstore->delete($entity->id()); + $id = $entity->id(); + $tempstore->delete($id); + $tags['view'][$id] = $id; } + + // Clear cache tags for these views. + // @todo Remove if views implements a view_builder controller. + Cache::deleteTags($tags); } /** diff --git a/core/modules/views/lib/Drupal/views/Tests/Plugin/CacheTagTest.php b/core/modules/views/lib/Drupal/views/Tests/Plugin/CacheTagTest.php index 6e393d3..c183e57 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Plugin/CacheTagTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Plugin/CacheTagTest.php @@ -54,21 +54,21 @@ class CacheTagTest extends PluginTestBase { /** * An array of page nodes. * - * @var \Drupal\node\Entity\Node[] + * @var \Drupal\node\NodeInterface[] */ protected $pages; /** * An article node. * - * @var \Drupal\node\Entity\Node + * @var \Drupal\node\NodeInterface */ protected $article; /** * A test user. * - * @var \Drupla\user\Entity\User + * @var \Drupal\user\UserInterface */ protected $user; diff --git a/core/modules/views/lib/Drupal/views/Tests/ViewExecutableTest.php b/core/modules/views/lib/Drupal/views/Tests/ViewExecutableTest.php index c3e4fd1..283c7cf 100644 --- a/core/modules/views/lib/Drupal/views/Tests/ViewExecutableTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/ViewExecutableTest.php @@ -36,7 +36,7 @@ class ViewExecutableTest extends ViewUnitTestBase { * * @var array */ - public static $testViews = array('test_destroy', 'test_executable_displays', 'test_view'); + public static $testViews = array('test_destroy', 'test_executable_displays'); /** * Properties that should be stored in the configuration.