diff --git a/includes/CategoryTree.php b/includes/CategoryTree.php index d814e4da..07e9a09f 100644 --- a/includes/CategoryTree.php +++ b/includes/CategoryTree.php @@ -78,11 +78,10 @@ class CategoryTree { * @param bool $hideroot * @param array $attr * @param int $depth - * @param bool $allowMissing * @return bool|string */ public function getTag( ?Parser $parser, string $category, bool $hideroot = false, array $attr = [], - int $depth = 1, bool $allowMissing = false + int $depth = 1 ) { $disableCache = $this->config->get( 'CategoryTreeDisableCache' ); @@ -114,7 +113,7 @@ class CategoryTree { $attr['data-ct-mode'] = $this->optionManager->getOption( 'mode' ); $attr['data-ct-options'] = $this->optionManager->getOptionsAsJsStructure(); - if ( !$allowMissing && !$title->getArticleID() ) { + if ( !$title->getArticleID() ) { $html = Html::rawElement( 'span', [ 'class' => 'CategoryTreeNotice' ], wfMessage( 'categorytree-not-found' ) ->plaintextParams( $category ) diff --git a/includes/Hooks.php b/includes/Hooks.php index 137ba1f8..b880109a 100644 --- a/includes/Hooks.php +++ b/includes/Hooks.php @@ -185,15 +185,13 @@ class Hooks implements * @param array $argv * @param Parser|null $parser * @param PPFrame|null $frame - * @param bool $allowMissing * @return bool|string */ public function parserHook( $cat, array $argv, Parser $parser = null, - PPFrame $frame = null, - $allowMissing = false + PPFrame $frame = null ) { if ( $parser ) { $parserOutput = $parser->getOutput(); @@ -226,7 +224,7 @@ class Hooks implements } return $message . - $ct->getTag( $parser, $cat, $hideroot, $attr, $depth, $allowMissing ); + $ct->getTag( $parser, $cat, $hideroot, $attr, $depth ); } /** @@ -247,13 +245,17 @@ class Hooks implements // Not enabled, don't do anything return; } + if ( !$categoryTitle->exists() ) { + // Category doesn't exist. Let the normal LinkRenderer generate the link. + return; + } CategoryTree::setHeaders( $out ); $options = $this->config->get( 'CategoryTreePageCategoryOptions' ); $link = $this->parserHook( $this->titleFormatter->getPrefixedText( $categoryTitle ), - $options, null, null, true + $options ); }