Werk #18746: Activate changes: post-snapshot-creation hook no longer fires twice on duplicate registration
| Component | Setup | ||
| Title | Activate changes: post-snapshot-creation hook no longer fires twice on duplicate registration | ||
| Date | Apr 28, 2026 | ||
| Level | Trivial Change | ||
| Class | Bug Fix | ||
| Compatibility | Compatible - no manual interaction needed | ||
| Checkmk versions & editions |
|
Previous Behavior
Previously, registering the same callable for the same hook name more than once (via cmk.gui.hooks.register, register_builtin, or register_from_plugin) caused that callable to be invoked once per registration whenever the hook fired.
Impact
This issue affected plug-ins (typically shipped via MKPs) whose registration code happened to be evaluated more than once during the GUI process startup, for example because the same plug-in file was loaded by more than one plug-in discovery mechanism. Plug-ins that registered hooks via register_builtin were particularly exposed, because builtin hooks survive unregister_plugin_hooks() and therefore accumulate across re-registrations. As a result, hooks such as post-snapshot-creation could end up running the custom handler twice on every "Activate changes", which consumed unnecessary CPU resources and produced duplicate side-effects.
New Behavior
Hook registration is now idempotent. When the same (hook name, callable) pair is registered more than once, it is safely collapsed into a single entry. Each hook now fires the handler exactly once per hooks.call(...).