Skip to content

fix(perf): replace legacy NotesHooks boot registration with typed file event listeners#1836

Open
joshtrichards wants to merge 10 commits intomainfrom
jtr/refactor-remove-legacy-hooks
Open

fix(perf): replace legacy NotesHooks boot registration with typed file event listeners#1836
joshtrichards wants to merge 10 commits intomainfrom
jtr/refactor-remove-legacy-hooks

Conversation

@joshtrichards
Copy link
Copy Markdown
Member

Summary

This refactor:

  • avoids unnecessary LazyFolder materialization during app boot
  • modernizes startup by removing the remaining legacy filesystem hook registration

It does so by migrating note metadata invalidation from legacy hooks to typed filesystem event listeners.

Why

The previous implementation registered listeners by calling listenTo() on a lazy root folder during boot(). That pattern can eagerly initialize IRootFolder just to register listeners, defeating laziness and adding avoidable request-time overhead.

Using registerEventListener() in Application::register() makes listener registration declarative and avoids boot-time access to the lazy filesystem root.

This is intended to address #1835 and is also a worthwhile cleanup on its own to move Notes away from legacy hook APIs (and since it'd be really really nice to drop support for the old hooks upstream at nextcloud/server).

Changes

  • removes the legacy NotesHooks registration pattern from Application::boot()
  • registers typed filesystem event listeners in Application::register()
    • these are 1:1 equivalents of the old hooks
  • adds NoteFileEventsListener to handle note metadata invalidation for the events formerly handled by NotesHooks
  • removes obsolete Psalm baseline entries related to NotesHooks

Behavior

This refactor is intended to preserve the existing invalidation behavior:

  • write/touch/delete invalidate metadata for the affected node
  • rename invalidates metadata for the source node

Expected impact

  • avoids boot-time lazy folder materialization
  • aligns Notes with modern Nextcloud event registration patterns
  • reduces per-request overhead caused by legacy filesystem hook setup

Notes

Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
Six of one half dozen of another...

Signed-off-by: Josh <josh.t.richards@gmail.com>
@joshtrichards joshtrichards added bug Something isn't working maintenance Software maintenance, e.g. refactoring, improve code quality, documentation etc. 3. to review performance 🚀 feature: backend Related to the PHP backend labels Apr 27, 2026
@joshtrichards joshtrichards marked this pull request as ready for review April 27, 2026 03:03
Copy link
Copy Markdown
Member

@CarlSchwan CarlSchwan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah for less legacy hooks \o/

but please wait for one of the maintainer of the app to approve before merging

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review bug Something isn't working feature: backend Related to the PHP backend maintenance Software maintenance, e.g. refactoring, improve code quality, documentation etc. performance 🚀

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Notes app boot() forces LazyFolder materialization on every request causing severe performance degradation

2 participants