Forum OpenACS Development: Re: Cannot delete groups with segments and rels

Collapse
Posted by tammy m on
Hi,

I took a look around to see if maybe there is anything else besides permissions, relations and rel_segs that would make sense to be deleted automatically when deleting a group. I figure since Randy submitted a bug and patch for deleting groups, we might as well get as much of this handled now with that bug as possible!

I think there might be a few more items... here are the steps I think need to be done to delete a group.

  1. delete rel_constraints.required_rel_segment on this group
  2. delete permissions on group and all its rel_segs
  3. delete dependent constraints on group and it's rel_segs (like rel_segments_delete tcl proc)
  4. delete relations to group and rel_segs

The 1st step is based on code I found from where a group is deleted from the admin page (packages/acs-subsite/www/admin/groups/delete-2.tcl); group::delete does an extra step before it calls application_group__delete:

  -- the acs_group package takes care of segments referred
  	    -- to by rel_constraints.rel_segment. We delete the ones
	    -- references by rel_constraints.required_rel_segment here.
for row in (select cons.constraint_id
                          from rel_constraints cons, rel_segments segs
                         where segs.segment_id = cons.required_rel_segment
                           and segs.group_id = :group_id) loop

                rel_segment.delete(row.constraint_id);

            end loop;
Seems the tcl proc group::delete is the right/preferred way to delete app groups. It looks like an extra rel_constraint may be left lying around if I call pl/sql function acs_group__delete directly instead of tcl proc group::delete. Maybe this constraint is created for me when I create my app group (on it's relationship to the app group rel_type)? I think any constraints I might create on my rel_segments are deleted differently (like in rel_segments_delete)? I'm not sure about the constraint deletion here...

The 2nd I had to do or my call to acs_group__delete would fail with ERROR: acs_permissions_grantee_id_fk referential integrity violation - key in parties still referenced from acs_permissions

I know I didn't create any rel_constraints on my group so I don't care about the 3rd... but might be a "bug" for someone else and cause acs_group__delete to fail;(

Anyway, there is definitely more to deleting a group than what the current acs_group__delete does and it would be really helpful to get most of this done in Randy's patch to the proc so that it gets into the code base soon:) Can a core team developer let us know what the right things to do in this proc are?

For instance rel_types to the group or it's rel_segs would also need to be removed if they were created. But I don't think that's a good thing to do in acs_group__delete itself since rel_types are reusable among groups and may not have been created strictly for use with a single group. I think deleting rel_types should be the creator's decision to explicitly delete.

And, just for the record, I am still able to drop my groups after I have added members to them too. I tried that today;)

Guidance from those who know on the final patch to acs_group__delete?! thanks:)

Collapse
Posted by Randy O'Meara on
Tammy,

That's really some great and thorough work. I can only hope that this thread has gained the attention of the core folks. I know that several people (including core folk) have complained in these forums about having to address deleting permissions explicitly. I think it's great that you took the time to thoroughly analyze *all* of the shortcomings of group deletion.

Many of the people that would know if your fix is correct are very busy at the moment preparing the 5.0 code for release. It would be a shame for this to fall through a crack because it's not addressed at this point in time.