diff --git a/includes/CategoryTree.php b/includes/CategoryTree.php index e4da8fad..b3a01b71 100644 --- a/includes/CategoryTree.php +++ b/includes/CategoryTree.php @@ -33,7 +33,6 @@ use MediaWiki\Html\Html; use MediaWiki\Linker\LinkRenderer; use MediaWiki\MediaWikiServices; use MediaWiki\Output\OutputPage; -use MediaWiki\Parser\Parser; use MediaWiki\Registration\ExtensionRegistry; use MediaWiki\SpecialPage\SpecialPage; use MediaWiki\Title\Title; @@ -73,31 +72,20 @@ class CategoryTree { /** * Custom tag implementation. This is called by Hooks::parserHook, which is used to * load CategoryTreeFunctions.php on demand. - * @param ?Parser $parser * @param string $category * @param bool $hideroot * @param array $attr * @param int $depth * @return bool|string */ - public function getTag( ?Parser $parser, string $category, bool $hideroot = false, array $attr = [], + public function getTag( string $category, bool $hideroot = false, array $attr = [], int $depth = 1 ) { - $disableCache = $this->config->get( 'CategoryTreeDisableCache' ); - $category = trim( $category ); if ( $category === '' ) { return false; } - if ( $parser ) { - if ( $disableCache === true ) { - $parser->getOutput()->updateCacheExpiry( 0 ); - } elseif ( is_int( $disableCache ) ) { - $parser->getOutput()->updateCacheExpiry( $disableCache ); - } - } - $title = self::makeTitle( $category ); if ( $title === null ) { diff --git a/includes/Hooks.php b/includes/Hooks.php index b880109a..4f030d20 100644 --- a/includes/Hooks.php +++ b/includes/Hooks.php @@ -197,6 +197,13 @@ class Hooks implements $parserOutput = $parser->getOutput(); $parserOutput->addModuleStyles( [ 'ext.categoryTree.styles' ] ); $parserOutput->addModules( [ 'ext.categoryTree' ] ); + + $disableCache = $this->config->get( 'CategoryTreeDisableCache' ); + if ( $disableCache === true ) { + $parserOutput->updateCacheExpiry( 0 ); + } elseif ( is_int( $disableCache ) ) { + $parserOutput->updateCacheExpiry( $disableCache ); + } } $ct = new CategoryTree( $argv, $this->config, $this->dbProvider, $this->linkRenderer ); @@ -224,7 +231,7 @@ class Hooks implements } return $message . - $ct->getTag( $parser, $cat, $hideroot, $attr, $depth ); + $ct->getTag( $cat, $hideroot, $attr, $depth ); } /**