Deleted content actions are not showed in activity after content deletion
| Project: | Activity |
| Version: | 6.x-1.x-dev |
| Component: | Activity Contrib |
| Category: | bug report |
| Priority: | normal |
| Assigned: | dalad |
| Status: | needs work |
| Issue tags: | activity-6.x-1-3 |
Jump to:
Hello. I've noticed the following behaviour. When an user creates a content, lets say a new blog entry and the nodeactivity is well setup, the action appears in the activity lists. Later, the user deletes the blog entry. If you look at the activity list, you'll see the "create" and "delete" activities are not reported anymore. But:
1) They are paged although they are not visible, giving strange paging issues
2) They are still present in the database.
I found out that the code responsible for this behaviour is in activityapi hook of the contrib modules. Talking about the nodeactivity:
<?php
function nodeactivity_activityapi(&$activity, $op) {
if ($op == 'load') {
if ($activity['data']['module'] == 'nodeactivity' && !node_access('view', node_load($activity['data']['node-id']))) {
$activity = array();
}
}
}
?>Here the activity is set as an empty array when the node is not accessible anymore (which is also the case it has been deleted).
A better approach would be to mark the activity as not anymore accessible, like:
<?php
/**
* Implementation of hook_activityapi().
*/
function nodeactivity_activityapi(&$activity, $op) {
if ($op == 'load') {
if ($activity['data']['module'] == 'nodeactivity' && !node_access('view', node_load($activity['data']['node-id']))) {
$activity['data']['zombie'] = true;
}
}
}
?>So that when the tokens are replaced in nodeactivity_token_values, we can avoid linking unaccessible or erased nodes, like:
<?php
function nodeactivity_token_values($type, $data = NULL, $options = array()) {
if ($type == 'nodeactivity' && !empty($data)) {
$data['node-type'] = theme('activity_node_type', $data['node-type']);
if($data['zombie']) {
$data['node-link'] = $data['node-title'];
} else {
$data['node-link'] = l($data['node-title'], 'node/'. $data['node-id']);
}
return $data;
}
}
?>I attach the patches for all the contrib modules in which the activity action can contain a link to a node although I've encountered the problem and tested the solution in nodeactivity, as I suppose the same problem applies in each and every of those circumstance. You might want to review them.
| Attachment | Size |
|---|---|
| commentactivity_zombie.patch | 2.06 KB |
| favorites_nodesactivity_zombie.patch | 897 bytes |
| flagactivity_zombie.patch | 1.67 KB |
| nodeactivity_zombie.patch | 837 bytes |
| ogactivity.patch | 830 bytes |
| votingapi_activity.patch | 837 bytes |

#1
I'm so sure I really like the idea of a zombie key thrown in and just keying off of that in token values...
#2
The problem with the activity records still being in the database after content is deleted is of course a problem but there is no obvious solution since we don't have a content ID (nid here) available as a column in the relevant activity table. This won't be addressed in the 6.1 branch as 6.2 is the way forward.
So that leaves the problem of having 'zombie' rows pulled from the initial activity list (via activity_get_activity) which can't be viewed anymore and thus are hidden on display. This does create the aforementioned problem with pagers and number of records that can actually be displayed.
The problem is the same though. Without a content ID to query off of during the initial activity list generation we can't fix the problem.
The main difference this patch does is allow the activity message to display but remove the link to the content in question. I think this does perhaps make sense when the node operation is a 'delete'. Since we know what the operation is we don't need to use another key like 'zombie' to tell us that. So the solution is to alter the nodeactivity_activityapi call to exclude the case of a delete operation and modify the code to set the node-link token to not actually set a link when the operation is a 'delete'.
#3
pushing to next release
#4
In the 2.x branch, I committed a fix. It deletes any message associated with that node. Including comments
http://drupal.org/cvs?commit=203196
#5
silly project module. Fixing the proper release tag...
#6
Why delete the activity messages? I definitely would like to see in the activity log, which nodes are deleted and by whom.
#7
Because a bunch of access controls work off of NID. If it can't find it in the nodeaccess table, it wont ever be rendered. If it can't associate a comment up the stream it won't be rendered. Perhaps just logging the deletion should happen, but that seems more involved then Im willing to spend time on right now.
And as noted, it produces bad links. Seems silly to keep them
Note: This is regarding Activity2, which is still under development.
#8
It is really pity if we can't create and show activity when some user delete his (or someone other) node, or comment.
I am pretty sure that it could be important information in many cases.
Igor
#9
Yea it doesn't make any sense that in the activity admin settings you can choose to include node deletion activities. But they the deletion activity itself doesn't even show up in the activity block and pages????