feat(dav): Add occ dav:show-listeners to allow better insights into DAV stack#61869
feat(dav): Add occ dav:show-listeners to allow better insights into DAV stack#61869DerDreschner wants to merge 1 commit into
occ dav:show-listeners to allow better insights into DAV stack#61869Conversation
0840f3e to
7cb10e8
Compare
…DAV stack Assisted-by: ClaudeCode:claude-fable-5 Signed-off-by: David Dreschner <david.dreschner@nextcloud.com>
7cb10e8 to
cc4db88
Compare
occ dav:show-listeners to allow better insides into DAV stackocc dav:show-listeners to allow better insights into DAV stack
provokateurin
left a comment
There was a problem hiding this comment.
Nice stuff! I skimmed over it a bit.
| * The order is taken directly from $server->listeners($eventName) — the very | ||
| * list Sabre\DAV\Server::emit() iterates at request time — rather than | ||
| * re-sorted here. This matters because WildcardEmitterTrait::listeners() sorts | ||
| * with array_multisort($priorities, SORT_NUMERIC, $callbacks), so equal | ||
| * priorities are tie-broken by comparing the callbacks themselves; a plain | ||
| * stable priority sort would not reproduce that. The priority is then looked | ||
| * up per callback from the raw registration maps for display only. |
There was a problem hiding this comment.
Not sure if this comment should be kept, since it was fixed upstream.
| * Collects the raw registrations that apply to a concrete event name: the | ||
| * exact listeners plus every wildcard whose (star-stripped) key is a prefix | ||
| * of the event name, each annotated with the event name it was registered |
There was a problem hiding this comment.
This sounds really strange. Can you please check in the sabre code, that this is actually true? I kind of doubt it, because it would not really work well in reality.
| <command>OCA\DAV\Command\RetentionCleanupCommand</command> | ||
| <command>OCA\DAV\Command\SendEventReminders</command> | ||
| <command>OCA\DAV\Command\SetAbsenceCommand</command> | ||
| <command>OCA\DAV\Command\ShowListeners</command> |
There was a problem hiding this comment.
This command should be registered at runtime and only when the debug mode is enabled. It is not intended to be used by admins.
| } | ||
|
|
||
| try { | ||
| $davServer = new Server($this->buildRequest($uri), '/'); |
There was a problem hiding this comment.
Unfortunately we have like 2 or 3 ways to create this server object. The entry points in apps/dav/appinfo also add some more stuff on top of that.
Besides fixing the root cause of the entry point mess, I don't know how to workaround this situation.
Summary
Right now, there is no way to see which listeners are registered for events being fired in Sabre. This makes debugging and analyzing the situation pretty hard (see #61680 for example). I would even say that we're not being able to really master the whole event system right now, based on some input I've gathered.
To change the situation I've used Claude to generate me an occ command to see all listeners for a command, their priority and give some information about the execution order and how it behaves on exceptions and errors.
Example output
Checklist
3. to review, feature component)stable32)AI (if applicable)