Deleted content actions are not showed in activity after content deletion

dalad - January 7, 2009 - 00:59
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
Description

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.

AttachmentSize
commentactivity_zombie.patch2.06 KB
favorites_nodesactivity_zombie.patch897 bytes
flagactivity_zombie.patch1.67 KB
nodeactivity_zombie.patch837 bytes
ogactivity.patch830 bytes
votingapi_activity.patch837 bytes

#1

sirkitree - April 26, 2009 - 23:45
Status:needs review» needs work

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

jaydub - April 27, 2009 - 02:07

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

jaydub - April 27, 2009 - 02:10

pushing to next release

#4

Scott Reynolds - April 27, 2009 - 02:28

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

Scott Reynolds - April 27, 2009 - 16:05

silly project module. Fixing the proper release tag...

#6

alexh - July 2, 2009 - 09:40

Why delete the activity messages? I definitely would like to see in the activity log, which nodes are deleted and by whom.

#7

Scott Reynolds - July 2, 2009 - 14:41

Why delete the activity messages? I definitely would like to see in the activity log, which nodes are deleted and by whom.

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

igorik - July 3, 2009 - 21:05

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

mikestefff - July 28, 2009 - 18:07

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????

 
 

Drupal is a registered trademark of Dries Buytaert.