Hey guys,

I didn't see any mention of this previously, so I'm hoping it's not a dupe. Just wanted to let you know that if you delete a comment, that comment's activity stays in the activity tables, referencing a comment that no longer exists.

The only way I've found to remedy this is to bounce into the activity table in the DB and delete the offending aid's ... I think in the past I used to add a "published=true" filter in views to hide all the deleted stuff, but that's no longer available in 2.x.

For what it's worth, node types are handled perfectly when they're deleted.

Thanks!

Comments

Scott Reynolds’s picture

Hmm tough problem. Heres hook_nodeapi and hook_user

/**
 * Implementation of hook_nodeapi().
 */
function activity_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
  if ($op == 'delete') {
    // Remove all activity records for this node.
    db_query("DELETE m, at, aa, a FROM {activity} a
              LEFT JOIN {activity_access} aa ON aa.aid = a.aid
              INNER JOIN {activity_targets} at ON at.aid = a.aid
              INNER JOIN {activity_messages} m ON m.amid = at.amid
              WHERE a.nid = %d", $node->nid);
  }
}

/**
 * Implementation of hook_user().
 */
function activity_user($op, &$edit, &$account, $category = NULL) {
  if ($op == 'delete') {
    // Remove all activity records for this user.
    db_query("DELETE m, at, aa, a FROM {activity} a
              LEFT JOIN {activity_access} aa ON aa.aid = a.aid
              INNER JOIN {activity_targets} at ON at.aid = a.aid
              INNER JOIN {activity_messages} m ON m.amid = at.amid
              WHERE a.uid = %d", $account->uid);
  }
}

In both cases we had a foriegn key to use (nid and uid). We keep uid so we can know the 'Creator' of the Activity and we keep the nid so we can make sure a user has access to view the node. I cannot imagine a case where storing other 'keys' would be a.) doable and b.) desirable

I would suggest, when deleting activities that you use the url activity/$aid/delete. There is a View handler to create a link to this and a default admin Activities View.

This feels like a Cannot Fix for design reasons...

Apollo610’s picture

Sounds good Scott, will do that going forward. Thanks for the feedback!

Scott Reynolds’s picture

Status: Active » Closed (works as designed)

Ok marking as by design

Scott Reynolds’s picture

Status: Closed (works as designed) » Closed (duplicate)