Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
In NodeViewsData
$data['node_revision']['nid']['relationship']['id'] = 'standard';
$data['node_revision']['nid']['relationship']['base'] = 'node';
$data['node_revision']['nid']['relationship']['base field'] = 'nid';
$data['node_revision']['nid']['relationship']['title'] = t('Content');
$data['node_revision']['nid']['relationship']['label'] = t('Get the actual content from a content revision.');
$data['node_revision']['vid'] = array(
'argument' => array(
'id' => 'node_vid',
'numeric' => TRUE,
),
'relationship' => array(
'id' => 'standard',
'base' => 'node',
'base field' => 'vid',
'title' => t('Content'),
'label' => t('Get the actual content from a content revision.'),
),
) + $data['node_revision']['vid'];
and now in #1984582: Add views support for custom blocks
$data['block_content_revision']['id']['relationship']['id'] = 'standard';
$data['block_content_revision']['id']['relationship']['base'] = 'block_content';
$data['block_content_revision']['id']['relationship']['base field'] = 'id';
$data['block_content_revision']['id']['relationship']['title'] = $this->t('Block Content');
$data['block_content_revision']['id']['relationship']['label'] = $this->t('Get the actual block content from a block content revision.');
$data['block_content_revision']['revision_id']['relationship']['id'] = 'standard';
$data['block_content_revision']['revision_id']['relationship']['base'] = 'block_content';
$data['block_content_revision']['revision_id']['relationship']['base field'] = 'revision_id';
$data['block_content_revision']['revision_id']['relationship']['title'] = $this->t('Block Content');
$data['block_content_revision']['revision_id']['relationship']['label'] = $this->t('Get the actual block content from a block content revision.');
Proposed resolution
If entity is revisionable then we can add these relationships by default in EntityViewsData
Remaining tasks
Create patch
User interface changes
None
API changes
Simple code moment so none.
Comments
Comment #1
dawehnerI'm not entirely sure whether this is fixed, but there maybe is a reason for the existence of https://github.com/Jaesin/content_entity_base/blob/master/src/Entity/Vie...
Comment #2
dawehnerAdded a really related issue: #2630886: Correct the join from revision data table to revision base table
Comment #3
dawehnerOh well #2652652: Provide a relationship from the revision table to the main table now has that.