Closed (fixed)
Project:
Node Profile
Version:
master
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
23 Oct 2006 at 16:30 UTC
Updated:
11 Mar 2007 at 15:03 UTC
Jump to comment: Most recent file
So as per my comments on the group, here is a patch that deletes profiles when a user is deleted.
It does this by default at the moment, but I guess a setting could be added to change this.
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | nodeprofile_deleteprofiles_try3.patch | 4.99 KB | jpetso |
| #7 | nodeprofile_deleteprofiles_try2.patch | 4.69 KB | jpetso |
| nodeprofile_deleteprofiles.patch.txt | 1.3 KB | sym |
Comments
Comment #1
fagoI'm OK with this as default action.
But you need to track down the nodefamily relations, e.g. the grandchildren of a nodeprofile should be also deleted.
Further I would like a bit more elegant code (looking at the $query_types..). E.g. you could directly use something like
in the nodeprofile loop, or use implode() instead.
Comment #2
jpetso commentedAfter some experiments with node_load() and subsequent inspection of the user_confirm_delete_submit() code, it's quite clear that the node_load() approach will not work because the user is deleted from the {user} table before hook_user() is called. And if node_load() doesn't find the user entry in the database then it sets the node's uid to 0, so we can't filter by uid.
Which means that a direct query is the way to go. Soon to come.
Comment #3
jpetso commentedTurns out that the uid of the {node} entry is already at 0, no matter if retrieved by node_load() or direct database query. Maybe it depends on the ordering of the modules, or something I currently didn't think of. In any case, I can't get it working here at the moment, at least with 4.7. Let me think about this for a while.
Comment #4
fagoyes, actually it's a case of module ordering. We could adapt that or we could also get the usernode-id and retrieve the ids of the profiles about the nodefamily relations. But that would require the usernode module for this functionality.
So I think it would be better to order the module appropriate, here is an handbook page about module weighting:
http://drupal.org/node/110238.
Comment #5
jpetso commentedBad news, module ordering doesn't work. module.inc always places the filter, node, system, user, and watchdog modules at the very beginning of the module list, so we can never get called before node.module. Bastards.
Comment #6
jpetso commentedHm... node et al. are always put to the top of the list in Drupal 4.7, but not in Drupal 5! That means it should work there, I'll try it out instantly.
Comment #7
jpetso commentedOk, here's the solution, but you won't like it, and neither do I.
The good news is that it works, and that it doesn't require the usernode module to exist. The bad news is that node_load() doesn't work (see the comments in the patch), and because of that, node_delete() also doesn't work. Which means we have to go db_query() all the way.
Comment #8
fagogood work!
I think its the best way we can do that.
But I think we should call nodeapi load like node_load() does, so that modules that use nodeapi op delete get their full node object, like they except it.
Then I fink the function _nodeprofile_relation_descendants_dive() should go into the nodefamily module as another API function - that might be useful in other cases too.
Comment #9
jpetso commentedInclude 'load' invokes, and make the patch dependent on issue #121578, getting rid of _nodeprofile_relation_descendants_dive() as private function and taking it from nodefamily instead.
Comment #10
fagoworks like expected, good work!
committed to 5.x and HEAD.
Comment #11
(not verified) commented