EntityViewsData variable reuse causes bug with revision_uid filter

Created on 28 March 2025, 5 days ago

Problem/Motivation

I added a base field to a custom entity by a hook_entity_base_field_info(). I added it this way because we need the base field across multiple entity types; both custom and core.

After adding the base field, the autocomplete on the 'Revision User' filter for our view stopped working. It became a text field.

Tracing the issue found this code to be the likely issue.

    if ($revision_table && ($revision_uid_key = $this->entityType->getRevisionMetadataKeys()['revision_user'] ?? '')) {
      $data[$revision_table][$revision_uid_key]['filter']['id'] = 'user_name';
    }

The $revision_table at that point in the execution was using the value for the new base field, rather than the entity base revision table. The value of that is overridden in a loop that processes the field_definitions.

Steps to reproduce

Proposed resolution

Update the loop that processes the field definitions to not reuse / overwrite the variable that is set (and used) at a higher scope.

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

πŸ› Bug report
Status

Active

Version

11.0 πŸ”₯

Component

views.module

Created by

πŸ‡¦πŸ‡ΊAustralia nterbogt

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024