Under the current node revisions overview logic, it is possible for a page of the revisions listing to show no revisions. This is confusing.
The NodeController->revisionsOverview() method reads in all revisions of the current node, and then filters them down according to whether the revision in question has a translation for the currently active language, and whether that revision translation is 'affected'. This was done in #2465907: Node revision UI reverts multiple languages when only one language should be reverted to address the issue of the revision UI reverting multiple translations when it shouldn't be.
Because the paging of the revisions query doesn't account for language and 'affected' state, it is possible for the revisions query to return a set of revisions for a node of which none of the revisions belong to the language being tested, nor are any of them marked as 'affected'. This filters the list down to zero, which results in an empty table of revisions for that page, which is confusing.
It's possible for this situation to arise on a site with many active languages. Given a site with 55 languages, if a node goes through translation, and there is a new revision for each language that is translated, it would be very possible for a given page of revisions to contain no revisions eligible for display.
The logic which filters down the returned page of revisions to the current language and 'affected' should be able to be pushed into the revision query itself (NodeController->getRevisionIds()). Since this is a protected method not called anywhere else, it should be safe to add these conditions to the query, to allow the pager to function properly.
| Comment | File | Size | Author |
|---|---|---|---|
| #27 | node-revision-overview-2916172-27.patch | 981 bytes | falco010 |
| #2 | 2916172_2_node_revision_overview_page.patch | 6.39 KB | timcosgrove |
Issue fork drupal-2916172
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:
- 2916172-add-meta-data
changes, plain diff MR !9296
- 2916172-node-revision-ui
changes, plain diff MR !9289
Comments
Comment #2
timcosgrove commentedThe attached patch works to rectify the situation. Review by those who know core better than me appreciated!
Comment #3
timcosgrove commentedComment #4
timcosgrove commentedComment #5
timmillwoodThis sounds similar to #2769741: Node revisions page might not list a default revision.
In that issue there was a lot of discussion around what the expected behaviour is. I think we need to fully nail down what that expected behaviour is, and clear it with the UX team, then work with a test driven approach to nail down the behaviour in a test.
Comment #6
timcosgrove commentedIt's somewhat similar, but for this case, the query that generates a page of 50 revisions doesn't take into account the further filtering that happens. All filtering should be part of the query if possible, so that the query is actually legitimate.
I have no strong opinion about #2769741: Node revisions page might not list a default revision though I think it's a legitimate issue. In this case, the query is simply badly constructed.
Comment #10
ahebrank commentedReroll for 8.6 since I just ran into this on an older site.
Comment #13
johan.s commentedAttached patch for version 8.7.7
Comment #14
firewaller commented+1
Comment #16
gantal commentedTagging for DrupalCamp Colorado's upcoming contrib day.
Comment #17
johan.s commentedComment #19
falco010#17 successfully applied for me on 8.9.10 and solved the pagination issue for me. Our Drupal installation also has a lot of languages (30+) as described in the issue description.
Comment #20
anmolgoyal74 commentedIgnore this one.
Comment #21
anmolgoyal74 commentedAdding the same patch for 9.2.x.
Comment #23
falco010All the above patches seem to break the work done in here:
https://www.drupal.org/project/drupal/issues/2938947
https://git.drupalcode.org/project/drupal/commit/41116a5
Which solved the issue that some revision lists would not have any "Current revision". This issue seems to be happening for me again now.
This might be because of this issue and the first patch was created earlier than the issue above.
All changes done in the NodeController.php in the patches above don't make any sense anymore and are not needed anymore. (tested this)
We can simplify the patch much more now, where we only have to change the query.
I will add a new patch where I revert all the changes in NodeController.php because they are not needed anymore.
I tested this new patch on 8.9.10 with 30+ languages and the pagination is working fine and it solves the "Current revision" issue (again) that I was having again.
Comment #24
golddragon007 commentedI'm working currently on the https://www.drupal.org/project/drupal/issues/1863906 to see if I can fix there the issues, and I noticed that, it's not correct to use the `->condition($node->getEntityType()->getKey('revision_translation_affected'), '1')` condition, if you revert a translation to a previous version, then it won't be visible the current revision...
Comment #25
golddragon007 commentedBut it seems it works here properly, because of the custom conditions in the code regarding the latest version...
The #23 works fine, however @Falco010 can you remove the `if ($revision->hasTranslation($langcode) && $revision->getTranslation($langcode)->isRevisionTranslationAffected()) {` as it become useless.
Comment #27
falco010Rerolling for 9.2.x
Comment #30
immaculatexavier commentedReviewed whether the old patch still applies to the latest code and passes automated tests.
Steps taken to review:
Downloaded the latest patch file.
Result:
Verified the patch applied successfully, and the automated test passed successfully.
Comment #31
immaculatexavier commentedChanged to Need review for other test scenarios
Comment #33
heddnThere's still some oddness going on here. If a specific translation doesn't exist and one visits the revisions tab, the langcode returned is for the default language, not the interface language. I think we should make that more obvious in the UI somehow. Maybe we need to list the language as the default instead? Alternatively, filter here by the interface language and show zero revisions.
Comment #35
recrit commentedRegarding #33, using the node language will be the correct language once the loaded node is correct for the interface language per #3092558: Revisions log on translated nodes should not show original language revisions, should show revisions of translated content
Comment #36
recrit commentedComment #37
recrit commentedComment #38
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue.
While you are making the above changes, we recommend that you convert this patch to a merge request. Merge requests are preferred over patches. Be sure to hide the old patch files as well. (Converting an issue to a merge request without other contributions to the issue will not receive credit.)
Comment #42
samitk commentedComment #45
romixuaBy adding addMetaData('langcode', $langcode) we fix this issue and provide correct check by nodes grants
Comment #46
smustgrave commentedIssue summary appears incomplete, recommend using the standard issue template.
Also can a test case be added for this scenario to show the problem.
Comment #47
acbramley commentedThis is a duplicate of #2722307: Move translation based conditions into database query on revisions overview page I'll close this one as work has been started over there with a more fleshed out solution.
Comment #48
lisotton commented@acbramley I do not agree that #2722307 is a better solution. There the behavior has completely changed and not only the affected revisions are displayed.
With patch provided by @falco010 in #27, it is only filtering at the query level, but the same revisions are displayed as before, but we don't have empty pages anymore.
@romixua your suggestion did not work, I tried to apply the patch your provided in the MR, but I will have empty pages.
Comment #49
acbramley commentedHi @lisotton I understand where you're coming from but:
1. That issue also includes the langcode filter
2. There's no reason to have 2 issues open that touch the same code in similar ways. If we find in that issue that we don't want to remove the affected revisions check then we will remove it there, meaning it is exactly the same as this issue. Having both issues open is just splitting effort and making it confusing for contributors.
We should focus efforts on a single issue and since this one has the least recent activity and the MR is not up to date I think we should still close this one.
Please provide testing and feedback on #2722307: Move translation based conditions into database query on revisions overview page.