Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
Content editors are unable to re-save existing, translatable draft content as draft again. After hitting "Save and Create New Draft", an EntityStorageException is thrown:
Fatal error: Call to a member function isPublishedState() on null in [docroot]/core/modules/content_moderation/src/EntityOperations.php on line 263
Steps to reproduce
- Install Drupal with the standard profile
- Enable Content Moderation and Content Translation modules
- Enable (default) moderation states for the Article content type.
- Add a new Article. Save it as draft, and then edit it again and save the changes as draft.
There won't be any errors and the changes will be saved - Add an additional language and enable translation for the Article node, and only for that type.
- Add an another test article again, repeat 4th step (above).
Exception will be thrown - Now repeat the 4th step with the Basic page content type as well (which is not translatable)
Exception will be thrown
Comment | File | Size | Author |
---|---|---|---|
#8 | drupal_save-draft-as-draft_2848803-8.patch | 768 bytes | Pavan B S |
#4 | drupal_save-draft-as-draft_2848803-4.patch | 740 bytes | huzooka |
Comments
Comment #2
timmillwoodIf you're enabling a workflow in step 3 this must be an 8.3.x issue.
Comment #3
huzooka..but I only enable moderation states. Thanks!
Comment #4
huzookaThis seems to be fixing the issue, however I haven't deep-dived into the problem.
Comment #5
timmillwoodIt seems strange that $default_revision->moderation_state->entity would be empty, it should get an initial state.
I'd suggest looking at why \Drupal\content_moderation\Plugin\Field\ModerationStateFieldItemList isn't returning the initial state.
Also, this will need a test. There should be some multilingual tests you can add this to.
Comment #7
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedNW for tests.
Comment #8
Pavan B S CreditAttribution: Pavan B S at Valuebound commentedRerolled the patch, please review.
Comment #9
timmillwoodNeeds work for tests and for everything else I said in #5.
Comment #10
sathish.redcrackle CreditAttribution: sathish.redcrackle at Red Crackle commentedIs this reproduced in Drupal 8.3.1. I tested and couldn't found the issue. Will any one confirm?
#8 has a patch with failed tests.
Comment #11
timmillwoodI don't think #4 or #8 is a valid solution.
In #5 I suggested looking at
\Drupal\content_moderation\Plugin\Field\ModerationStateFieldItemList
, but it seems this isn't even called, and I've no idea why.It took me a while to replicate this issue, and struggling to replicate in a test.
Comment #13
catchComment #14
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedI just tried to reproduce this on 8.4.x HEAD and failed.
Comment #15
jeqqCouldn't reproduce the bug with 8.4.x HEAD.
Comment #16
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedIs this a dupe of #2848775: BaseFieldOverride entities created by content_translation break content_moderation because they don't support computed fields? The steps are very similar?
Comment #17
jeqqYes, it looks to be a duplicate now. The only difference is that one issue has been reported for Drupal 8.2 where the Workflows module is missing. Now both issues are tagged with core version >= 8.4.x.
Closed as duplicate of #2848775: BaseFieldOverride entities created by content_translation break content_moderation because they don't support computed fields.