Available from version 1.16.0
Occurs before anything is initialized in MediaWiki::performRequest().
Define function:
public static function onBeforeInitialize( &$title, $unused, $output, $user, $request, $mediaWiki ) { ... }
Attach hook: In extension.json:
	"Hooks": {
		"BeforeInitialize": "MediaWiki\\Extension\\MyExtension\\Hooks::onBeforeInitialize"
Called from: File(s): MediaWiki.php
Interface: BeforeInitializeHook.php

For more information about attaching hooks, see Manual:Hooks .
For examples of extensions using this hook, see Category:BeforeInitialize extensions.


  • &$title: Title being used for request
  • $unused: Always null. Historically an Article object to be passed back, or null. Unused since 2011.
  • $output: OutputPage object.
  • $user: User object
  • $request: WebRequest object
  • $mediaWiki: Current MediaWiki instance calling this hook handler.

See also[edit]