Repository navigation
[18.0][FIX] auditlog: don't patch methods while the registry is loading - #3853
Open
parabol123654 wants to merge 1 commit into
Open
parabol123654 wants to merge 1 commit into
parabol123654 wants to merge 1 commit into
Conversation
parabol123654
force-pushed
the
18.0-fix-auditlog-patch-after-registry-loaded
branch
from
November 14, 2026 18:31
7915c68 to
88e15f2
Compare
A rule created or written as module data called _register_hook() during the registry loading, so _patch_method() kept as origin the method of a partially set up model class. The overrides of the modules loaded later were skipped for the rest of the process, and the final _register_hook() pass did not patch again because the class flag was already set. Rules are now only applied once the registry is loaded; the final _register_hook() pass of the loading applies them on the complete classes. Fixes OCA#3852 on 18.0. Assisted-by: Claude Opus 5.5
parabol123654
force-pushed
the
18.0-fix-auditlog-patch-after-registry-loaded
branch
from
November 24, 2026 00:41
88e15f2 to
0c67685
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3852 on 18.0 (thanks @Paddy691 for the analysis; the issue is reported on 19.0, and 18.0 has the same code).
When a module ships a subscribed
auditlog.ruleas data,AuditlogRule.create()/write()call_register_hook()while the registry is still loading._patch_method()then keeps asoriginthewrite(or create/read/...) of a model class that only has the modules loaded so far. The overrides of the modules loaded afterwards are skipped for the rest of the process. The final_register_hook()pass ofload_modulesdoes not patch again either, because theauditlog_ruled_*flag is already set.The fix:
_register_hook()ofauditlog.ruledoes nothing whileself.pool.loadedis false. Core setsregistry.loaded = Truebefore the final pass that calls_register_hook()on every model, so the rules are applied there, on the complete classes. Rules created or changed afterwards (UI, RPC) are still applied right away.Test:
test_no_patch_while_registry_loadingcreates and subscribes a rule withregistry.loaded = False, checks thatwriteis not patched, then runs the hook on the loaded registry and checks that it is.True is not false.auditlogpass.Assisted-by: Claude Opus 5.5