Problem/Motivation

Views currently doesn't provide a relationship from the revision table back to the base table by default.
There are though workarounds in both block_content and node module for that.

Proposed resolution

Let's add it.

Remaining tasks

Provide a patch
Review it

User interface changes

None

API changes

None

Data model changes

None

CommentFileSizeAuthor
#91 Drupal 9.4 - Revision User.png56.33 KBdishabhadra
#91 Drupal 9.3 - Revision User.png77.39 KBdishabhadra
#81 interdiff_79-81.txt134.96 KBmikemiles86
#81 2652652_81.patch17.87 KBmikemiles86
#79 interdiff_77-79.txt7.08 KBmikemiles86
#79 2652652_79.patch18.5 KBmikemiles86
#77 2652652_77.patch17.08 KBGhost of Drupal Past
#75 2652652_75.patch17.45 KBGhost of Drupal Past
#74 2652652_74.patch17.92 KBGhost of Drupal Past
#72 2652652_72.patch16.89 KBGhost of Drupal Past
#71 2652652_71.patch17.05 KBGhost of Drupal Past
#70 2652652_70.patch16.4 KBGhost of Drupal Past
#68 2652652-66.patch10.57 KBminorOffense
#64 2652652-64.patch11.49 KBSam152
#61 2652652-61.patch10.93 KBSam152
#53 2652652-53.patch10.86 KBSam152
#46 reroll-diff-2652652-38-46.txt1.89 KBManuel Garcia
#46 2652652-46.patch12.35 KBManuel Garcia
#42 Screenshot from 2018-01-16 12-35-40.png21.98 KBManuel Garcia
#41 interdiff-revision_table.txt1.01 KBManuel Garcia
#39 2652652-38.patch12.47 KBManuel Garcia
#35 rerroll-2652652-31-36.diff3.27 KBManuel Garcia
#35 2652652-36.patch12.47 KBManuel Garcia
#31 2652652-31.patch12.59 KBSam152
#28 2652652-25.patch12.53 KBSam152
#28 interdiff.txt810 bytesSam152
#25 2652652-25.patch12.53 KBSam152
#22 2652652-22.patch12.28 KBbenjy
#18 adding relationship.png17.6 KBLendude
#18 new label.png10.88 KBLendude
#18 revision_relationship.yml5.62 KBLendude
#17 interdiff.txt3.28 KBdawehner
#17 2652652-18.patch11.98 KBdawehner
#16 2652652-help.png14.38 KBLendude
#16 2652652-label.png13.73 KBLendude
#14 interdiff.txt2.87 KBdawehner
#14 2652652-14.patch11.06 KBdawehner
#12 interdiff.txt526 bytesdawehner
#12 2652652-12.patch10.99 KBdawehner
#9 interdiff.txt1.36 KBdawehner
#9 2652652-9.patch10.53 KBdawehner
#5 interdiff.txt4.67 KBdawehner
#5 2652652-5.patch10.98 KBdawehner
#2 2652652-2.patch7.24 KBdawehner
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dawehner created an issue. See original summary.

dawehner’s picture

Status: Active » Needs review
FileSize
7.24 KB

There we go.

Status: Needs review » Needs work

The last submitted patch, 2: 2652652-2.patch, failed testing.

jibran’s picture

Priority: Normal » Major

Thanks for working on this. This is a huge problem for contrib so it's at least major.

dawehner’s picture

Status: Needs work » Needs review
FileSize
10.98 KB
4.67 KB

There we go.

jibran’s picture

