Problem/Motivation

Node revisions tab at `/node/{nid}/revisions` route have "Current Version" on every Page.

The problem is that the second page is just labeling the first revision as "current revision" (though it is not). Essentially, the way core currently works is that the second and subsequent pages of revisions will always label the first listed revision as as "current."

Steps to reproduce

  • Create a Page.
  • Add revisions. Enough to generate pagination
  • Check the Revisions tab on page 2 or any other page. You'll see Current revision listed at the top, but its not the current one.

Proposed resolution

Display "current revision" only on first page.

Screenshots

Before
Page 1
Page
Page 2
Page 2

Issue fork drupal-3021671

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

visabhishek created an issue. See original summary.

visabhishek’s picture

I have noticed if I changed the following code in core/modules/node/src/Controller/NodeController.php then everything is fine for me

public function revisionOverview

$is_current_revision = $vid == $default_revision || (!$current_revision_displayed && $revision->wasDefaultRevision());

to

$is_current_revision = $vid == $default_revision;
berdir’s picture

Status: Active » Postponed (maintainer needs more info)

I don't understand what the problem is, please describe what you think is wrong and how it should be.

visabhishek’s picture

Hi Berdir,

The link under the revisions columns and "Current Revision" under the operation column is the same for all pages as you can see in the attached screenshot.

I think "Current Revision" should come on the first page only.

berdir’s picture

Status: Postponed (maintainer needs more info) » Active

Ah, now I get it, you mean different pages of the pager. I missed the page argument in the URL.

Your fix isn't correct though, I think what we likely need is to add an *additional* check instead that excludes page > 0. That would theretically still be breakable if you have so many drafts that the actual current revision is the on the second page, but that seems like a pretty unlikely scenario.

visabhishek’s picture

Ah, right, this solutions will not work when we have so many drafts that the actual current revision is the on the second page. I will check this scenario also and try to introduce a patch.

visabhishek’s picture

Status: Active » Needs review
StatusFileSize
new54.89 KB
new60.07 KB
new59.8 KB
new878 bytes

Hi Berdir,

I have tried with the above scenario and its working fine, Screenshot is attached with draft pagination.

Status: Needs review » Needs work

The last submitted patch, 7: node_revisions_issue-3021671-07.patch, failed testing. View results

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

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.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.

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

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should 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.

vodde83’s picture

I have this issue as well, and can confirm that the patch does indeed fix it.
I'm curious however, how there's so little feedback as this still seems to be an issue?

It's not just a visual issue, as this issue makes it impossible to revert back to any of those revisions that are displayed incorrectly as 'Current revision' ( as there are no available 'Operations' in that case ).

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

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev
mediabounds’s picture

StatusFileSize
new2.67 KB

The patch in #7 assumes that the default revision on a node is displayed in the revisions table--but the revisions table filters to only show revisions where the the current translation is affected. This gets caught by the failing test in NodeRevisionsUiTest.

There is an identical bug reported in #3082614: Node revisions: in paged lists, the first revision in any page is always marked as default, but the patch there has the same problem and doesn't fix the issue if translations are enabled.

I'm taking a different approach: to try to determine which revision ID is the current revision ID by querying the database for the latest revision ID for the current langcode that is both a default revision and affects the current translation. Best I could tell, there was no method in the TranslatableRevisionableStorageInterface API so I'm having the controller do an additional query to the database to find the revision.

mediabounds’s picture

Status: Needs work » Needs review
StatusFileSize
new2.7 KB

Fixing code style in #15.

mdupont’s picture

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

Bumped to 9.4.x which is the current development version

mdupont’s picture

On the one hand, the patch in #16 does the job, and maybe there's no need to over-engineer it if it's the only use-case in core where we need "Give me the current revision ID for the current translation of an entity".

On the other hand, I'm wondering if we should offer this method for all translatable and revisionable entities and add a getCurrentRevisionId() to TranslatableRevisionableStorageInterface. It has more side effects in core and contrib code extending it though.

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

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

SerShevchyk made their first commit to this issue’s fork.

ranjith_kumar_k_u’s picture

StatusFileSize
new2.84 KB
new412 bytes
aarti zikre’s picture

Assigned: Unassigned » aarti zikre

reviewing this

aarti zikre’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new68.29 KB
new76.37 KB

Verified patch for Drupal 9.5.x dev version
https://www.drupal.org/files/issues/2022-07-15/3021671-22.patch

Testing Steps:

* Install a new Drupal instance
* Created basic page
* Edit it multiple times till pages for revisions not create

Problem:
Each revision page's first content shows current version

Test Result:
Verified that after applying patch only latest version content shows current version not other revision pages first row

Refer SS
Before apply Patch

2022-07-15/3021671 before applying patch.png

After Patch
2022-07-15/3021671 after patch.png

Test Result Pass
Can be move to RTBC

aarti zikre’s picture

