Manual:Hooks/SpecialPageExecuteBeforeHeader

From Linux Web Expert

SpecialPageExecuteBeforeHeader
<translate> Available from <tvar name=1><translate> version <tvar </tvar></translate>
<translate> Removed in <tvar name=1><translate> version <tvar </tvar></translate>
called before setting the header text of the special page
<translate> Define function:</translate>
public static function onSpecialPageExecuteBeforeHeader( $specialPage, $par, $funct ) { ... }
<translate> Attach hook:</translate> <translate> In <tvar name=1>extension.json</tvar>:</translate>
{
	"Hooks": {
		"SpecialPageExecuteBeforeHeader": "MediaWiki\\Extension\\MyExtension\\Hooks::onSpecialPageExecuteBeforeHeader"
	}
}
<translate> Called from:</translate> <translate> File(s):</translate> SpecialPage.php
<translate> Interface:</translate> SpecialPageExecuteBeforeHeaderHook.php

<translate> For more information about attaching hooks, see <tvar name=1>Manual:Hooks </tvar>.</translate>

Details

  • $specialPage: SpecialPage object
  • $par: paramter passed to the special page (string)
  • $funct: function called to execute the special page

Usage

There is a note in includes/SpecialPage.php where this hook is called stating that it is broken for extensions:

# FIXME: these hooks are broken for extensions and anything else that subclasses SpecialPage. 

This is due to the fact that extensions that subclass SpecialPage implement their own execute function. Since the hooks are fired in the SpecialPage parent class execute function they don't get called in the subclass. A bug has been filed for this, but the chances of it being fixed in the short term are probably small due to this subclass/parentclass problem.