Forum OpenACS Development: Deleting a user throws errrors

Request notifications

Collapse
Posted by Iuri Sampaio on
ad_proc [acs_user::delete -user_id $user_id -permanent] , to permanently remove a user, crashed. Because of a content item (i.e. a portrait), the user partially remains in the system. It doesn't show up in the admin user's list (i.e. acs-admin/users/complex-search?), but it's still present into tables: persons, parties and acs-objects.

I tried CASCADE but I haven't succeeded. Plus, I know it's not smart, but I'm wondering if removing FK constraints temporarily and swiping the user manually would be a solution.

Is there anything wiser than that?

Best wishes,

evex=# delete from acs_objects WHERE object_id = 11531 ;
ERROR: update or delete on table "acs_objects" violates foreign key constraint "parties_party_id_fk" on table "parties"
DETAIL: Key (object_id)=(11531) is still referenced from table "parties".
e
...

Collapse
Posted by Iuri Sampaio on
More SQL logs...

evex=# select acs__remove_user(11531);
ERROR: update or delete on table "users" violates foreign key constraint "acs_objects_creation_user_fk" on table "acs_objects"
DETAIL: Key (user_id)=(11531) is still referenced from table "acs_objects".
CONTEXT: SQL statement "delete from users
where user_id = delete__user_id"
PL/pgSQL function acs_user__delete(integer) line 7 at SQL statement
SQL statement "SELECT acs_user__delete(remove_user__user_id)"
PL/pgSQL function acs__remove_user(integer) line 16 at PERFORM
evex=#

Collapse
Posted by Antonio Pisano on
Dear Iuri,

it is in general not trivial to completely remove a user. What if, for instance, this was the creator of a forum? Would we want to completely delete this forum also (and all its potentially valuable content)? This is why we don't set any on delete cascade on creation users of an acs_object.

It is usually the case that the portrait is also an acs_object with creation user set to the one the portrait belongs to. Therefore, one must delete it first and then user deletion can happen.

For me it makes sense that one deletes a user expecting its portrait to go away too. Therefore I have addressed this in commit http://cvs.openacs.org/changelog/OpenACS?cs=MAIN%3Aantoniop%3A20170816091820

Hope this helps

Collapse
Posted by Iuri Sampaio on
Thanks Pisano,
That's what I expected. In fact and fortunately, the content created by the user was only the portrait, and I removed all references from content::item.

I guess I know what to do and I'm only afraid to it! :)

Best wishes

Collapse
Posted by Iuri Sampaio on
p.s. I'm aware, deleting a user is a big issue in a community based system. I also agree that a user must be never deleted, plus the task to remove all content generated by the user can be a real nightmare. thus, deleting a user is not recommended.

Best wishes

Collapse
Posted by Antonio Pisano on
Disabling the user is in general sufficient as "deletion" and is safe with respects to foreign keys. Other strategies or policies might be thought of, but I don't see any clear benefit that would come from there ATM.

Glad you could solve it!

Ciao