Fatal error "getCacheTags() on null" on admin/content Views page

Created on 21 March 2025, 17 days ago

Problem/Motivation

/admin/content view is not working - fatal error.

Dblog reports 3 different errors:
Error: Call to a member function getCacheTags() on null in Drupal\views\Plugin\views\query\Sql->getCacheTags() (Line 1677 in /app/web/core/modules/views/src/Plugin/views/query/Sql.php)

Error: Call to a member function getCacheMaxAge() on null in Drupal\views\Plugin\views\query\Sql->getCacheMaxAge() (Line 1694 in /app/web/core/modules/views/src/Plugin/views/query/Sql.php)

Error: Call to a member function getCacheTags() on null in Drupal\views\Plugin\views\cache\CachePluginBase->getRowCacheTags() (Zeile 320 in /app/web/core/modules/views/src/Plugin/views/cache/CachePluginBase.php)

The issue lies in web/core/modules/views/src/Plugin/views/query/Sql.php in getAllEntities(line 1707) method, where $row->_relationship_entities can be NULL but are not checked if emtyp (as $row->_entity is).

Steps to reproduce

It is related to our content so I'm not sure how exactly to reproduce. On some of our migrated nodes an entity reference field is missing.

Proposed resolution

I would actually put a check into the 3 methods that are throwing php errors to check if the entity is not empty and then perform caching operations (merging tags or getRowCacheTags).

🐛 Bug report
Status

Closed: works as designed

Version

10.4

Component

views.module

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024