diff -u b/core/modules/comment/comment.module b/core/modules/comment/comment.module --- b/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -144,7 +144,7 @@ function comment_entity_base_field_info_alter(&$fields, EntityTypeInterface $entity_type) { // Provide a better default value for the moderation state field if the // content moderation is enabled for comments. - if (\Drupal::moduleHandler()->moduleExists('content_moderation') && \Drupal::service('content_moderation.moderation_information')->canModerateEntitiesOfEntityType($entity_type)) { + if (\Drupal::moduleHandler()->moduleExists('content_moderation') && \Drupal::service('content_moderation.moderation_information')->canModerateEntitiesOfEntityType($entity_type) && isset($fields['moderation_state'])) { $fields['moderation_state']->setDefaultValueCallback('comment_get_default_moderation_state'); } }