Manual:Hooks/SetupAfterCache
From Linux Web Expert
SetupAfterCache | |
---|---|
<translate> Available from <tvar name=1><translate> version <tvar </tvar></translate> Called in Setup.php, after cache objects are set | |
<translate> Define function:</translate> | public static function onSetupAfterCache( ) { ... }
|
<translate> Attach hook:</translate> | <translate> In <tvar name=1>extension.json</tvar>:</translate>
{
"Hooks": {
"SetupAfterCache": "MediaWiki\\Extension\\MyExtension\\Hooks::onSetupAfterCache"
}
}
|
<translate> Called from:</translate> | <translate> File(s):</translate> Setup.php |
<translate> Interface:</translate> | SetupAfterCacheHook.php |
<translate> For more information about attaching hooks, see <tvar name=1>Manual:Hooks </tvar>.</translate>
<translate> For examples of extensions using this hook, see <tvar name=cat>Category:SetupAfterCache extensions</tvar>.</translate>
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.
- In practice, this hook is typically by extensions to register additional configuration settings and globals.
- It is not generally a safe place for changing global configuration settings because some services might have already been instantiated by the time this hook runs. While there is currently no dedicated hook for changing configuration, MediaWikiServices is safer than this one.