diff --git a/core/modules/comment/comment.admin.inc b/core/modules/comment/comment.admin.inc index f79ba74..7df2c43 100644 --- a/core/modules/comment/comment.admin.inc +++ b/core/modules/comment/comment.admin.inc @@ -306,7 +306,7 @@ function comment_confirm_delete($form, &$form_state, Comment $comment) { function comment_confirm_delete_submit($form, &$form_state) { $comment = $form_state['comment']; // Delete the comment and its replies. - comment_delete($comment->cid->value); + $comment->delete(); drupal_set_message(t('The comment and all its replies have been deleted.')); watchdog('content', 'Deleted comment @cid and its replies.', array('@cid' => $comment->cid->value)); // Clear the cache so an anonymous user sees that his comment was deleted. diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentActionsTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentActionsTest.php index a93d02c..b5c1431 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentActionsTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentActionsTest.php @@ -35,7 +35,6 @@ function testCommentPublishUnpublishActions() { $comment_text = $this->randomName(); $subject = $this->randomName(); $comment = $this->postComment($this->node, $comment_text, $subject); - $comment = comment_load($comment->id()); // Unpublish a comment (direct form: doesn't actually save the comment). comment_unpublish_action($comment); diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentContentRebuildTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentContentRebuildTest.php index ddaf89d..c467a09 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentContentRebuildTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentContentRebuildTest.php @@ -34,12 +34,11 @@ function testCommentRebuild() { $subject_text = $this->randomName(); $comment_text = $this->randomName(); $comment = $this->postComment($this->node, $comment_text, $subject_text, TRUE); - $comment_loaded = comment_load($comment->id()); $this->assertTrue($this->commentExists($comment), 'Comment found.'); // Add the property to the content array and then see if it still exists on build. - $comment_loaded->content['test_property'] = array('#value' => $this->randomString()); - $built_content = comment_view($comment_loaded); + $comment->content['test_property'] = array('#value' => $this->randomString()); + $built_content = comment_view($comment); // This means that the content was rebuilt as the added test property no longer exists. $this->assertFalse(isset($built_content['test_property']), 'Comment content was emptied before being built.'); diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentInterfaceTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentInterfaceTest.php index 00a4291..f0edffb 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentInterfaceTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentInterfaceTest.php @@ -67,8 +67,7 @@ function testCommentInterface() { // Test changing the comment author to "Anonymous". $this->drupalGet('comment/' . $comment->id() . '/edit'); $comment = $this->postComment(NULL, $comment->comment_body->value, $comment->subject->value, array('name' => '')); - $comment_loaded = comment_load($comment->id()); - $this->assertTrue(empty($comment_loaded->name->value) && $comment_loaded->uid->value == 0, 'Comment author successfully changed to anonymous.'); + $this->assertTrue(empty($comment->name->value) && $comment->uid->value == 0, 'Comment author successfully changed to anonymous.'); // Test changing the comment author to an unverified user. $random_name = $this->randomName(); @@ -80,8 +79,7 @@ function testCommentInterface() { // Test changing the comment author to a verified user. $this->drupalGet('comment/' . $comment->id() . '/edit'); $comment = $this->postComment(NULL, $comment->comment_body->value, $comment->subject->value, array('name' => $this->web_user->name)); - $comment_loaded = comment_load($comment->id()); - $this->assertTrue($comment_loaded->name->value == $this->web_user->name && $comment_loaded->uid->value == $this->web_user->uid, 'Comment author successfully changed to a registered user.'); + $this->assertTrue($comment->name->value == $this->web_user->name && $comment->uid->value == $this->web_user->uid, 'Comment author successfully changed to a registered user.'); $this->drupalLogout(); @@ -95,7 +93,7 @@ function testCommentInterface() { $reply_loaded = comment_load($reply->id()); $this->assertTrue($this->commentExists($reply, TRUE), 'Reply found.'); $this->assertEqual($comment->id(), $reply_loaded->pid->value, 'Pid of a reply to a comment is set correctly.'); - $this->assertEqual(rtrim($comment_loaded->thread->value, '/') . '.00/', $reply_loaded->thread->value, 'Thread of reply grows correctly.'); + $this->assertEqual(rtrim($comment->thread->value, '/') . '.00/', $reply_loaded->thread->value, 'Thread of reply grows correctly.'); // Second reply to comment #3 creating comment #4. $this->drupalGet('comment/reply/' . $this->node->nid . '/' . $comment->id()); @@ -104,7 +102,7 @@ function testCommentInterface() { $reply = $this->postComment(NULL, $this->randomName(), $this->randomName(), TRUE); $reply_loaded = comment_load($reply->id()); $this->assertTrue($this->commentExists($reply, TRUE), 'Second reply found.'); - $this->assertEqual(rtrim($comment_loaded->thread->value, '/') . '.01/', $reply_loaded->thread->value, 'Thread of second reply grows correctly.'); + $this->assertEqual(rtrim($comment->thread->value, '/') . '.01/', $reply_loaded->thread->value, 'Thread of second reply grows correctly.'); // Edit reply. $this->drupalGet('comment/' . $reply->id() . '/edit'); diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentNodeChangesTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentNodeChangesTest.php index b27412c..e932f68 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentNodeChangesTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentNodeChangesTest.php @@ -26,7 +26,7 @@ public static function getInfo() { function testNodeDeletion() { $this->drupalLogin($this->web_user); $comment = $this->postComment($this->node, $this->randomName(), $this->randomName()); - $this->assertTrue(comment_load($comment->id()), 'The comment could be loaded.'); + $this->assertTrue($comment->id(), 'The comment could be loaded.'); node_delete($this->node->nid); $this->assertFalse(comment_load($comment->id()), 'The comment could not be loaded after the node was deleted.'); } diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentPreviewTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentPreviewTest.php index 7a2094b..973c4b4 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentPreviewTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentPreviewTest.php @@ -129,7 +129,7 @@ function testCommentEditPreviewSave() { $this->drupalPost('comment/' . $comment->id() . '/edit', $displayed, t('Save')); // Check that the saved comment is still correct. - $comment_loaded = comment_load($comment->id()); + $comment_loaded = comment_load($comment->id(), TRUE); $this->assertEqual($comment_loaded->subject->value, $edit['subject'], 'Subject loaded.'); $this->assertEqual($comment_loaded->comment_body->value, $edit['comment_body[' . $langcode . '][0][value]'], 'Comment body loaded.'); $this->assertEqual($comment_loaded->name->value, $edit['name'], 'Name loaded.'); diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentTestBase.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentTestBase.php index 569efa6..30ebbf6 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentTestBase.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentTestBase.php @@ -146,8 +146,6 @@ function postComment($node, $comment, $subject = '', $contact = NULL) { if (isset($match[1])) { $entity = comment_load($match[1]); - $entity->subject->value = $subject; - $entity->comment_body->value = $comment; return $entity; } } diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentThreadingTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentThreadingTest.php index 682cf51..6f2837a 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentThreadingTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentThreadingTest.php @@ -42,9 +42,8 @@ function testCommentThreading() { $comment_text = $this->randomName(); $comment1 = $this->postComment($this->node, $comment_text, $subject_text, TRUE); // Confirm that the comment was created and has the correct threading. - $comment1_loaded = comment_load($comment1->id()); $this->assertTrue($this->commentExists($comment1), 'Comment #1. Comment found.'); - $this->assertEqual($comment1_loaded->thread->value, '01/'); + $this->assertEqual($comment1->thread->value, '01/'); // Confirm that there is no reference to a parent comment. $this->assertNoParentLink($comment1->id()); @@ -53,9 +52,8 @@ function testCommentThreading() { $this->drupalGet('comment/reply/' . $this->node->nid . '/' . $comment1->id()); $comment2 = $this->postComment(NULL, $this->randomName(), '', TRUE); // Confirm that the comment was created and has the correct threading. - $comment2_loaded = comment_load($comment2->id()); $this->assertTrue($this->commentExists($comment2, TRUE), 'Comment #2. Reply found.'); - $this->assertEqual($comment2_loaded->thread->value, '01.00/'); + $this->assertEqual($comment2->thread->value, '01.00/'); // Confirm that there is a link to the parent comment. $this->assertParentLink($comment2->id(), $comment1->id()); @@ -63,9 +61,8 @@ function testCommentThreading() { $this->drupalGet('comment/reply/' . $this->node->nid . '/' . $comment2->id()); $comment3 = $this->postComment(NULL, $this->randomName(), $this->randomName(), TRUE); // Confirm that the comment was created and has the correct threading. - $comment3_loaded = comment_load($comment3->id()); $this->assertTrue($this->commentExists($comment3, TRUE), 'Comment #3. Second reply found.'); - $this->assertEqual($comment3_loaded->thread->value, '01.00.00/'); + $this->assertEqual($comment3->thread->value, '01.00.00/'); // Confirm that there is a link to the parent comment. $this->assertParentLink($comment3->id(), $comment2->id()); @@ -74,9 +71,8 @@ function testCommentThreading() { $this->drupalGet('comment/reply/' . $this->node->nid . '/' . $comment1->id()); $comment4 = $this->postComment(NULL, $this->randomName(), '', TRUE); // Confirm that the comment was created and has the correct threading. - $comment4_loaded = comment_load($comment4->id()); $this->assertTrue($this->commentExists($comment4), 'Comment #4. Third reply found.'); - $this->assertEqual($comment4_loaded->thread->value, '01.01/'); + $this->assertEqual($comment4->thread->value, '01.01/'); // Confirm that there is a link to the parent comment. $this->assertParentLink($comment4->id(), $comment1->id()); @@ -86,9 +82,8 @@ function testCommentThreading() { $comment_text = $this->randomName(); $comment5 = $this->postComment($this->node, $comment_text, $subject_text, TRUE); // Confirm that the comment was created and has the correct threading. - $comment5_loaded = comment_load($comment5->id()); $this->assertTrue($this->commentExists($comment5), 'Comment #5. Second comment found.'); - $this->assertEqual($comment5_loaded->thread->value, '02/'); + $this->assertEqual($comment5->thread->value, '02/'); // Confirm that there is no link to a parent comment. $this->assertNoParentLink($comment5->id()); @@ -97,9 +92,8 @@ function testCommentThreading() { $this->drupalGet('comment/reply/' . $this->node->nid . '/' . $comment5->id()); $comment6 = $this->postComment(NULL, $this->randomName(), '', TRUE); // Confirm that the comment was created and has the correct threading. - $comment6_loaded = comment_load($comment6->id()); $this->assertTrue($this->commentExists($comment6, TRUE), 'Comment #6. Reply found.'); - $this->assertEqual($comment6_loaded->thread->value, '02.00/'); + $this->assertEqual($comment6->thread->value, '02.00/'); // Confirm that there is a link to the parent comment. $this->assertParentLink($comment6->id(), $comment5->id()); @@ -107,9 +101,8 @@ function testCommentThreading() { $this->drupalGet('comment/reply/' . $this->node->nid . '/' . $comment6->id()); $comment7 = $this->postComment(NULL, $this->randomName(), $this->randomName(), TRUE); // Confirm that the comment was created and has the correct threading. - $comment7_loaded = comment_load($comment7->id()); $this->assertTrue($this->commentExists($comment7, TRUE), 'Comment #7. Second reply found.'); - $this->assertEqual($comment7_loaded->thread->value, '02.00.00/'); + $this->assertEqual($comment7->thread->value, '02.00.00/'); // Confirm that there is a link to the parent comment. $this->assertParentLink($comment7->id(), $comment6->id()); @@ -118,9 +111,8 @@ function testCommentThreading() { $this->drupalGet('comment/reply/' . $this->node->nid . '/' . $comment5->id()); $comment8 = $this->postComment(NULL, $this->randomName(), '', TRUE); // Confirm that the comment was created and has the correct threading. - $comment8_loaded = comment_load($comment8->id()); $this->assertTrue($this->commentExists($comment8), 'Comment #8. Third reply found.'); - $this->assertEqual($comment8_loaded->thread->value, '02.01/'); + $this->assertEqual($comment8->thread->value, '02.01/'); // Confirm that there is a link to the parent comment. $this->assertParentLink($comment8->id(), $comment5->id()); } diff --git a/core/modules/field/field.attach.inc b/core/modules/field/field.attach.inc index 26f6e07..17fba7c 100644 --- a/core/modules/field/field.attach.inc +++ b/core/modules/field/field.attach.inc @@ -7,8 +7,6 @@ use Drupal\field\FieldValidationException; use Drupal\Core\Entity\EntityInterface; -use Drupal\Core\Entity\EntityNG; -use Drupal\Core\Entity\EntityBCDecorator; use Drupal\entity\Plugin\Core\Entity\EntityDisplay; /** diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityCrudHookTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityCrudHookTest.php index b383a27..2c5299b 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityCrudHookTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityCrudHookTest.php @@ -126,7 +126,7 @@ public function testCommentHooks() { )); $_SESSION['entity_crud_hook_test'] = array(); - comment_delete($comment->cid->value); + $comment->delete(); $this->assertHookMessageOrder(array( 'entity_crud_hook_test_comment_predelete called', diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php index b41bf3d..370622d 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php @@ -131,7 +131,7 @@ function testEntityLanguageMethods() { $this->pass('A translation for an invalid language is NULL.'); } - // Try to get an unstranslatable value from a translation in strict mode. + // Try to get an untranslatable value from a translation in strict mode. try { $field_name = 'field_test_text'; $value = $entity->getTranslation($this->langcodes[1])->get($field_name); @@ -141,7 +141,7 @@ function testEntityLanguageMethods() { $this->pass('Getting an untranslatable value from a translation in strict mode throws an exception.'); } - // Try to get an unstranslatable value from a translation in non-strict + // Try to get an untranslatable value from a translation in non-strict // mode. $entity->set($field_name, array(0 => array('value' => 'default value'))); $value = $entity->getTranslation($this->langcodes[1], FALSE)->get($field_name)->value; @@ -156,7 +156,7 @@ function testEntityLanguageMethods() { $this->pass("Setting a translation for an invalid language throws an exception."); } - // Try to set an unstranslatable value into a translation in strict mode. + // Try to set an untranslatable value into a translation in strict mode. try { $entity->getTranslation($this->langcodes[1])->set($field_name, NULL); $this->fail("Setting an untranslatable value into a translation in strict mode throws an exception.");