diff --git a/core/modules/comment/comment.admin.inc b/core/modules/comment/comment.admin.inc index 51158a9..9594151 100644 --- a/core/modules/comment/comment.admin.inc +++ b/core/modules/comment/comment.admin.inc @@ -189,7 +189,7 @@ function comment_admin_overview_submit($form, &$form_state) { $cids = $form_state['values']['comments']; if ($operation == 'delete') { - comment_delete_multiple($cids); + entity_delete_multiple('comment', $cids); } else { foreach ($cids as $cid => $value) { @@ -201,7 +201,7 @@ function comment_admin_overview_submit($form, &$form_state) { elseif ($operation == 'publish') { $comment->status->value = COMMENT_PUBLISHED; } - comment_save($comment); + $comment->save(); } } drupal_set_message(t('The update has been performed.')); @@ -253,7 +253,7 @@ function comment_multiple_delete_confirm($form, &$form_state) { */ function comment_multiple_delete_confirm_submit($form, &$form_state) { if ($form_state['values']['confirm']) { - comment_delete_multiple(array_keys($form_state['values']['comments'])); + entity_delete_multiple('comment', array_keys($form_state['values']['comments'])); cache_invalidate_tags(array('content' => TRUE)); $count = count($form_state['values']['comments']); watchdog('content', 'Deleted @count comments.', array('@count' => $count)); diff --git a/core/modules/comment/comment.api.php b/core/modules/comment/comment.api.php index a27899e..ec1707f 100644 --- a/core/modules/comment/comment.api.php +++ b/core/modules/comment/comment.api.php @@ -15,7 +15,7 @@ /** * Act on a comment being inserted or updated. * - * This hook is invoked from comment_save() before the comment is saved to the + * This hook is invoked from $comment->save() before the comment is saved to the * database. * * @param Drupal\comment\Comment $comment @@ -160,7 +160,7 @@ function hook_comment_unpublish(Drupal\comment\Comment $comment) { /** * Act before comment deletion. * - * This hook is invoked from comment_delete_multiple() before + * This hook is invoked from entity_delete_multiple() before * field_attach_delete() is called and before the comment is actually removed * from the database. * @@ -168,7 +168,6 @@ function hook_comment_unpublish(Drupal\comment\Comment $comment) { * The comment object for the comment that is about to be deleted. * * @see hook_comment_delete() - * @see comment_delete_multiple() * @see entity_delete_multiple() */ function hook_comment_predelete(Drupal\comment\Comment $comment) { @@ -181,7 +180,7 @@ function hook_comment_predelete(Drupal\comment\Comment $comment) { /** * Respond to comment deletion. * - * This hook is invoked from comment_delete_multiple() after + * This hook is invoked from entity_delete_multiple() after * field_attach_delete() has called and after the comment has been removed from * the database. * @@ -189,7 +188,6 @@ function hook_comment_predelete(Drupal\comment\Comment $comment) { * The comment object for the comment that has been deleted. * * @see hook_comment_predelete() - * @see comment_delete_multiple() * @see entity_delete_multiple() */ function hook_comment_delete(Drupal\comment\Comment $comment) { diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index 9895b1f..2be2ab5 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -1210,7 +1210,7 @@ function comment_node_insert(EntityInterface $node) { */ function comment_node_predelete(EntityInterface $node) { $cids = db_query('SELECT cid FROM {comment} WHERE nid = :nid', array(':nid' => $node->nid))->fetchCol(); - comment_delete_multiple($cids); + entity_delete_multiple('comment', $cids); db_delete('node_comment_statistics') ->condition('nid', $node->nid) ->execute(); @@ -1289,7 +1289,7 @@ function comment_user_cancel($edit, $account, $method) { $comments = entity_load_multiple_by_properties('comment', array('uid' => $account->uid)); foreach ($comments as $comment) { $comment->status->value = 0; - comment_save($comment); + $comment->save(); } break; @@ -1297,7 +1297,7 @@ function comment_user_cancel($edit, $account, $method) { $comments = entity_load_multiple_by_properties('comment', array('uid' => $account->uid)); foreach ($comments as $comment) { $comment->uid->target_id = 0; - comment_save($comment); + $comment->save(); } break; } @@ -1308,39 +1308,6 @@ function comment_user_cancel($edit, $account, $method) { */ function comment_user_predelete($account) { $cids = db_query('SELECT c.cid FROM {comment} c WHERE uid = :uid', array(':uid' => $account->uid))->fetchCol(); - comment_delete_multiple($cids); -} - -/** - * Accepts a submission of new or changed comment content. - * - * @param Drupal\comment\Comment $comment - * A comment object. - */ -function comment_save(Comment $comment) { - $comment->save(); -} - -/** - * Deletes a comment and all its replies. - * - * @param $cid - * The ID of the comment to delete. - */ -function comment_delete($cid) { - comment_delete_multiple(array($cid)); -} - -/** - * Deletes comments and all their replies. - * - * @param $cids - * The IDs of the comments to delete. - * - * @see hook_comment_predelete() - * @see hook_comment_delete() - */ -function comment_delete_multiple($cids) { entity_delete_multiple('comment', $cids); } @@ -1955,7 +1922,7 @@ function comment_unpublish_by_keyword_action_submit($form, $form_state) { * @ingroup actions */ function comment_save_action(Comment $comment) { - comment_save($comment); + $comment->save(); cache_invalidate_tags(array('content' => TRUE)); watchdog('action', 'Saved comment %title', array('%title' => $comment->subject->value)); } diff --git a/core/modules/comment/lib/Drupal/comment/CommentFormController.php b/core/modules/comment/lib/Drupal/comment/CommentFormController.php index dd4e13d..e2040d5 100644 --- a/core/modules/comment/lib/Drupal/comment/CommentFormController.php +++ b/core/modules/comment/lib/Drupal/comment/CommentFormController.php @@ -319,7 +319,7 @@ public function save(array $form, array &$form_state) { user_cookie_save(array_intersect_key($form_state['values'], array_flip(array('name', 'mail', 'homepage')))); } - comment_save($comment); + $comment->save(); $form_state['values']['cid'] = $comment->id(); // Add an entry to the watchdog log. diff --git a/core/modules/comment/lib/Drupal/comment/CommentStorageController.php b/core/modules/comment/lib/Drupal/comment/CommentStorageController.php index eef80c8..3231d4b 100644 --- a/core/modules/comment/lib/Drupal/comment/CommentStorageController.php +++ b/core/modules/comment/lib/Drupal/comment/CommentStorageController.php @@ -178,7 +178,7 @@ protected function postDelete($comments) { ->fields('c', array('cid')) ->condition('pid', array(array_keys($comments)), 'IN'); $child_cids = $query->execute()->fetchCol(); - comment_delete_multiple($child_cids); + entity_delete_multiple('comment', $child_cids); foreach ($comments as $comment) { $this->updateNodeStatistics($comment->nid->target_id); diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentCSSTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentCSSTest.php index 9213e16..8b07aec 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentCSSTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentCSSTest.php @@ -59,7 +59,7 @@ function testCommentClasses() { 'language' => Language::LANGCODE_NOT_SPECIFIED, 'comment_body' => array(Language::LANGCODE_NOT_SPECIFIED => array($this->randomName())), )); - comment_save($comment); + $comment->save(); // Adjust the current/viewing user. switch ($case['user']) { diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentLinksTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentLinksTest.php index 5523674..744b9f9 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentLinksTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentLinksTest.php @@ -151,7 +151,7 @@ function setEnvironment(array $info) { 'langcode' => Language::LANGCODE_NOT_SPECIFIED, 'comment_body' => array(Language::LANGCODE_NOT_SPECIFIED => array($this->randomName())), )); - comment_save($comment); + $comment->save(); $this->comment = $comment; // comment_num_new() relies on history_read(), so ensure that no one has @@ -160,7 +160,7 @@ function setEnvironment(array $info) { } else { $cids = db_query("SELECT cid FROM {comment}")->fetchCol(); - comment_delete_multiple($cids); + entity_delete_multiple('comment', $cids); unset($this->comment); } } diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentNewIndicatorTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentNewIndicatorTest.php index 295c6c2..e121432 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentNewIndicatorTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentNewIndicatorTest.php @@ -45,7 +45,7 @@ public function testCommentNewCommentsIndicator() { $this->assertLink(t('Read more')); // Create a new comment. This helper function may be run with different - // comment settings so use comment_save() to avoid complex setup. + // comment settings so use $comment->save() to avoid complex setup. $comment = entity_create('comment', array( 'cid' => NULL, 'nid' => $this->node->nid, @@ -58,7 +58,7 @@ public function testCommentNewCommentsIndicator() { 'langcode' => Language::LANGCODE_NOT_SPECIFIED, 'comment_body' => array(Language::LANGCODE_NOT_SPECIFIED => array($this->randomName())), )); - comment_save($comment); + $comment->save(); $this->drupalLogout(); // Log in with 'web user' and check comment links. diff --git a/core/modules/comment/lib/Drupal/comment/Tests/Views/DefaultViewRecentComments.php b/core/modules/comment/lib/Drupal/comment/Tests/Views/DefaultViewRecentComments.php index 37455c5..ce5bc3e 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/Views/DefaultViewRecentComments.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/Views/DefaultViewRecentComments.php @@ -89,7 +89,7 @@ public function setUp() { $comment->created->value = $time; $comment->changed->value = $time; - comment_save($comment); + $comment->save(); } // Store all the nodes just created to access their properties on the tests. diff --git a/core/modules/forum/forum.module b/core/modules/forum/forum.module index 42d7326..c5af0f4 100644 --- a/core/modules/forum/forum.module +++ b/core/modules/forum/forum.module @@ -493,7 +493,7 @@ function forum_taxonomy_term_delete(Term $term) { * Implements hook_comment_publish(). * * This actually handles the insertion and update of published nodes since - * comment_save() calls hook_comment_publish() for all published comments. + * $comment->save() calls hook_comment_publish() for all published comments. */ function forum_comment_publish($comment) { _forum_update_forum_index($comment->nid->target_id); @@ -506,7 +506,7 @@ function forum_comment_publish($comment) { * individual comments, so we need to check for those here. */ function forum_comment_update($comment) { - // comment_save() calls hook_comment_publish() for all published comments, + // $comment->save() calls hook_comment_publish() for all published comments, // so we need to handle all other values here. if (!$comment->status->value) { _forum_update_forum_index($comment->nid->target_id); diff --git a/core/modules/forum/lib/Drupal/forum/Tests/ForumBlockTest.php b/core/modules/forum/lib/Drupal/forum/Tests/ForumBlockTest.php index 175f049..b6349ab 100644 --- a/core/modules/forum/lib/Drupal/forum/Tests/ForumBlockTest.php +++ b/core/modules/forum/lib/Drupal/forum/Tests/ForumBlockTest.php @@ -111,7 +111,7 @@ public function testActiveForumTopicsBlock() { 'comment_body' => $this->randomString(256), 'created' => $date->getTimestamp(), )); - comment_save($comment); + $comment->save(); } // Enable the block. 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 da9db46..abd7dad 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityCrudHookTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityCrudHookTest.php @@ -168,7 +168,7 @@ public function testCommentHooks() { )); $_SESSION['entity_crud_hook_test'] = array(); - comment_save($comment); + $comment->save(); $this->assertHookMessageOrder(array( 'entity_crud_hook_test_comment_presave called', @@ -187,7 +187,7 @@ public function testCommentHooks() { $_SESSION['entity_crud_hook_test'] = array(); $comment->subject->value = 'New subject'; - comment_save($comment); + $comment->save(); $this->assertHookMessageOrder(array( 'entity_crud_hook_test_comment_presave called', diff --git a/core/modules/system/lib/Drupal/system/Tests/Theme/EntityFilteringThemeTest.php b/core/modules/system/lib/Drupal/system/Tests/Theme/EntityFilteringThemeTest.php index 3eb90ba..5f5b1f8 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Theme/EntityFilteringThemeTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Theme/EntityFilteringThemeTest.php @@ -113,7 +113,7 @@ function setUp() { 'subject' => $this->xss_label, 'comment_body' => array($this->randomName()), )); - comment_save($this->comment); + $this->comment->save(); } /** diff --git a/core/modules/tracker/tracker.module b/core/modules/tracker/tracker.module index 34235b9..faadb12 100644 --- a/core/modules/tracker/tracker.module +++ b/core/modules/tracker/tracker.module @@ -229,7 +229,7 @@ function tracker_node_predelete(EntityInterface $node, $arg = 0) { * comments so we need to check for those here. */ function tracker_comment_update($comment) { - // comment_save() calls hook_comment_publish() for all published comments + // $comment->save() calls hook_comment_publish() for all published comments // so we need to handle all other values here. if ($comment->status->value != COMMENT_PUBLISHED) { _tracker_remove($comment->nid->target_id, $comment->uid->target_id, $comment->changed->value); @@ -240,7 +240,7 @@ function tracker_comment_update($comment) { * Implements hook_comment_publish(). * * This actually handles the insert and update of published nodes since - * comment_save() calls hook_comment_publish() for all published comments. + * $comment->save() calls hook_comment_publish() for all published comments. */ function tracker_comment_publish($comment) { _tracker_add($comment->nid->target_id, $comment->uid->target_id, $comment->changed->value);