+++ b/core/modules/views/src/ViewsData.php
@@ -125,12 +125,12 @@ public function __construct(CacheBackendInterface $cache_backend, ConfigFactoryI
+      if (TRUE || !isset($this->storage[$key])) {
...
+        if (FALSE && $data = $this->cacheGet($cid)) {

This can't be correct.

Status: Needs review » Needs work

The last submitted patch, 5: 2652652-5.patch, failed testing.

xjm’s picture

Version: 8.0.x-dev » 8.1.x-dev
Category: Bug report » Task
Issue tags: +Triaged core major, +Needs upgrade path, +Needs upgrade path tests

@alexpott, @effulgentsia, @webchick, and I discussed this and agreed it makes sense for this to be marked major. We all thought it was more of a task though.

Finally, I think this is best targeted against 8.1.x. I think we need an upgrade path?

dawehner’s picture

Status: Needs work » Needs review
Issue tags: -Needs upgrade path, -Needs upgrade path tests
FileSize
10.53 KB
1.36 KB

Finally, I think this is best targeted against 8.1.x. I think we need an upgrade path?

I agree with the 8.1.x part, even it actually already helps contrib and especially custom people to integrate their entities.
Regarding the upgrade path, I disagree. We could of course totally implement an empty update function, but this is about it.

alexpott’s picture

I think we need an empty update function to clear cache - unless already have an 8.1.x update function in views which there's not... looks like views_update_8003() and views_update_8004() are going to be the same :)

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.0-beta1 was released on March 2, 2016, which means new developments and disruptive changes should now be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
10.99 KB
526 bytes

Addressed the feedback from alex

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 12: 2652652-12.patch, failed testing.

dawehner’s picture

Status: Needs work » Needs review
FileSize
11.06 KB
2.87 KB

Fixed the failures ...

Lendude’s picture

+++ b/core/modules/views/src/EntityViewsData.php
@@ -233,6 +234,23 @@ public function getViewsData() {
+      $data[$views_revision_base_table][$this->entityType->getKey('id')]['relationship'] = [
...
+        'base field' => $this->entityType->getKey('id'),
...
+      $data[$views_revision_base_table][$this->entityType->getKey('revision')]['relationship'] = [
...
+        'base field' => $this->entityType->getKey('revision'),

Maybe replace $this->entityType->getKey('revision') and $this->entityType->getKey('id') with $revision_field and $base_field, these variables are already set earlier in the method anyway and would make this a little easier to read.

Lendude’s picture

Issue summary: View changes
Status: Needs review » Needs work
FileSize
13.73 KB
14.38 KB
+++ b/core/modules/views/src/EntityViewsData.php
@@ -233,6 +234,23 @@ public function getViewsData() {
+        'label' => $this->t('Get the actual @label from a @label revision', ['@label' => $entity_type_label]),

This looks more like a help text, and with the 'Get' look a bit weird as a label and could probably be shortened to just 'Content' since everything from the revision is marked 'Content revision'. See screenshots for how this looks now.

No help makes it unclear what the difference between these two thing is:

The label looks weird and way to long:

Manually tested the patch and I got:
Drupal\Core\Database\IntegrityConstraintViolationException: SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'langcode' in field list is ambiguous: SELECT node_field_data_node_field_revision.langcode AS node_field_data_node_field_revision_langcode, node_field_revision.vid AS vid, node_field_data_node_field_revision.nid AS node_field_data_node_field_revision_nid, langcode AS langcode FROM {node_field_revision} node_field_revision LEFT JOIN {node_field_data} node_field_data_node_field_revision ON node_field_revision.nid = node_field_data_node_field_revision.nid WHERE (( (node_field_revision.status = :db_condition_placeholder_0) )) LIMIT 11 OFFSET 0; Array ( [:db_condition_placeholder_0] => 1 )

Didn't dig any further yet to find out if this also happens without this patch applied with the original relationships.

dawehner’s picture

Status: Needs work » Needs review
FileSize
11.98 KB
3.28 KB

@Lendude
Good point!

Can you please though try to provide a view which reproduces the problem you've described? I tried to get that, but I couldn't

Lendude’s picture

Issue summary: View changes
Status: Needs review » Needs work
FileSize
5.62 KB
10.88 KB
17.6 KB

Attached an export with a failing View. Basic steps to reproduce, multiple languages enabled, View showing node revisions, add relationship to content -> fail. But....this is just as broken without the patch, so no new fails get introduced and maybe we should open a separate issue for this.

But to the patch:
The new label is definitely shorter then it was, but this might be a bit too short :)

The 'add' dialog is still a bit ambiguous (but definitely better then it was). Any way to to make the difference between these two options clearer?

TravisCarden’s picture

@Lendude: I created #2714717: Content (nid) relationship joins to wrong nodes, which may capture the bug you refer to creating a separate issue for in #18.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

benjy’s picture

We're using this patch against 8.3.x if anyones interested.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Sam152’s picture

Status: Needs work » Needs review
FileSize
12.53 KB

Reroll against 8.4.x.

Status: Needs review » Needs work

The last submitted patch, 25: 2652652-25.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

Sam152’s picture

I have a bunch of views that were affected by The 'content_revision_tracker' table from Content Moderation has been removed. This patch is now essential for displaying any non-revisionable field on a custom entity with the revision table as the base.

I do agree with #18 however, the label is a little confusing in the list.

Sam152’s picture

Status: Needs work » Needs review
FileSize
810 bytes
12.53 KB

I botched the reroll. Fixing.

Sam152’s picture

+++ b/core/modules/views/src/EntityViewsData.php
@@ -243,6 +247,22 @@ public function getViewsData() {
+      $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]),
+      ];

Can I ask what this actually does? Why would we need a relationship from the revision table to the base table based on the revision ID? Does that mean the relationship would fail/not-exist if the given revision wasn't default? Because vid in the base table doesn't match vid in the revision?

If that's the reason we're adding it, we have @ViewsFilter("latest_revision") instead and should probably rely on that instead of joining a table to access the same data?

Status: Needs review » Needs work

The last submitted patch, 28: 2652652-25.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

Sam152’s picture

Status: Needs work » Needs review
FileSize
12.59 KB

Uploaded wrong patch in #28.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

The only thing I was wondering: Should we have some test which actually executes some query? I think we have some test coverage for node module though which should cover that

The last submitted patch, 22: 2652652-22.patch, failed testing. View results

Sam152’s picture

Status: Reviewed & tested by the community » Needs review

I was going to propose removing a chunk of the patch in #29, do you know if that part is still relevant? If there is a use case for it or I'm misunderstanding, happy to put back to RTBC.

Manuel Garcia’s picture

Reroll of #31.
Manually fixed conflicts on:

  • core/modules/views/src/EntityViewsData.php
  • core/modules/views/views.install
Manuel Garcia’s picture

Ow, the bot runs .diff files as well.. sorry.

Manuel Garcia’s picture

<        $views_field_name = ($multiple) ? $field_name . '__' . $field_column_name : $field_name;
< -      $table_data[$views_field_name] = $this->mapSingleFieldViewsData($table, $field_name, $field_definition_type, $field_column_name, $field_schema['columns'][$field_column_name]['type'], $first, $field_definition);
< +
---
> -      $table_data[$schema_field_name] = $this->mapSingleFieldViewsData($table, $field_name, $field_definition_type, $field_column_name, $field_schema['columns'][$field_column_name]['type'], $first, $field_definition);

This part of the reroll I've realized is not correct, since $views_field_name is no longer set previously.

Status: Needs review » Needs work

The last submitted patch, 35: rerroll-2652652-31-36.diff, failed testing. View results

Manuel Garcia’s picture

This should hopefully be a correct reroll of #31.

Diff against #35:

diff --git a/core/modules/views/src/EntityViewsData.php b/core/modules/views/src/EntityViewsData.php
index 028687f..34de2e5 100644
--- a/core/modules/views/src/EntityViewsData.php
+++ b/core/modules/views/src/EntityViewsData.php
@@ -409,8 +409,8 @@ protected function mapFieldDefinition($table, $field_name, FieldDefinitionInterf
     foreach ($field_column_mapping as $field_column_name => $schema_field_name) {
       // The fields might be defined before the actual table.
       $table_data = $table_data ?: [];
-      $table_data += [$views_field_name => []];
-      $table_data[$views_field_name] = NestedArray::mergeDeep($table_data[$views_field_name], $this->mapSingleFieldViewsData($table, $field_name, $field_definition_type, $field_column_name, $field_schema['columns'][$field_column_name]['type'], $first, $field_definition));
+      $table_data += [$schema_field_name => []];
+      $table_data[$schema_field_name] = NestedArray::mergeDeep($table_data[$schema_field_name], $this->mapSingleFieldViewsData($table, $field_name, $field_definition_type, $field_column_name, $field_schema['columns'][$field_column_name]['type'], $first, $field_definition));
       $table_data[$schema_field_name]['entity field'] = $field_name;
       $first = FALSE;
     }

The last submitted patch, 35: 2652652-36.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

Manuel Garcia’s picture

Re: #29 - I agree this relationship doesn't add much value. Instead, let's add the missing relationship to the $revision_table (node_revision for nodes), so as to give access to the revision_log, revision date, etc.

I attach the interdiff that would get this working, please let me know what you think :)

This has been requested here #2674518: Add revision log field to views, and I think it would be very useful for content editors =)

Manuel Garcia’s picture

It is also not clear what the difference is between these two in the UI (see #29):

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

griffincox’s picture

I'm having a problem that I think is related to this issue. In my standard 'Content' view, I'm trying to add the column "Last Updated By". When I add a User relationship, I should be able to put in a User:Name field that references the User relationship, which ultimately should supply the user that last updated the node... right? Instead, it's supplying the original author of the node, as if it were referencing the Author relationship.

alphawebgroup’s picture

#39 patch could not be applied to 8.6.x anymore... sorry

alphawebgroup’s picture

now it's not compatible with 8.5.x

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Manuel Garcia’s picture

Issue summary: View changes
amateescu’s picture

+++ b/core/modules/views/src/EntityViewsData.php
@@ -250,6 +254,22 @@ public function getViewsData() {
+      // Add a relationship from the revision table back to the main table.

As found and fixed in #2977276: Node views integration that joins revisions to the default entity fails to consider langcode, resulting in duplicate rows, we should include the langcode as an "extra" join argument if the entity types are translatable.

jibran’s picture

Status: Needs review » Needs work

NW for #50.

+++ b/core/modules/views/views.install
@@ -532,3 +532,10 @@ function views_update_8500() {
+function views_update_8501() {

This should be converted into a post-update hook.

Wim Leers’s picture

Sam152’s picture

Status: Needs work » Needs review
FileSize
10.86 KB

Straight reroll.

jibran’s picture

Status: Needs review » Needs work

#51 is still pending.

Anas_maw’s picture

+1 for #41, adding a relation to the revision table will give us access to date and log message.

Pancho’s picture

Just a recap. Current patch needs work for:

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

eddi86’s picture

It's a little bit confusing... which patch should i use to get a solution for #44 with translated nodes/entities?
I use 8.6.14

eddi86’s picture

After testing patch from #46 (applying with problems) i was able to get the revision user name - but only when checked "create new revision" in node edit. The "last updating user" is not stored in the DB without creating a new revision... the uid in "node_revision" table is still the author of the node.

Is this the way to go in Drupal 8, save every change in a new revision? Maybe this should be discused in a new issue.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Sam152’s picture

Status: Needs work » Needs review
FileSize
10.93 KB

Rerolling.

Manuel Garcia’s picture

Status: Needs review » Needs work

Thanks for the reroll @Sam152

Setting to needs work because although its very close, we still have a bit of work to do, see #56

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Sam152’s picture

Status: Needs work » Needs review
FileSize
11.49 KB

Rerolling #61 for 9.1.

Sam152’s picture

Status: Needs review » Needs work

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

minorOffense’s picture

Updated the patch for Drupal 9.2.x

Looks like they moved one of the test files and two of the test modifications are already part of the new test file.

minorOffense’s picture

Patch appears to apply to 9.3 and 9.4. Figure run the tests and see what it says. I guess not then. That's weird cause it applied locally. Well maybe I'll take a shot at updating it again...

Ghost of Drupal Past’s picture

I added

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

currently user_name is added in Node and Media, this is likely unnecessary after slamming it like this. Not a lot remained of MediaViewsData which I consider a good thing. NodeViewsData also sees a healthy trim.

Ghost of Drupal Past’s picture

FileSize
17.05 KB
Ghost of Drupal Past’s picture

FileSize
16.89 KB

Status: Needs review » Needs work

The last submitted patch, 72: 2652652_72.patch, failed testing. View results

Ghost of Drupal Past’s picture

Status: Needs work » Needs review
FileSize
17.92 KB

Now with more langcode. All the previous versions didn't take langcode into account.

Ghost of Drupal Past’s picture

FileSize
17.45 KB
jibran’s picture

Status: Needs review » Reviewed & tested by the community

Wow, this issue is still open. I reviewed it again. Code changes and test coverage looks good. Only one observation but other than that this is RTBC.

+++ b/core/modules/views/tests/src/Kernel/Entity/EntityViewsDataTest.php
@@ -483,7 +512,8 @@ public function testDataTableFields() {
-      'extra' => [[
+      'extra' => [
+        [

Seems like an unwanted change.

Ghost of Drupal Past’s picture

FileSize
17.08 KB

Removed that. No other change.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
  1. +++ b/core/modules/views/src/EntityViewsData.php
    @@ -132,7 +133,9 @@ public function getViewsData() {
    +    $entity_id_key = $this->entityType->getKey('id');
    +    $base_field = $entity_id_key;
    

    I think that rather than have both $entity_id_key and $base_field we should have only one. Changing the existing usages of $base_field to $entity_id_key seems fine to me.

  2. +++ b/core/modules/views/tests/src/Kernel/Entity/EntityViewsDataTest.php
    @@ -256,6 +256,13 @@ public function testRevisionTableWithoutDataTable() {
    +    $this->assertTrue(!empty($revision_data['id']['relationship']));
    ...
    +    $this->assertTrue(!empty($revision_data['revision_id']['relationship']));
    

    $this->assertNotEmpty() - but also given the following assertions - not sure these are required.

  3. +++ b/core/modules/views/tests/src/Kernel/Entity/EntityViewsDataTest.php
    @@ -294,16 +301,27 @@ public function testRevisionTableWithRevisionDataTableAndDataTable() {
    +    $this->assertTrue(!empty($revision_field_data['id']['relationship']));
    ...
    +    $this->assertTrue(!empty($revision_field_data['revision_id']['relationship']));
    

    As above.

  4. +++ b/core/modules/views/tests/src/Kernel/Entity/EntityViewsDataTest.php
    @@ -341,15 +359,26 @@ public function testRevisionTableWithRevisionDataTable() {
    +    $this->assertTrue(!empty($revision_field_data['id']['relationship']));
    ...
    +    $this->assertTrue(!empty($revision_field_data['revision_id']['relationship']));
    
    @@ -583,6 +612,13 @@ public function testRevisionTableFields() {
    +    $this->assertTrue(!empty($data['entity_test_mulrev_property_revision']['id']['relationship']));
    ...
    +    $this->assertTrue(!empty($data['entity_test_mulrev_property_revision']['revision_id']['relationship']));
    

    Same again...

  5. +++ b/core/modules/views/views.install
    @@ -18,3 +18,10 @@ function views_install() {
    +/**
    + * Clear views data cache.
    + */
    +function views_update_8501() {
    +  // Empty update function to rebuild the views data.
    +}
    

    Use hook_post_update_NAME and not a schema numbered update. It's not necessary to use hook_update_N here.

mikemiles86’s picture

FileSize
18.5 KB
7.08 KB

I've made changes @alexpott recommended to the patch from #77.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

mikemiles86’s picture

FileSize
17.87 KB
134.96 KB

Updated the patch for 9.4.x and removed the unneeded AssertNotEmpty() tests that were in patch #79.

Ghost of Drupal Past’s picture

Status: Needs work » Reviewed & tested by the community

This concludes everything Alex asked for and it was RTBC before. Thanks!

alexpott credited webchick.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs change record

The code looks great. We need a CR to tell developers about this change and the fact that they can remove code from contrib / custom entity types that provide this relationship because core views will now add it automatically.

jibran’s picture

Status: Needs work » Reviewed & tested by the community
Issue tags: -Needs change record
alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed 45347fa580 to 10.0.x and d9bd98f6ed to 9.4.x. Thanks!

Thanks @jibran

  • alexpott committed 45347fa on 10.0.x
    Issue #2652652 by dawehner, Sam152, Charlie ChX Negyesi, Manuel Garcia,...

  • alexpott committed d9bd98f on 9.4.x
    Issue #2652652 by dawehner, Sam152, Charlie ChX Negyesi, Manuel Garcia,...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

dishabhadra’s picture

As this issue is merged into Drupal 9.4, it fixes the adding the relationship into view automatically for all entities.

But the above patch is not adding filter user_name for node_revision, media_revision and block_content_revision table.

Eg,

$data['node_revision']['revision_uid']['help'] = $this->t('The user who created the revision.');
$data['node_revision']['revision_uid']['relationship']['label'] = $this->t('revision user');
$data['node_revision']['revision_uid']['filter']['id'] = 'user_name';
$data['node_revision']['table']['join']['node_field_data']['left_field'] = 'vid';
$data['node_revision']['table']['join']['node_field_data']['field'] = 'vid';

Similarly for media_revision and block_content_revision as well.

Before Drupal 9.4 if the content view is using the "Revision User" field was showing the username for the current revision now showing User ID instead of Username and it is breaking the display.

Drupal 9.3 - Revision User Field: 9.3

Drupal 9.4 - Revision User Field:9.4

There are related issues with "Revision User" field to show the author name it was added into Drupal core 8.9 onwards and now it got removed again.

https://www.drupal.org/project/drupal/issues/2769289
https://www.drupal.org/project/drupal/issues/3113986

smustgrave’s picture