Available from version 1.16.0
Occurs before anything is initialized in MediaWiki::performRequest().
Define function:
public static function onBeforeInitialize( \Title &$title, \Article &$article = null, \OutputPage &$output, \User &$user, \WebRequest $request, \MediaWiki $mediaWiki ) { ... }
Attach hook:

In extension.json:

	"Hooks": {
		"BeforeInitialize": "MyExtensionHooks::onBeforeInitialize"

For MediaWiki ≤1.25:

$wgHooks['BeforeInitialize'][] = 'MyExtensionHooks::onBeforeInitialize';
Called from:File(s): MediaWiki.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
  • &$article: The associated Article object. May be null.
  • &$output: OutputPage object.
  • &$user: User object
  • $request: WebRequest object
  • $mediaWiki: MediaWiki object

See alsoEdit