processwire / processwire-issues

ProcessWire issue reports.
45 stars 2 forks source link

should Pages::trashed fire for all pages of a trashed branch? #1565

Closed BernhardBaumrock closed 2 years ago

BernhardBaumrock commented 2 years ago

Short description of the issue

Not sure if this is an issue or intended. I have a typical parent-child setup like this:

Home
  '- Clients
       '- Client 1
       '- Client 2
       '- Client 3

Then I have a hook that is executed on Pages::trashed (in my case it calls an external API to remove the client from the remote system).

When I trash Client 3 the hook is executed and the external client is also removed. Good.

Then I trashed the "Clients" page (meaning that also Client 1 + 2 are moved to the trash), but the hook did not fire for either one of them.

Expected behavior

I'm not sure if Pages::trashed should fire for Client 1+2 if the parent "Clients" page is being trashed? In my case this is what I'd expect...

ryancramerdesign commented 2 years ago

@BernhardBaumrock The trashed hook covers just the page that was moved to the trash. If it has children, that's for the hooker to decide what they want to do with them. It was written this way because it can't guarantee success if it has to load every child and provide each to the hook in a separate call. It might very well run out of memory if there are a lot of them. We don't operate on every single page until the trash is emptied, at which point we provide an interactive mechanism for dealing with more pages than can fit in memory.

BernhardBaumrock commented 2 years ago

Thx for clarifying @ryancramerdesign makes sense :)