The problem
- Say, you have a node which can be translated to Eng (default language) and Fre.
- I could not reproduce the exact steps, but sometimes, the
node_field_data ends up in such a state that ContentEntityStorageBase::getLatestTranslationAffectedRevisionId($entity_id, $langcode) returns an empty value
-
- As a result of this,
ModerationInformation::hasPendingRevision() cannot load the $latest_revision.
- Since
$latest_revision cannot be loaded, it then ends up calling $latest_revision->wasDefaultRevision on NULL; This results in a WSOD when editors try to edit the node in the language which has node_field_data.revision_translation_affected = NULL.
Question 1
So, my question is, possible to have the node_field_data table in the following state:
+-----+------+---------+----------+--------+-----------------------------------+-----+------------+------------+------------------+
| nid | vid | type | langcode | status | title | uid | created | changed | default_langcode |
+-----+------+---------+----------+--------+-----------------------------------+-----+------------+------------+------------------+
| 781 | 4432 | article | en | 1 | Différé EN29 janvier | 0 | 1548799632 | 1549314390 | 0 |
| 781 | 4432 | article | fr | 1 | Différé FR 29 janvier - Revised | 0 | 1548799632 | 1549472245 | 1 |
+-----+------+---------+----------+--------+-----------------------------------+-----+------------+------------+------------------+
Question 2
If the above state of the tables is normal, then it is also normal for ContentEntityStorageBase::getLatestTranslationAffectedRevisionId() to return an empty value. In that case, I'd like to propose the patch I'll be posting in comment 1.
Comments
Comment #2
jigariusHere's the patch which validates latest revision id before trying to load the latest revision. So, when latest revision id is empty, we don't attempt to load the latest revision, even though
$latest_revision_id != $default_revision_idmight turn out to be TRUE.Marking as Needs Review so that we can determine if all that I said makes sense.
Comment #3
sam152 commentedComment #4
sam152 commentedThis sounds like the same problem as the related issue I'm adding.
Comment #5
sam152 commentedUnfortunately the other issue doesn't have steps to reproduce either, so this is tricky to write tests for.
Comment #7
maximpodorov commentedPossible source (for some cases) of this problem: #3025709: "Create new revision" option is ignored when updating EntityReferenceRevisionsItem
Another source is incorrect manual creation of revisions.
Comment #8
grimreaperClosing as a duplication because a not null condition has been added by #3001299: Error Loading Language Not Translated For Current Revision.