diff --git a/core/modules/comment/lib/Drupal/comment/CommentFieldNameValue.php b/core/modules/comment/lib/Drupal/comment/CommentFieldNameValue.php index 0190b8d..7907ba8 100644 --- a/core/modules/comment/lib/Drupal/comment/CommentFieldNameValue.php +++ b/core/modules/comment/lib/Drupal/comment/CommentFieldNameValue.php @@ -29,7 +29,7 @@ public function getValue() { // Field id is of the form {entity_type}__{field_name}. We set the // optional limit param to explode() in case the user adds a field with __ // in the name. - $parts = explode('__', $entity->getFieldId(), 2); + $parts = explode('.', $entity->getFieldId(), 2); if ($parts && count($parts) == 2) { $this->value = end($parts); } @@ -46,7 +46,7 @@ public function setValue($value, $notify = TRUE) { // Also set the field id. $field = $this->parent->getParent(); $entity = $field->getParent(); - $entity->field_id = $entity->getCommentedEntityTypeId() . '__' . $value; + $entity->field_id = $entity->getCommentedEntityTypeId() . '.' . $value; } } diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentValidationTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentValidationTest.php index 90cac5d..94a676d 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentValidationTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentValidationTest.php @@ -44,6 +44,20 @@ public function setUp() { * Tests the comment validation constraints. */ public function testValidation() { + $field = $this->entityManager->getStorageController('field_entity')->create(array( + 'entity_type' => 'node', + 'name' => 'comment', + 'type' => 'comment', + )); + $field->save(); + $instance = $this->entityManager->getStorageController('field_instance')->create(array( + 'field_name' => 'comment', + 'entity_type' => 'node', + 'bundle' => 'page', + 'label' => 'Comment settings', + //'settings' => array('display_summary' => FALSE), + )); + $instance->save(); $node = $this->entityManager->getStorageController('node')->create(array( 'type' => 'page', 'title' => 'test', @@ -52,9 +66,8 @@ public function testValidation() { $comment = $this->entityManager->getStorageController('comment')->create(array( 'entity_id' => $node->id(), - // Just use some non-existing dummy field ID here, we are not testing - // that. - 'field_id' => 'test', + 'entity_type' => 'node', + 'field_name' => 'comment', )); $violations = $comment->validate(); $this->assertEqual(count($violations), 0, 'No violations when validating a default comment.');