Problem/Motivation
A node that contains a paragraph throws this error while doing several translations.
This translation cannot be accepted as there is a pending revision in the default translation.
Possible follow up of #2978341: Support pending revisions and accepting translation as a specific moderation state
Steps to reproduce
- Use latest dev release (with https://git.drupalcode.org/project/tmgmt/commit/895bc68)
- Enable Translation Management Demo or use TMGMT with at least 2 more languages
- Enable Paragraphs, create a paragraph type with a translatable text field
- Add a Paragraph field that makes use of this paragraph type to a content type
- Create a source node in EN
- Request a translation job for FR, save then save as completed (published)
- Request a translation job for DE, save then save as completed (published)
On the first (FR) translation everything looks good, the FR node is published
On the second (DE) translation it's fine on save, then fails while saving as completed.
Reproduced with this setup:
- with or without revisions enabled
- with or without content moderation states for this content type
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #13 | interdiff-3174543-11-13.txt | 1.12 KB | johnchque |
| #13 | 3174543-translation-accepted-13.patch | 3.82 KB | johnchque |
| #11 | interdiff-3174543-7-11.txt | 991 bytes | johnchque |
| #11 | 3174543-translation-accepted-11.patch | 3.49 KB | johnchque |
| #7 | interdiff-3174543-5-7.txt | 1.56 KB | johnchque |
Comments
Comment #2
colorfieldComment #3
berdirThis does look like a regression of that issue, strange. A failing test would be helpful, surpried that none of our tests are catching this?
Comment #4
johnchqueStrange, not sure if I am doing this correctly. These are the steps to reproduce the problem I think so probably something related to the ui?
Comment #5
johnchqueMoving the test to use Content Moderation. This fails locally as the DE translation is not published.
Comment #7
johnchqueChecking the revision ids. :)
Comment #9
berdirHm, this is tricky. The change is what I expected, and is also consistent with what we do in \Drupal\moderation_sidebar\Controller\ModerationSidebarController::sideBar.
This is what happens:
We have "Moderated node", an EN node, with a draft version "[DRAFT] Moderated node". Now, we request a translation of that draft to DE, that picks the EN draft, we translate that, and accept it. So far, everything is fine.
Now, immediately after accepting, we save the DE translation as the new default, published translation. But we still have the actual EN draft that was not yet published, because this revision has been created based on the published default EN revision "Moderated node".
Now, we generate the message, load the original node that we translated from, but now that detects that the EN draft is older than the DE translation/default revision, and no longer uses that. So we have a different node title for the confirmation message.
That alone is not a huge deal, but if you'd now like to translate that same EN draft also to ES, then it won't do that. It will pick the non-draft EN version.
What we'd need is to see if there is a real pending revision for EN, able to make a difference between a past revision that has been superseded by a new default revision, vs. one that is still not merged yet.
That said, I think this is a less severe issue than the current problem, as you'd probably either accept the EN translation first or create two translation requests initially, so we might want to live with this regression, disable/change some tests and create a follow-up issue if there's no easy solution for this.
Comment #10
berdirSo there might be something that could work here. There is $entity->wasDefaultRevision().
So instead of not loading the revision, try changing it to load the revision into $revision, then check wasDefaultRevision(). If yes, then it means that it is a history revision (or possibly even the current default revision), then we can ignore it.
Also, lets extend the if ($revision_id) check to also do && $revision_id != $entity->getRevisionId(), because if it the same, then we don't need to do all that extra work of loading that revision because we know it's the same anyway.
Comment #11
johnchqueAlright, this seems to fix the tests. Nice, thanks for the explanation. :) Let's see if test bot is happy.
Comment #12
berdirLooks good.
Lets add a comment to that piece of code to try to write down what we learned here. Try to summarize my comments down into 2-3 short sentences: that are looking for a pending revision, no need to check a revision if the revision id is the current default revision, and that if was the default revision at some point, then it is an old revision that is part of the default revision that we have.
Comment #13
johnchqueAdding some comments here. Hope they are comprehensive enough.
Comment #15
berdirAnd committed.