When I add a heartbeat comment to an activity that was created with the shoutbox the comment disappears after some time (about 24 hours one day) it is also deleted from the database table. I cannot figure out when exactly the comment gets removed from the table and why.

Is there any configuration which causes comments to be deleted after a given time? Does the standard cron job do anything on the heartbeat comments table?

Thanks in advance for your support

Comments

Stalski’s picture

Comments are actually only deleted when the parent activity message (or in node context, the node) gets deleted.

The cronjob will delete too old activity (and their comments attached).

So I don't know of any case where comments would be deleted with the parent activity being deleted. Not sure what could cause this behavior.

goekhanc’s picture

Do you have any hint, how I can trace what causes this problem?

I am trying to analyze mysql.log but cannot find where the comments are removed.

Stalski’s picture

The best solution to find the problem is to see inside the comment delete function (I do hope you mean node comments) and do a ddebugbactrace or debug_backtrace if you don't have devel installed.

goekhanc’s picture

"Enable node comments for this activity template if a node is available " is not enabled. all acitivty comments are not node comments. even though the activity is "node creation". the comments are stored in the heartbeat_comments.

Stalski’s picture

ok, then you'll need to backtrace in the heartbeat comment delete function

goekhanc’s picture

I noticed, that activity comments get removed, after I remove an activity. I dont mean, that the related comment disappears, but all activity comments disappear.

Maybe these lines in the mysql.log cause this???

                  633 Query     DELETE FROM netsiad_heartbeat_activity
WHERE  (uaid IN  ('2131'))
                  633 Query     DELETE FROM netsiad_heartbeat_comments
WHERE  (uaid)

goekhanc’s picture

I commented the comments delete function, which is called after an activity has been deleted. The acitivity comments are not removed after one activity is deleted. But now every comments will be kept in the table, even though the corresponding activity is deleted.

It seems to me that there is a problem with the $uaids variable. But I dont know how to solve this problem.

my change in heartbeat_comments.module

 186 function heartbeat_comments_heartbeat_activity_delete($uaids) {
 187 //  db_delete('heartbeat_comments')->where('uaid', $uaids, 'IN')->execute();
 188 }
 189 
Stalski’s picture

DELETE FROM netsiad_heartbeat_comments
WHERE (uaid)

This is indeed the error, this should not happen.

So in detail:

function heartbeat_comments_heartbeat_activity_delete($uaids) {
  db_delete('heartbeat_comments')->where('uaid', $uaids, 'IN')->execute();
}

This was the function and this is how it is now:

function heartbeat_comments_heartbeat_activity_delete($uaids) {
  if (!empty($uaids)) {
    db_delete('heartbeat_comments')->condition('uaid', $uaids, 'IN')->execute();
  }
}

So this will fix the problem. I used where and it should be condition. In all other places, I used it correct, stupid :(

So thanks for the report and the fix has been pushed to git.

Stalski’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.