Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Reroll patch for 8.2.x https://www.drupal.org/node/2903942
diff --git a/core/modules/views/src/Plugin/views/cache/CachePluginBase.php b/core/modules/views/src/Plugin/views/cache/CachePluginBase.php
index 87465ca06f..377d36f84e 100644
--- a/core/modules/views/src/Plugin/views/cache/CachePluginBase.php
+++ b/core/modules/views/src/Plugin/views/cache/CachePluginBase.php
@@ -4,6 +4,7 @@
use Drupal\Core\Cache\Cache;
use Drupal\Core\Cache\CacheableMetadata;
+use Drupal\Core\Entity\EntityInterface;
use Drupal\views\Plugin\views\PluginBase;
use Drupal\Core\Database\Query\Select;
use Drupal\views\ResultRow;
@@ -303,7 +304,9 @@ public function getRowCacheTags(ResultRow $row) {
if (!empty($row->_relationship_entities)) {
foreach ($row->_relationship_entities as $entity) {
- $tags = Cache::mergeTags($tags, $entity->getCacheTags());
+ if ($entity instanceof EntityInterface) {
+ $tags = Cache::mergeTags($tags, $entity->getCacheTags());
+ }
}
}
diff --git a/core/modules/views/src/Plugin/views/query/Sql.php b/core/modules/views/src/Plugin/views/query/Sql.php
index cfe593cc2e..604fffc898 100644
--- a/core/modules/views/src/Plugin/views/query/Sql.php
+++ b/core/modules/views/src/Plugin/views/query/Sql.php
@@ -5,6 +5,7 @@
use Drupal\Component\Utility\NestedArray;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Database\Database;
+use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
@@ -1646,11 +1647,13 @@ public function getCacheMaxAge() {
protected function getAllEntities() {
$entities = [];
foreach ($this->view->result as $row) {
- if ($row->_entity) {
+ if ($row->_entity instanceof EntityInterface) {
$entities[] = $row->_entity;
}
foreach ($row->_relationship_entities as $entity) {
- $entities[] = $entity;
+ if ($entity instanceof EntityInterface) {
+ $entities[] = $entity;
+ }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.