Commit 0aaea6de authored by catch's avatar catch

Issue #1999328 by DmitryDrozdik, annikaC, jeroen12345, andypost: Remove...

Issue #1999328 by DmitryDrozdik, annikaC, jeroen12345, andypost: Remove comment_save() and comment_delete()/comment_delete_multiple() in favor of $comment->save()/$comment->delete().
parent 60a10550
......@@ -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));
......
......@@ -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) {
......
......@@ -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);
}
......
......@@ -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.
......
......@@ -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);
......
......@@ -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']) {
......
......@@ -152,7 +152,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
......@@ -161,7 +161,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);
}
}
......
......@@ -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.
......
......@@ -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.
......
......@@ -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);
......
......@@ -111,7 +111,7 @@ public function testActiveForumTopicsBlock() {
'comment_body' => $this->randomString(256),
'created' => $date->getTimestamp(),
));
comment_save($comment);
$comment->save();
}
// Enable the block.
......
......@@ -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',
......
......@@ -113,7 +113,7 @@ function setUp() {
'subject' => $this->xss_label,
'comment_body' => array($this->randomName()),
));
comment_save($this->comment);
$this->comment->save();
}
/**
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment