Forum OpenACS Q&A: How to Delete a User???

Collapse
Posted by Frank Bergmann on
Hi,

simple task but big issue due to the referential integrity constraints to all these 200+ database tables...

Here is what I've found:
- There is a "user-nuke.tcl" in the dotlrn package, but it only removes the user plus some innocent acs_rels.
- There was a "nuke.tcl" in ACS 3.4 with a lot of deletes, but completely outdated, obviously.

So I'm actually working on a "nuke.tcl" based on the ACS 3.4 code, adding basic OpenACS 5.1.5 and ]project-open[ V3.0.0.6 stuff. I'm gradually increasing complexity, and it seems to be OK as a quick patch.

However, I definitely would prefer a more thorough solution that could _guarantee_ to delete a user. I'm thinking about callbacks in each package that would cleanup everything in this module wrt. the user. Any ideas?

Also, I'm trying to cleanup stuff from the content repository for a given user. Do you know of any code available for this?

Bests,
Frank

mailto:frank_dot_bergmann_at_project_dash_open_dot_com
http://www.project-open.com/

Collapse
Posted by Richard Hamilton on
Frank,

There was a dicsussion on this subject about a year or so ago following a question I asked about this issue. I will try to find the link.

The issue was discussed but the decision was taken to do nothing because there was no obvious solution that was acceptable at the time.

It was considered unacceptable to have code (be it kernel code or other package code) deleting data that belongs to a package.

Now that callbacks have been developed and are widely used it does seem sensible to require each package to provide a callback for user deletion.

However this is unlikely to be trivial and there will be issues. For example where objects are connected with multiple users and where packages are tightly integrated together when installed together but can exist seperately.

Collapse
Posted by Rocael Hernández Rizzardini on
Frank, the idea was to use user_merge procs, which are callbacks at each package to handle the deletion.
For instance, when you call this for merge:
callback::merge::MergePackageUser::impl::as -from_user_id from_user_id -to_user_id to_user_id

if the to_user_id is empty, then it means "delete", and each package callback implementation should do the proper deletion mechanism. The user merge code is commited at oacs-5-2, so you can work on an implementation there.

The deletion should handle special cases, like for a forum contribution, putting something like special user "deleted user", etc.

Collapse
Posted by Nima Mazloumi on
What has merge to do with delete?
Collapse
Posted by russ m on
I realise this isn't a solution to Frank's immediate problem, but is there any reason to not recommend using "on delete cascade" for all of OACS's RI constraints? I always assumed the current codebase didn't do that because postgres didn't support on delete cascade in the early 7.x series, but now that all the supported PG versions can handle it should it not be adopted? This would reduce nuking a user to "acs_object__delete(:user_id)"...
Collapse
Posted by Malte Sussdorff on
The reason is simple. We have a lot of packages that reuse content of a user (take forum postings for example). If a user has started a thread and you do a delete on cascade, you delete the start of the thread and with it all messages that use this thread as the parent_id. So in effect you delete a lot of content just when you want to delete a user. The approach described by Roc is therefore the one to choose.
Collapse
Posted by Frank Bergmann on
Hi,

thanks for all the replies. Yes, the "merge" makes a lot of sense.

In our case the main objective is to allow users to remove the contents from our demo configuration once they have tested it and decided to go productive with ]project-translation[ or ]project-consulting[.

For this reason we actually _want_ to delete the contents associated with a user. I admit that this is not the normal case.

So we have gone forward, featuring now a "nuke user & users's contents" function and a "nuke project" function, mainly based on the ACS 3.4 code, just if somebody is interested in it.

I wonder how many modules are supporting the "merge" callbacks alread...

Thanks for the replies,
Frank