Forum OpenACS Development: Re: Chicken and egg problem with content_item__delete

Collapse
Posted by Jarkko Laine on
Hi Jun,

I was talking about content revisions, not associated objects per se.

If that's the expected behaviour, then why is this in content_item__del:

  raise NOTICE ''Deleting associated revisions...'';
  -- 3) delete all revisions of this item
  delete from cr_item_publish_audit
    where item_id = delete__item_id;

  for v_revision_val in select
                          revision_id
                        from
                          cr_revisions
                        where
                          item_id = delete__item_id
  LOOP
    PERFORM acs_object__delete(v_revision_val.revision_id);
  end loop;

...because there's no idea to delete revisions if the assumption is that there can be no revisions left before calling content_item__delete. From what I found, you can unset the live revision with CR TCL API but not the latest revision (which would not make any sense anyway). Having the latest_revision set will pull the abovementioned trigger as well.

So I don't really see why I would need to delete the revisions by hand before trying to delete the item. I'm working on Simulation which uses bcms and calls bcms::item::delete_item to delete items. bcms::item::delete_item then calls content_item__delete to do the dirty work. I don't think simulation package is the right place to put in code that essentially unsets the live and latest revisions of a cr item and then deletes them. I really think content_item__del should at least be able to delete the revisions (it is after all trying to do it already, with no success) even if it weren't the default behaviour.