Content Moderation prevents workspace deployment

Created on 27 October 2020, almost 4 years ago
Updated 31 August 2024, 7 days ago

Problem/Motivation

The WorkspacePrePublishEvent subscriber in Workflows implements a query on tracked revisions that neither takes into account that there might not be tracked types, nor that there might be different entity types with the same revision id tracked.

On trying to publish a workspace which only has default state published content that is ready this causes:

  • in the first instance a fatal error because of a SQL syntax violation (see below);
  • and in the second instance an error message that incorrectly states that there is content in an unpublished workflow state.

Steps to reproduce

Automated tests

https://git.drupalcode.org/project/drupal/-/merge_requests/9062/diffs#di...

Manual tests

From OP on this issue:

  1. Enable the core content moderation, workflows and workspace modules
  2. Remove the default content moderation from all content types
  3. Add the default content moderation to the workspace entity type
  4. Create a new workspace or use the default Stage workspace
  5. Switch to the workspace and modify or create some content
  6. Try to deploy the changes from the workspace
  7. You should see the status message "Deployment failed. All errors have been logged."
  8. Content has not been deployed from the workspace.
  9. Logs will reveal no errors

From OP on πŸ› Content moderation check does not take into account entity IDs being used by two content entities Needs work :

  1. Enable the core content moderation, workflows and workspace modules
  2. Remove the default content moderation from all content types
  3. Add the default content moderation to the workspace entity type
  4. Create a new workspace or use the default Stage workspace
  5. Switch to the workspace and modify or create some content
  6. Try to deploy the changes from the workspace
  7. You should see the status message "Deployment failed. All errors have been logged."
  8. Content has not been deployed from the workspace.
  9. Logs will reveal no errors

Also more simply:

  1. Enable the core content moderation, workflows and workspace modules
  2. Switch to Stage
  3. Enable content moderation on two different entity types
  4. Create an entity of type 1 in an unpublished default state. To create an tracked revision id 1.
  5. Edit the entity to a published state. To create a tracked default revision id 2.
  6. Create an entity of type 2 in a published default state. To create a tracked published default revision id 1.
  7. Try to publish the state workspace.
  8. It will fail because no longer default revision of entity type 1 is in an unpublished state, but is reported matching for entity of type 2 revision 1

Proposed resolution

Add a check that there are tracked entity types, and include the entity type along with the revision id in the moderation state query. This is done in:

MR https://git.drupalcode.org/project/drupal/-/merge_requests/9062/diffs

Remaining tasks

Needs review.

Footnote

SQL error from OP:

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')
GROUP BY base_table.revision_id, base_table.id) subquery' at line 2: SELECT COUNT(*) AS expression
FROM
(SELECT 1 AS expression
FROM
{content_moderation_state_revision} base_table
INNER JOIN {content_moderation_state_field_revision} content_moderation_state_field_revision ON content_moderation_state_field_revision.revision_id = base_table.revision_id
WHERE (content_moderation_state_field_revision.content_entity_revision_id IN (:db_condition_placeholder_0, ....)) AND ()
GROUP BY base_table.revision_id, base_table.id)
πŸ› Bug report
Status

RTBC

Version

11.0 πŸ”₯

Component
Content moderationΒ  β†’

Last updated 1 day ago

  • Maintained by
  • πŸ‡¦πŸ‡ΊAustralia @Sam152
Created by

πŸ‡¨πŸ‡¦Canada acrazyanimal

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

Merge Requests

Comments & Activities

Not all content is available!

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

Production build 0.71.5 2024