Commit dde80e87 authored by Dries's avatar Dries
Browse files

- Patch #642178 by mfb: fixed two comment updates bug.

parent 500b2a00
......@@ -191,11 +191,10 @@ function tracker_node_delete($node, $arg = 0) {
* comments so we need to check for those here.
*/
function tracker_comment_update($comment) {
$comment = (array) $comment;
// comment_save() calls hook_comment_publish() for all published comments
// so we to handle all other values here.
if ($comment['status'] != COMMENT_PUBLISHED) {
_tracker_remove($comment['nid'], $comment['uid'], $comment['timestamp']);
if ($comment->status != COMMENT_PUBLISHED) {
_tracker_remove($comment->nid, $comment->uid, $comment->changed);
}
}
......@@ -309,9 +308,10 @@ function _tracker_remove($nid, $uid = NULL, $changed = NULL) {
// Comments are a second reason to keep the user's subscription.
if (!$keep_subscription) {
// Check if the user has commented at least once on the given nid
$keep_subscription = db_query_range('SELECT COUNT(*) FROM {comment} WHERE nid = :nid AND uid = :uid AND status = 0', 0, 1, array(
$keep_subscription = db_query_range('SELECT COUNT(*) FROM {comment} WHERE nid = :nid AND uid = :uid AND status = :status', 0, 1, array(
':nid' => $nid,
':uid' => $uid,
':status' => COMMENT_PUBLISHED,
))->fetchField();
}
......
......@@ -83,6 +83,13 @@ class TrackerTest extends DrupalWebTestCase {
$this->assertText($my_published->title[FIELD_LANGUAGE_NONE][0]['value'], t("Published nodes show up in the user's tracker listing."));
$this->assertNoText($other_published_no_comment->title[FIELD_LANGUAGE_NONE][0]['value'], t("Other user's nodes do not show up in the user's tracker listing."));
$this->assertText($other_published_my_comment->title[FIELD_LANGUAGE_NONE][0]['value'], t("Nodes that the user has commented on appear in the user's tracker listing."));
// Verify that unpublished comments are removed from the tracker.
$admin_user = $this->drupalCreateUser(array('administer comments', 'access user profiles'));
$this->drupalLogin($admin_user);
$this->drupalPost('comment/1/edit', array('status' => COMMENT_NOT_PUBLISHED), t('Save'));
$this->drupalGet('user/' . $this->user->uid . '/track');
$this->assertNoText($other_published_my_comment->title[FIELD_LANGUAGE_NONE][0]['value'], 'Unpublished comments are not counted on the tracker listing.');
}
/**
......
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