diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index 7ebe93e..525e46b 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -188,7 +188,7 @@ function comment_count_unpublished() { */ function comment_field_instance_config_insert(FieldInstanceConfigInterface $instance) { if ($instance->getType() == 'comment' && !$instance->isSyncing()) { - \Drupal::service('comment.manager')->addBodyField($instance->entity_type, $instance->getName()); + \Drupal::service('comment.manager')->addBodyField($instance->getSetting('comment_type')); } } diff --git a/core/modules/comment/lib/Drupal/comment/CommentManager.php b/core/modules/comment/lib/Drupal/comment/CommentManager.php index cb2ea80..cc957dd 100644 --- a/core/modules/comment/lib/Drupal/comment/CommentManager.php +++ b/core/modules/comment/lib/Drupal/comment/CommentManager.php @@ -221,7 +221,7 @@ public function addDefaultField($entity_type, $bundle, $field_name = 'comment', /** * {@inheritdoc} */ - public function addBodyField($comment_type) { + public function addBodyField($comment_type_id) { // Create the field if needed. $field = $this->entityManager->getStorage('field_config')->load('comment.comment_body'); if (!$field) { @@ -234,28 +234,28 @@ public function addBodyField($comment_type) { } $field_instance = $this->entityManager ->getStorage('field_instance_config') - ->load("comment.$comment_type.comment_body"); + ->load("comment.$comment_type_id.comment_body"); if (!$field_instance) { // Attaches the body field by default. $field_instance = $this->entityManager->getStorage('field_instance_config')->create(array( 'field_name' => 'comment_body', 'label' => 'Comment', 'entity_type' => 'comment', - 'bundle' => $comment_type, + 'bundle' => $comment_type_id, 'settings' => array('text_processing' => 1), 'required' => TRUE, )); $field_instance->save(); // Assign widget settings for the 'default' form mode. - entity_get_form_display('comment', $comment_type, 'default') + entity_get_form_display('comment', $comment_type_id, 'default') ->setComponent('comment_body', array( 'type' => 'text_textarea', )) ->save(); // Assign display settings for the 'default' view mode. - entity_get_display('comment', $comment_type, 'default') + entity_get_display('comment', $comment_type_id, 'default') ->setComponent('comment_body', array( 'label' => 'hidden', 'type' => 'text_default', diff --git a/core/modules/comment/lib/Drupal/comment/CommentStatistics.php b/core/modules/comment/lib/Drupal/comment/CommentStatistics.php index 63e9833..7a03391 100644 --- a/core/modules/comment/lib/Drupal/comment/CommentStatistics.php +++ b/core/modules/comment/lib/Drupal/comment/CommentStatistics.php @@ -182,7 +182,7 @@ public function update(CommentInterface $comment) { $query->addExpression('COUNT(cid)'); $count = $query->condition('c.entity_id', $comment->getCommentedEntityId()) ->condition('c.entity_type', $comment->getCommentedEntityTypeId()) - ->condition('c.comment_name', $comment->getFieldName()) + ->condition('c.field_name', $comment->getFieldName()) ->condition('c.status', CommentInterface::PUBLISHED) ->execute() ->fetchField(); diff --git a/core/modules/comment/lib/Drupal/comment/CommentViewBuilder.php b/core/modules/comment/lib/Drupal/comment/CommentViewBuilder.php index da28f7b..517b201 100644 --- a/core/modules/comment/lib/Drupal/comment/CommentViewBuilder.php +++ b/core/modules/comment/lib/Drupal/comment/CommentViewBuilder.php @@ -122,7 +122,7 @@ public function buildContent(array $entities, array $displays, $view_mode, $lang throw new \InvalidArgumentException(t('Invalid entity for comment.')); } $entity->content['#entity'] = $entity; - $entity->content['#theme'] = 'comment__' . $entity->getFieldId() . '__' . $commented_entity->bundle(); + $entity->content['#theme'] = 'comment__' . $entity->getFieldName() . '__' . $commented_entity->bundle(); $entity->content['links'] = array( '#type' => 'render_cache_placeholder', '#callback' => '\Drupal\comment\CommentViewBuilder::renderLinks', diff --git a/core/modules/comment/lib/Drupal/comment/Entity/Comment.php b/core/modules/comment/lib/Drupal/comment/Entity/Comment.php index f14b310..b72f845 100644 --- a/core/modules/comment/lib/Drupal/comment/Entity/Comment.php +++ b/core/modules/comment/lib/Drupal/comment/Entity/Comment.php @@ -298,10 +298,12 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { * {@inheritdoc} */ public static function bundleFieldDefinitions(EntityTypeInterface $entity_type, $bundle, array $base_field_definitions) { - $comment_type = entity_load('comment_type', $bundle); - $fields['entity_id'] = clone $base_field_definitions['entity_id']; - $fields['entity_id']->setSetting('target_type', $comment_type->targetEntityTypeId); - return $fields; + if ($entity_type->id() == 'comment') { + $comment_type = entity_load('comment_type', $bundle); + $fields['entity_id'] = clone $base_field_definitions['entity_id']; + $fields['entity_id']->setSetting('target_type', $comment_type->targetEntityTypeId); + return $fields; + } } /**