Assigned: aarti zikre » Unassigned
dww’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Bug Smash Initiative, +Needs tests

Thanks for working on this bug!

However, core committers won't commit this (or most any other issue) without test coverage. As a bug, we want to make sure it never regresses as folks make further changes to the relevant code.

So we need:

  1. A test that demonstrates the problem, uploaded as a failing test-only patch.
  2. A full patch that includes the new test and the patch from #22 which should pass.

Thanks / sorry,
-Derek

smustgrave’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests
StatusFileSize
new1.4 KB
new4.24 KB

Uploaded a test case.

The last submitted patch, 27: 3021671-27-tests-only.patch, failed testing. View results

quietone’s picture

Issue summary: View changes
Status: Needs review » Needs work
Issue tags: +Needs issue summary update

This needs an issue summary update with, at least, before and after screenshots and proposed resolution.

@aarti zikre, thanks for the testing. When making screenshots put the latest before and after in the Issue Summary because it helps the reviewers and committers.

I ran the test locally and have some suggestions.

  1. +++ b/core/modules/node/tests/src/Functional/NodeRevisionsUiTest.php
    @@ -187,4 +187,30 @@ public function testNodeRevisionsTabWithDefaultRevision() {
    +    // Create 75 revisions to generate revisions.
    +    $revision_count = 75;
    

    Why 75? Can we get the number per page from somewhere and use that?

  2. +++ b/core/modules/node/tests/src/Functional/NodeRevisionsUiTest.php
    @@ -187,4 +187,30 @@ public function testNodeRevisionsTabWithDefaultRevision() {
    +      $node->setRevisionLogMessage($this->randomString());
    

    Since we already have a unique value, can we use $i here and skip making a random string.
    $node->setRevisionLogMessage((string) $i);

  3. +++ b/core/modules/node/tests/src/Functional/NodeRevisionsUiTest.php
    @@ -187,4 +187,30 @@ public function testNodeRevisionsTabWithDefaultRevision() {
    +    $this->assertSession()->addressEquals('node/' . $node->id() . '/revisions?page=1');
    +    $this->assertSession()->pageTextNotContains('Current revision');
    

    If the revision count is less that the number of revisions per page, these assertions pass. I think there should be an assertion that fails if there are no revisions on page 1.

smustgrave’s picture

Issue summary: View changes
Issue tags: -Needs issue summary update
smustgrave’s picture

Status: Needs work » Needs review
StatusFileSize
new4.38 KB
new1.24 KB

Addressed issues #29.1,2,3 and updated issue summary

Aamir M’s picture

Assigned: Unassigned » Aamir M
Aamir M’s picture

Assigned: Aamir M » Unassigned
Status: Needs review » Reviewed & tested by the community
StatusFileSize
new130.24 KB
new83.61 KB
new303.12 KB
new82.14 KB
new73.56 KB

Verified and tested patch #31 on Drupal 9.5.x-dev. Patch applied successfully and looks good to me.

Testing steps:
1. Go to Content
2. Click on + Add content
3. Select a Basic page then enter the title and Save the page
4. Now a new basic page is created. Edit this page again and again until pagination is created
5. Go to the revisions tab and observe the 1st page and 2nd page
6. Current revision is displayed on both page
7. Apply patch
8. Reload the page and observe
9. Now the Current revision is displayed only on the 1st page at the top

Testing Result:
1. After applying the patch the Current revision is displayed only on the 1st page at the top

Can be moved to RTBC

parashram’s picture

While applying comment #16 patch on Drupal v 9.4.3 and PHP 8.0, it's getting fail and composer gives below error:

The error was: Cannot apply patch https://www.drupal.org/files/issues/2022-01-15/3021671-16-determine_curr...
patching file modules/node/src/Controller/NodeController.php
Hunk #1 FAILED at 164.
Hunk #2 succeeded at 182 (offset 1 line).
Hunk #3 succeeded at 302 (offset 2 lines).
1 out of 3 hunks FAILED -- saving rejects to file modules/node/src/Controller/NodeController.php.rej

Do we have any specific patch for drupal version 9.4.3 and PHP 8.0 ? How can we apply this patch for the mentioned setup ?

quietone’s picture

Status: Reviewed & tested by the community » Needs work

@Aamir M, Welcome to Drupal! Thanks for testing the patch, when the testing includes screenshots they should be added to the issue summary in the user interface section. Thanks

@smustgrave, thanks for the updated patch.

Just some minor things.
The changes made in the patch have not been reviewed and since there were changes made to the test can we have a fail patch.

+++ b/core/modules/node/tests/src/Functional/NodeRevisionsUiTest.php
@@ -210,6 +210,8 @@
+    // Verify the first revision exists on page1.

s/page1/page 1/

I have not reviewed the code or the changes to the test.

smustgrave’s picture

Actually rethinking this one I’m not sure it’s a bug? If the current revision isn’t on every page are you able to compare revisions across pages?

parashram’s picture

Version: 9.5.x-dev » 9.4.x-dev
Status: Needs work » Needs review
StatusFileSize
new2.43 KB

Test patch with Drupal v 9.4.3 and PHP 8.0

smustgrave’s picture

@Parashram can you please upload an interdiff if you are going to submit a patch.

Manibharathi E R’s picture

StatusFileSize
new123.06 KB
new122.85 KB

Patch #31 Tested on Drupal 9.4.x-dev. Patch applied successfully.
Before the patch
Before-Patch
After The Patch
After-Patch

parashram’s picture

StatusFileSize
new1.82 MB

Patch #31 working on Drupal 9.4.3, PHP 8.0

parashram’s picture

smustgrave’s picture

Status: Needs review » Needs work

Patch isn’t passing core tests so testing manually doesn’t count

berdir’s picture

> Actually rethinking this one I’m not sure it’s a bug? If the current revision isn’t on every page are you able to compare revisions across pages?

FWIW, drupal core doesn't allow you to actually compare versions, that's diff.module which mostly replaces the current core functionality, as there's not really another way. With core, you can just manually compare by viewing the different revisions in separate tabs, that could be done across multiple pages.

That said, I do agree that maybe this needs a UX review. There might be (better?) alternatives to just removing it, maybe show it separately and not in the main list?

berdir’s picture

There's also something strange about the screenshots. It still shows 3 revisions on the second page, I would expect one less if it doesn't repeat the current one?

mediabounds’s picture

The current problem is that the second page is just labeling the first revision as "current revision" (though it is not). Essentially, the way core currently works is that the second and subsequent pages of revisions will always label the first listed revision as as "current."

So I think there is a discrete bug here that can still be addressed while maybe separately considering UX improvements.

ravi.shankar’s picture

StatusFileSize
new4.38 KB
new834 bytes
new1.53 KB

Added test only patch and fixed one nit of patch #31 as mentioned in comment #35.

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

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

parashram’s picture

Hi All,

Is it working for Drupal 10?

Thanks!

Manibharathi E R’s picture

StatusFileSize
new274.96 KB
new265.46 KB

Patch #46 Tested on Drupal 9.5.x-dev. Patch applied successfully.
For the Drupal 10 test case is failing. Need to fix the test cases.
Before Patch:
Before-patch
After Patch:
After-patch

Version: 9.5.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

piotrsmykaj’s picture

StatusFileSize
new4.38 KB

.

piotrsmykaj’s picture

StatusFileSize
new4.38 KB

Re-roll of #46 against Drupal 10.2.x.

sokru made their first commit to this issue’s fork.

sokru’s picture

Issue summary: View changes
Status: Needs work » Needs review
Related issues: +#2938947: Always list a "Current revision" for each available content translation

Updated the issue summary and rebased the MR to 11.x branch. I agree with #45 that doing more complete UX renew should be done on separate issue so we could fix this 6 years old issue first.

sokru changed the visibility of the branch 3021671-node-revisions-tab to hidden.

smustgrave’s picture

Status: Needs review » Needs work

1 test I think we should consider is what if someone wnats to compare current revision with a revision on a 2nd page, will that still be possible.

sokru’s picture

Status: Needs work » Needs review

we should consider is what if someone wnats to compare current revision with a revision on a 2nd page, will that still be possible.

Quoting @berdir from #43

drupal core doesn't allow you to actually compare versions, that's diff.module which mostly replaces the current core functionality, as there's not really another way. With core, you can just manually compare by viewing the different revisions in separate tabs, that could be done across multiple pages.

I assume we don't want to include Diff module into core on this issue, so setting back to Needs review. Diff module uses routeSubscriber so changes in this MR does not have effect on Diff module.

smustgrave’s picture

Status: Needs review » Needs work
sokru’s picture

Status: Needs work » Needs review

Feedback has been addressed.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +Needs Review Queue Initiative

All feedback appears to be addressed.

quietone’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Usability, +Needs usability review, +Needs screenshots

In #43 a UX review was asked for and I don't see that. Tagging for a review.

At least one thing that will be needed here is up to date screenshot available form the Issue summary. That same would be true for testing results. If they are in the issue summary, then the reviewer can find the correct work to review.

acbramley’s picture

Status: Needs work » Postponed (maintainer needs more info)

Is this worth spending time on given this will swap to the generic revision UI in #3153559: Switch Node revision UI to generic UI?

I also noticed other weird behaviour when testing this such as the "Current revision" on the second page shows the revision log message of a different revision.

smustgrave’s picture

Wanted to give 1 more bump for #63

sokru’s picture

Can confirm that #3153559: Switch Node revision UI to generic UI would make this obsolete.

smustgrave’s picture

Status: Postponed (maintainer needs more info) » Closed (duplicate)

Lets close this one as a duplicate then thanks for following up!

Now that this issue is closed, please review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, please credit people who helped resolve this issue.