Skip to content

Conversation

@imsidkg
Copy link

@imsidkg imsidkg commented Nov 26, 2025

What?

Fixes the beforeOperation collection hook being called when using the findVersions operation, just as it is for the standard find operation.

Why?

Previously, the beforeOperation hook was only triggered for standard find operations, but not for findVersions. This led to inconsistent behavior, as custom logic (such as access control, logging, or argument modification) defined in beforeOperation would not run when querying document versions. This PR brings parity and predictability to hook execution across both operations.

How?

The logic for invoking the beforeOperation hook (as seen in find.ts) was added to findVersions.ts.
Now, when findVersions is called, all registered beforeOperation hooks are executed with the correct arguments before the main operation logic runs.

Fixes
#14726

@imsidkg imsidkg changed the title fix(core): add beforeOperation hook in findVersions collections operations fix: add beforeOperation hook in findVersions collections operations Nov 26, 2025
@jhb-dev
Copy link
Contributor

jhb-dev commented Nov 28, 2025

Hi @imsidkg, thanks for creating this PR to the issue I opened!

During a discussion with r1tsuu in the Discord, he noticed that the afterOperation hook is also not called for find operations. Could you maybe extend this PR to also call that?

@imsidkg
Copy link
Author

imsidkg commented Nov 28, 2025

sure @jhb-dev i will work on it.

@jhb-dev
Copy link
Contributor

jhb-dev commented Dec 3, 2025

Thanks @imsidkg, but I guess you can close this PR in favour of #14778, which also calls the beforeOperation and afterOperation hooks in even more operations where it was missing.

Copy link
Contributor

@DanRibbens DanRibbens left a comment

Choose a reason for hiding this comment

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

We are going to close this PR in favor of #14778 which solves the same issue and is more thorough.
Thanks for the PR and drawing attention to this issue though! I would love to get you in as a contributor on another PR on the next one.

} = args

const req = args.req!
const { fallbackLocale, locale, payload } = req
Copy link
Contributor

Choose a reason for hiding this comment

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

This is redundant with the above.

@DanRibbens DanRibbens closed this Dec 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants