Immediately publishing a node fails when no content type have content moderation applied

Created on 17 July 2023, 11 months ago
Updated 17 May 2024, about 1 month ago

Problem/Motivation

On sites with content_moderation, scheduler and scheduler_content_moderation_integration modules enabled, but no content type with workflow applied to, the immediately publishing of a scheduled node fails with the error:
Drupal\Core\Entity\EntityStorageException: Field moderation_state is unknown. in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 815 of /var/www/pilootsites/staging/application/docroot/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).
Our use case is a default setup of content moderation + scheduler, for a shared configuration for many sites, where by default workflow is not applied. The application of workflow to a content type is done on a config split for each particular site.

Steps to reproduce

  1. Check on a site with content_moderation, scheduler and scheduler_content_moderation_integration enabled
  2. Add a workflow to the site
  3. Do not apply this workflow to any content type
  4. Configure a content type to have scheduling added, and add the fields publish on and unpublish on to the node form
  5. Create an unpublished node and schedule to publish in the past
  6. See that the error is thrown
  7. Apply workflow to any content type, not necessarily the one you are tesing
  8. Repeate the above steps
  9. And observe no error is thrown

Proposed resolution

Add a simple condition to https://git.drupalcode.org/project/scheduler_content_moderation_integrat... to check for the existence of the field.

πŸ› Bug report
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡§πŸ‡·Brazil webfordreams

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

Merge Requests

Comments & Activities

Production build 0.69.0 2024