Search code examples
mediawikimediawiki-extensions

How do I track down the source definition of a custom hook event in a Mediawiki extension?


Here's an example:

https://phabricator.wikimedia.org/diffusion/EPFM/browse/master/?grep=BeforeFreeTextSubst

A Mediawiki extension where Hooks::run( 'PageForms::BeforeFreeTextSubst', ...) gets invoked but there's no other record or trace of where it's defined. If there was some mapping of strings/names to functions it would be registered somewhere else, and if it was a function name it should show up somewhere else.

I'm seeing this with a few other function hook events.


Solution

  • There isn't any "source definition" other than where the hook is run from. That is where the hook is defined; it may or may not actually be hooked onto anywhere. All the hook definition is is a name and a set of parameters that are passed to hook callbacks.

    To help find out where the hook is actually used, you can use the (new) codesearch tool:

    https://codesearch.wmflabs.org/extensions/?q=BeforeFreeTextSubst

    (It looks like this one is not used by any extension that is in Wikimedia source control.)