Manual:Hooks/SetupAfterCache
SetupAfterCache | |
---|---|
Available from version 1.14.0 Called in Setup.php, after cache objects are set | |
Define function: | public static function onSetupAfterCache( ) { ... }
|
Attach hook: | In extension.json:
{
"Hooks": {
"SetupAfterCache": "MediaWiki\\Extension\\MyExtension\\Hooks::onSetupAfterCache"
}
}
|
Called from: | File(s): Setup.phpCategory:MediaWiki hooks included in Setup.php#SetupAfterCache |
Interface: | SetupAfterCacheHook.php |
For more information about attaching hooks, see Manual:Hooks .
For examples of extensions using this hook, see Category:SetupAfterCache extensions.
Usage
- SetupAfterCache should only be used for any initialization that needs to run right after cache objects are set.
- If you need to use the RequestContext , consider the BeforeInitialize and ApiBeforeMain hooks instead.
- Callback functions to be called further down the road after most initialisations are complete can be stored in the
$wgExtensionFunctions
variable.
- SetupAfterCache is not safe place for changing global configuration settings, because some services might have already been instantiated by the time this (or any) hook runs. The only safe place for manipulating configuration variables is an extension registration callback. The MediaWikiServices hook can be used as a stop-gap alternative for cases where a registration callback is not sufficient, but it is not entirely safe.