- Issue created by @twod
Revision based Views of entities are unable to add a relation back to the main entity table.
Core normally adds this in its EntityViewsData::getViewsData()
method, here:
$data[$views_revision_base_table][$entity_id_key]['relationship'] = [
'id' => 'standard',
'base' => $views_base_table,
'base field' => $entity_id_key,
'title' => $entity_type_label,
'help' => $this->t('Get the actual @label from a @label revision', ['@label' => $entity_type_label]),
];
$data[$views_revision_base_table][$entity_revision_key]['relationship'] = [
'id' => 'standard',
'base' => $views_base_table,
'base field' => $entity_revision_key,
'title' => $this->t('@label revision', ['@label' => $entity_type_label]),
'help' => $this->t('Get the actual @label from a @label revision', ['@label' => $entity_type_label]),
];
Then it calls into $this->mapFieldDefinition()
for most fields on each of the entity tables.
Entity API's override of that method does not merge the existing Views data for those fields, and instead overwrites it.
This causes the relation added between the base [data] table and the revision [data] table using the entity id fields to be lost.
It appears Core added this relation after Entity API made the override so it was likely overlooked (and Commerce module likely did the same thing for its override.)
The issue was noticed when attempting to recreate the Node revision View bundled with Content Moderation for a custom entity type, and we were unable to add the relation back to the entity's base table.
Perform the same NestedArray::mergeDeep()
the base class does in the overridden method.
* Implement fix.
None. (Other than restoring the missing relation as a possible option.)
None.
None.
Active
1.0
Views integration