Integrity Constraint Viloation on comment_status

Created on 21 November 2024, 5 months ago

No one else seems to have reported this issue, so Im not completely sure if its in the workflow module but removing it does "fix" it

After upgrading from 10.2 to 10.3 while upgrading from 1.7 to 1.8 I got the following error on nodes in an old workflow
Drupal\Core\Database\IntegrityConstraintViolationException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'comment_status' cannot be null: INSERT INTO "node__comment" ("entity_id", "revision_id", "bundle", "delta", "langcode", "comment_status")
I dont see that anyone else has this particular error, or at least hasnt reported it, so I thought I would anyway just to see.

I ended up "fixing" the error with the following (in case anyone else encounters)

function [custom_module]_node_presave(Drupal\Core\Entity\EntityInterface $node) {
  if ($node->bundle() == '[custom_node_type]' && $node->get('comment')) {
    $comment = $node->get('comment')->getValue();
    if (!isset($comment[0]['status'])) {
      $comment[0]['status'] = 1;
      $node->get('comment')->setValue($comment);
    }
  }
}

I really dont see any obvious change causing this in either core/modules/comment or modules/contrib/workflow but do see that comments should be a comment interface in core and not a string like in workflow.

Sadly, this may just hasten the inevitable migration of this particular old workflow to content_moderation since I can see changing the workflow comments from strings to core comment entities is a pretty big and possibly error prone task, just like migrating. So Im wondering if others have this issue in case there are better workarounds.

πŸ› Bug report
Status

Active

Version

1.8

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States el1_1el

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

Comments & Activities

Production build 0.71.5 2024