EntityViewsData fails to set 'entity revision' in the table data for an entity's revision table

Created on 4 October 2018, over 5 years ago
Updated 29 January 2024, 5 months ago

Problem/Motivation

The array of Views table data has a special 'table' key for each table which contains metadata about the table.

For entity tables, this has additional properties. One of these is the 'entity revision' property, which is a boolean that says whether this table is for revisions or not.

The EntityViewsData default handler sets this on the entity tables:

      $data[$data_table]['table']['group'] = $this->entityType->getLabel();
      $data[$data_table]['table']['provider'] = $this->entityType->getProvider();
      $data[$data_table]['table']['entity revision'] = FALSE;

...

      $data[$views_revision_base_table]['table']['entity revision'] = TRUE;
      $data[$views_revision_base_table]['table']['base'] = [

However, it fails to set this property for the revision table itself.

This is a problem because QueryPluginBase::getEntityTableInfo() assumes that any table that is an entity table has this set:

    if (isset($base_table_data['table']['entity type'])) {
      $entity_tables[$base_table_data['table']['entity type']] = [
        'base' => $base_table,
        'alias' => $base_table,
        'relationship_id' => 'none',
        'entity_type' => $base_table_data['table']['entity type'],
        'revision' => $base_table_data['table']['entity revision'],
      ];

This causes an error if a Views relationship goes to the revision table, as the revision table becomes one of the joined base tables, and the code above runs for it, and finds that $base_table_data['table']['entity revision'] is not set.

Proposed resolution

Ensure the entity revision property is set.

Remaining tasks

None.

User interface changes

None.

API changes

None.

Data model changes

None.

πŸ› Bug report
Status

Fixed

Version

10.2 ✨

Component
ViewsΒ  β†’

Last updated less than a minute ago

Created by

πŸ‡¬πŸ‡§United Kingdom joachim

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

Merge Requests

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.69.0 2024