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

  1. Install Drupal with the standard profile
  2. Enable Content Moderation and Content Translation modules
  3. Enable (default) moderation states for the Article content type.
  4. 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
  5. Add an additional language and enable translation for the Article node, and only for that type.
  6. Add an another test article again, repeat 4th step (above).
    Exception will be thrown
  7. Now repeat the 4th step with the Basic page content type as well (which is not translatable)
    Exception will be thrown
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

huzooka created an issue. See original summary.

timmillwood’s picture

Version: 8.2.x-dev » 8.3.x-dev

If you're enabling a workflow in step 3 this must be an 8.3.x issue.

huzooka’s picture

Version: 8.3.x-dev » 8.2.x-dev
Issue summary: View changes

..but I only enable moderation states. Thanks!

huzooka’s picture

This seems to be fixing the issue, however I haven't deep-dived into the problem.

timmillwood’s picture

Status: Active » Needs review
Issue tags: +Needs tests

It 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.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Sam152’s picture

Status: Needs review » Needs work

NW for tests.

Pavan B S’s picture

Status: Needs work » Needs review
FileSize
768 bytes

Rerolled the patch, please review.

timmillwood’s picture

Status: Needs review » Needs work

Needs work for tests and for everything else I said in #5.

sathish.redcrackle’s picture

Is 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.

timmillwood’s picture

I 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.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

catch’s picture

Issue tags: +WI critical
Sam152’s picture

I just tried to reproduce this on 8.4.x HEAD and failed.

jeqq’s picture

Couldn't reproduce the bug with 8.4.x HEAD.

Sam152’s picture

jeqq’s picture

Status: Needs work » Closed (duplicate)

Yes, 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.