stable

Clone or download

Read-only

chore: Deal with conditional event listening

Contrary to the original investigations, attributes for hook registrations is more simple than with previous design. Originally string based events didn't had the issue of conditional load because strings always existed. However, when we introduced const based events, it was a pain because as base classes might not be loaded, the const might not be defined. So we worked around with the good old plain constant and check with `defined`. When we moved to object based events, we kept the `if(defined())` strategy while there was a better option: rely on autoload + class existance check. For 2023 version of events, it's time to clean this up. For weak plugin to plugin dependencies (like statistics that can be there or not), the attribute will only register the hook if the event class actually exist (ie autoload tries to load it, if it fails then we don't hook on that). Plugin developers no longer have to worry about that. Part of: request #31113 Simplify hook listening for plugins Change-Id: I72ce12da7fdb92003426f1866361b38f55c69276

Modified Files

Name
M adr/0021-attributes-based-events.md +2 −4 Go to diff View file
M doc/back-end/events.md +30 −63 Go to diff View file
M plugins/agiledashboard/include/agiledashboardPlugin.php +5 −7 Go to diff View file
M plugins/docman/include/docmanPlugin.php +8 −16 Go to diff View file
M plugins/git/include/gitPlugin.php +8 −16 Go to diff View file
M plugins/statistics/include/Frequencies/GraphDataBuilders/SampleFactory.php +2 −14 Go to diff View file
A plugins/statistics/include/FrequenciesLabels.php +58 −0 Go to diff View file
A plugins/statistics/include/FrequenciesSamples.php +50 −0 Go to diff View file
M plugins/statistics/include/SearchFieldsPresenterBuilder.php +2 −19 Go to diff View file
D plugins/statistics/include/Statistics_Event.php +0 −41 Go to diff View file
M plugins/tracker/include/trackerPlugin.php +8 −15 Go to diff View file
M src/common/Plugin/Plugin.php +2 −1 Go to diff View file
M tests/unit/common/Plugin/PluginTest.php +12 −0 Go to diff View file