Issue importing content using content moderation

Created on 24 January 2022, about 3 years ago
Updated 6 February 2024, about 1 year ago

Problem/Motivation

When my site contains nodes using content moderation and I run a full content export ($ drush dcdes) I get content exported to files in the node and content_moderation_state folders. If I delete a node that uses content moderation and try to import ($ drush dcdi) I get the following error:

[error] Error: Attempt to assign property "moderation_state" on null in Drupal\content_moderation\Entity\ContentModerationState->save() (line 165 of /var/www/html/core/modules/content_moderation/src/Entity/ContentModerationState.php)

This error also happens if I export my content again after deleting the node using content moderation, then import.

We need a way to remove the content_moderation_state files after an associated node is deleted. Or maybe a drush command to remove all content JSON files before performing an export to ensure there aren't any entities remaining that point to non-existent nodes.

Steps to reproduce

  • Create a node in Draft
  • Create a new revision and set to Published
  • Export all content ($ drush dcdes)
  • Delete the node from above
  • Import content ($ drush dcdi). You can also export content again before importing.
🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇨🇦Canada smulvih2 Canada 🍁

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇨🇦Canada Liam Morland Ontario, CA 🇨🇦

    I got this error even with the force option checked. I was able to work around it by moving the content_moderation_state directory away, doing an import, putting that directory back in place, and running the update again.

  • 🇨🇦Canada joseph.olstad

    I have the same issue as @liam morland
    about to test the workaround which is to move the content_moderation_state directory away during the first import and putting it back for another import.

Production build 0.71.5 2024