mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/ParserFunctions
synced 2024-11-24 00:06:21 +00:00
Use HookContainer to register hooks on the fly.
Manipulating $wgHooks is deprecated and unreliable. Use HookContainer instead. Needed-By: Iddcb760cf8961316d6527e81b9aa968657d8354c Change-Id: I413cd2ae43fe4b13917d61a50e190b536fce7279
This commit is contained in:
parent
ee66f0bfff
commit
f97da7df26
|
@ -30,22 +30,6 @@ class ParserFunctions {
|
|||
/** ~10 seconds */
|
||||
private const MAX_TIME_CHARS = 6000;
|
||||
|
||||
/**
|
||||
* Register ParserClearState hook.
|
||||
* We defer this until needed to avoid the loading of the code of this file
|
||||
* when no parser function is actually called.
|
||||
*/
|
||||
private static function registerClearHook() {
|
||||
static $done = false;
|
||||
if ( !$done ) {
|
||||
global $wgHooks;
|
||||
$wgHooks['ParserClearState'][] = static function () {
|
||||
self::$mTimeChars = 0;
|
||||
};
|
||||
$done = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ExprParser
|
||||
*/
|
||||
|
@ -431,7 +415,14 @@ class ParserFunctions {
|
|||
Parser $parser, PPFrame $frame, $format, $date, $language, $local
|
||||
) {
|
||||
global $wgLocaltimezone;
|
||||
self::registerClearHook();
|
||||
|
||||
MediaWikiServices::getInstance()->getHookContainer()->register(
|
||||
'ParserClearState',
|
||||
static function () {
|
||||
self::$mTimeChars = 0;
|
||||
}
|
||||
);
|
||||
|
||||
if ( $date === '' ) {
|
||||
$cacheKey = $parser->getOptions()->getTimestamp();
|
||||
$timestamp = new MWTimestamp( $cacheKey );
|
||||
|
|
Loading…
Reference in a new issue