Context
As of MediaWIki 1.35, it is possible to utilize a new set of interfaces and instantiated classes to register hook handlers. This was done to improve, static validity of hook handler parameters, and enable dependency injection for hook handler classes.
Currently, the Entity Schema extension still registers its hook handlers through a class with static methods. While this methodology is not deprecated, switching to the newer hook pattern will allow us to leverage its advantages.
For more information about hooks and hook handlers, see:
- https://www.mediawiki.org/wiki/Manual:Hooks#Handling_hooks_in_MediaWiki_1.35_and_later
- https://doc.wikimedia.org/mediawiki-core/master/php/md_docs_Hooks.html
Main Objectives
Similarly to what was done in the WikibaseClient extension in T256246: Migrate Client hooks to extension JSON, we would like to migrate each of the hook handlers in the Entity Schema extension to use MediaWiki's hook interfaces. This involves:
- Creating a hook handler class that implements the required hook interface and contains a public method for the hook handler itself, as described in: https://doc.wikimedia.org/mediawiki-core/master/php/md_docs_Hooks.html#autotoc_md47
- Registering the new hook class in extension.json, including any services that need to be injected in the services key (full example).
Considerations
As there might be a need for dependency injection in some of the hook handler, this may depend on some tickets of T329828: [ES-M5] [EPIC] Migrate EntitySchema to use the MediaWiki Service Container .
While a bulk of this work will most likely be completed with upcoming feature development in EntitySchema, it is pivotal that the migration is complete, in order to ensure consistency in the patterns employed in the codebase and avoid degradation of the codebase's comprehensibility by mixing various code organization ideas.