Hello,
Not too sure this is the appropriate place to post this, so if it’s not I’d appreciate you telling me where to go to
First and foremost, I’m working on the french translation of Modx so I apologize if I’m not using the proper english translations in my descriptions, but I do hope it’ll still be understandable.
I was working on some plugins using the Resources events, and I noticed something that bothers me.
There is a clear discrepancy in the way events are triggered depending on how you delete/undelete a resource, here is what I’ve jotted down about the behaviours:
- First, the setup. A parent resource, containing a few child resources (but behaviour seems to be the same with more parent-children levels).
-
If you right click on the parent, then click Delete (or go in the form then click the Delete button)
- Event OnDocFormDelete triggered on the parent resource
- Event OnResourceDelete triggered on the parent
- Absolutely NO Event triggered on the child resources, yet they still get marked as deleted (?)
-
If you right click on the parent then click Undelete (or go in the trash and choose to restore the parent resource)
- Event OnResourceUndelete triggered on the parent
- Absolutely NO Event triggered on the child resources, yet they still get undeleted (?)
-
Go into the parent resource’s form, Parameters tab then check Deleted then save the resource
- Event OnResourceDelete triggered on the parent
- Event OnDocFormSave triggered on the parent
- No OnDocFormDelete event triggered on the parent (?)
- No Event triggered on child resources, which I suppose is the intended behaviour.
- No effect on the child resources as well (not deleted), which I suppose is the intended behaviour
-
Go into the parent resource’s form, Parameters tab then uncheck Deleted then save the resource
- Event OnResourceUndelete triggered on the parent
- Event OnDocFormSave triggered on the parent
- No Event triggered on child resources, which I suppose is the intended behaviour.
- No effect on the child resources as well (not undeleted if they were marked as deleted), which I suppose is the intended behaviour
Another thing of note, there seems to be no information about which action was performed on the resources, contrary to every other type of object (unless I’ve missed something, there is an “action” property in the plugin/snippet/chunk… objects)
I don’t really know how to end this post, just wanted to ask for thoughts or insights as to why all this functions that way?
Edit:
Since it seems that OnDocFormDelete is the event corresponding to the cascading delete (empyrically, but I might be wrong), I guess what bothers me the most is the following question: How are you supposed to differentiate cases 2 & 4? Go & check each and every child ‘deleted’ state? Am I missing something?
Edit 2: I am working on 2.8.3, will try this on modx 3
Edit 3: Same behaviour on modx 3