\Drupal\views\Plugin\views\query\Sql::getCacheTags and getCacheMaxAge don't take into account that some entities can be NULL

Created on 1 June 2016, over 8 years ago
Updated 1 March 2024, 9 months ago

Problem/Motivation

\Drupal\views\Plugin\views\query\Sql::getCacheMaxAge and \Drupal\views\Plugin\views\query\Sql::getCacheTags both assume that the result of \Drupal\views\Plugin\views\query\Sql::getAllEntities is an array of Entity objects.

However \Drupal\views\Plugin\views\query\Sql::loadEntities sets missing entities to NULL.

This results in a fatal error:

Error: Call to a member function getCacheTags() on null in Drupal\views\Plugin\views\query\Sql->getCacheTags() (line 1552 of core/modules/views/src/Plugin/views/query/Sql.php).

This manifested with a view of content revisions linked to scheduled updates.

Sample view attached

Proposed resolution

Filter out nulls in \Drupal\views\Plugin\views\query\Sql::getAllEntities
Filter out nulls in \Drupal\views\Plugin\views\cache\CachePluginBase::getRowCacheTags too

Remaining tasks

tests

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Needs work

Version

11.0 🔥

Component
Views 

Last updated about 2 hours ago

Created by

🇦🇺Australia larowlan 🇦🇺🏝.au GMT+10

Live updates comments and jobs are added and updated live.
  • Needs change record

    A change record needs to be drafted before an issue is committed. Note: Change records used to be called change notifications.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024