Introduce HookEssentials#5474
Merged
Merged
Conversation
This was referenced Feb 16, 2026
11371cd to
28b18ff
Compare
28b18ff to
267c5df
Compare
a161f42 to
f2bdd99
Compare
Al2Klimov
commented
Feb 18, 2026
Al2Klimov
left a comment
Member
Author
There was a problem hiding this comment.
Test
- Install Fedora 42
- Apply https://github.com/Al2Klimov/ansible-icinga-fedora
- Downgrade to https://git.icinga.com/packages/icingaweb/-/jobs/817857
- Ensure /icingaweb2/health shows Icinga DB and Redis
- In
/usr/share/icingaweb2/modules/icingadb/run.php, comment out$this->provideHook('health', 'RedisHealth'); - Ensure /icingaweb2/health shows Icinga DB only
- In
/usr/share/icingaweb2/modules/icingadb/run.php, add\Icinga\Module\Icingadb\ProvidedHook\RedisHealth::register(); - Ensure /icingaweb2/health shows Icinga DB and Redis again = it works
Member
Author
|
@lippserd Please have a quick look here. This PR would allow to make
gleich gescheit. |
0fd0f9d to
9b20fcd
Compare
Merged
9b20fcd to
d955987
Compare
sukhwinder33445
requested changes
Apr 10, 2026
d955987 to
844af8c
Compare
sukhwinder33445
previously approved these changes
Apr 14, 2026
\Icinga\Application\Hook\EssentialsHookEssentials
Member
|
I made the following changes:
@Al2Klimov please have a look since I have amended some of the changes into your commits. |
TheSyscall
requested changes
Jun 22, 2026
TheSyscall
left a comment
Contributor
There was a problem hiding this comment.
- I searched through the codebase and I can't find any hook that doesn't use the new HookEssentials methods. (At least in icingaweb itself)
- Tested the functionality behind these hooks, and they seem to work just fine.
getModuleshould probably be final, but that is sadly not possible in PHP.
Finding(s):
getHookName inside the hook implementations should be made final in all instances, overriding it could lead to strange bugs. But that would be entirely self-inflicted.
2c62f40 to
a486b04
Compare
Co-authored-by: Eric Lippmann <eric.lippmann@icinga.com>
Co-authored-by: Eric Lippmann <eric.lippmann@icinga.com>
Co-authored-by: Eric Lippmann <eric.lippmann@icinga.com>
Co-authored-by: Eric Lippmann <eric.lippmann@icinga.com>
The `use HookEssentials { register as protected parentRegister; }` alias
construct in `LoginButtonHook` and `RequestHook` is harder to read than a
simple method override. A `protected static isAlwaysRun()` default on the
trait lets subclasses declare their intent without redefining `register()`.
A static property was not viable here: PHP forbids redefining a trait
property in a using class with a different initial value.
Ported from `Hook\Common\HookUtils` in Icinga DB Web, generalized to return null when the hook is not registered under a module namespace.
lippserd
approved these changes
Jun 23, 2026
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.
Introduce
Icinga\Application\Hook\HookEssentialsas the shared API for hook base classes to register and retrieve hook implementations through their own type.This moves existing core hook classes to methods such as
register(),all(),first(), andisRegistered(), while keeping the underlying hook registry behavior unchanged.The new trait centralizes common hook behavior and lets hook base classes define their registry name once through
getHookName(). It also addsgetModule()for hook implementations that belong to a module namespace.Existing direct uses of
Hook::has(),Hook::all(),Hook::first(), andHook::register()are replaced where a typed hook base class is available. The old low-level APIs andModule::provideHook()are marked as deprecated in favor ofHook\HookEssentials.