Skip to content

Instantly share code, notes, and snippets.

@damiankloip
Created June 6, 2015 15:30
Show Gist options
  • Save damiankloip/1ac60cc8a43c24e61950 to your computer and use it in GitHub Desktop.
Save damiankloip/1ac60cc8a43c24e61950 to your computer and use it in GitHub Desktop.
diff --git a/core/modules/views/src/Plugin/views/cache/CachePluginBase.php b/core/modules/views/src/Plugin/views/cache/CachePluginBase.php
index 2285c53..7ba07b9 100644
--- a/core/modules/views/src/Plugin/views/cache/CachePluginBase.php
+++ b/core/modules/views/src/Plugin/views/cache/CachePluginBase.php
@@ -355,21 +355,7 @@ public function generateOutputKey() {
* An array of cache tags based on the current view.
*/
public function getCacheTags() {
- $tags = $this->view->storage->getCacheTags();
-
- // The list cache tags for the entity types listed in this view.
- $entity_information = $this->view->query->getEntityTableInfo();
-
- if (!empty($entity_information)) {
- // Add the list cache tags for each entity type used by this view.
- foreach ($entity_information as $table => $metadata) {
- $tags = Cache::mergeTags($tags, \Drupal::entityManager()->getDefinition($metadata['entity_type'])->getListCacheTags());
- }
- }
-
- $tags = Cache::mergeTags($tags, $this->view->getQuery()->getCacheTags());
-
- return $tags;
+ return $this->view->storage->getCacheTags();
}
/**
diff --git a/core/modules/views/src/Plugin/views/cache/Tag.php b/core/modules/views/src/Plugin/views/cache/Tag.php
index 87ac8ba..f226373 100644
--- a/core/modules/views/src/Plugin/views/cache/Tag.php
+++ b/core/modules/views/src/Plugin/views/cache/Tag.php
@@ -7,6 +7,7 @@
namespace Drupal\views\Plugin\views\cache;
+use Drupal\Core\Cache\Cache;
use Drupal\Core\Cache\CacheBackendInterface;
/**
@@ -32,6 +33,27 @@ public function summaryTitle() {
/**
* {@inheritdoc}
*/
+ public function getCacheTags() {
+ $tags = parent::getCacheTags();
+
+ // The list cache tags for the entity types listed in this view.
+ $entity_information = $this->view->query->getEntityTableInfo();
+
+ if (!empty($entity_information)) {
+ // Add the list cache tags for each entity type used by this view.
+ foreach ($entity_information as $table => $metadata) {
+ $tags = Cache::mergeTags($tags, \Drupal::entityManager()->getDefinition($metadata['entity_type'])->getListCacheTags());
+ }
+ }
+
+ $tags = Cache::mergeTags($tags, $this->view->getQuery()->getCacheTags());
+
+ return $tags;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
protected function cacheExpire($type) {
return FALSE;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment