diff --git a/includes/LintErrorsPager.php b/includes/LintErrorsPager.php index 3004bdea..454fed62 100644 --- a/includes/LintErrorsPager.php +++ b/includes/LintErrorsPager.php @@ -42,7 +42,8 @@ class LintErrorsPager extends TablePager { private PermissionManager $permissionManager; private ?string $category; - private ?int $categoryId; + /** @var mixed */ + private $categoryId; private array $namespaces; private bool $exactMatch; private string $title; @@ -88,8 +89,11 @@ class LintErrorsPager extends TablePager { if ( $category !== null ) { $this->categoryId = $categoryManager->getCategoryId( $category ); } else { - $this->categoryId = null; + $this->categoryId = array_values( $this->categoryManager->getCategoryIds( + $this->categoryManager->getVisibleCategories() + ) ); } + $this->namespaces = $namespaces; $this->exactMatch = $exactMatch; $this->title = $title; @@ -109,11 +113,8 @@ class LintErrorsPager extends TablePager { 'linter_id', 'linter_params', 'linter_start', 'linter_end', 'linter_cat' - ] ); - - if ( $this->categoryId !== null ) { - $queryBuilder->where( [ 'linter_cat' => $this->categoryId ] ); - } + ] ) + ->where( [ 'linter_cat' => $this->categoryId ] ); if ( $this->title !== '' ) { $namespaces = $this->namespaces ?: [ NS_MAIN ]; @@ -184,7 +185,8 @@ class LintErrorsPager extends TablePager { // category is set each time based on the category set in the lint error $row // not by the class when lints are being reported by type for many pages $category = $this->category; - if ( $category === null && $row->linter_cat !== null ) { + if ( $category === null ) { + // Assert $row->linter_cat !== null ? $category = $this->categoryManager->getCategoryName( $row->linter_cat ); } else { $row->linter_cat = $this->categoryId; diff --git a/includes/SpecialLintErrors.php b/includes/SpecialLintErrors.php index 9c650363..e3acdd9a 100644 --- a/includes/SpecialLintErrors.php +++ b/includes/SpecialLintErrors.php @@ -222,16 +222,16 @@ class SpecialLintErrors extends SpecialPage { } /** - * @param string|null $par + * @param string|null $subPage */ - public function execute( $par ) { + public function execute( $subPage ) { $request = $this->getRequest(); $out = $this->getOutput(); $params = $request->getQueryValues(); $this->setHeaders(); - $this->outputHeader( $par || isset( $params[ 'titlesearch' ] ) ? 'disable-summary' : '' ); + $this->outputHeader( $subPage || isset( $params[ 'titlesearch' ] ) ? 'disable-summary' : '' ); $namespaces = $this->findNamespaces( $request ); @@ -248,7 +248,7 @@ class SpecialLintErrors extends SpecialPage { // of a custom namespace (just the text before a ':') to search for and pressed the associated Submit button. // Added the pageback parameter to inform the code that the '<- Special:LintErrors' link had been used to allow // the UI to redisplay with previous form values, instead of just resubmitting the query. - if ( $par === null && isset( $params[ 'titlesearch' ] ) && !isset( $params[ 'pageback'] ) ) { + if ( $subPage === null && isset( $params[ 'titlesearch' ] ) && !isset( $params[ 'pageback'] ) ) { unset( $params[ 'title' ] ); $params = array_merge( [ 'pageback' => true ], $params ); $out->addBacklinkSubtitle( $this->getPageTitle(), $params ); @@ -276,8 +276,11 @@ class SpecialLintErrors extends SpecialPage { return; } - if ( in_array( $par, $this->getSubpagesForPrefixSearch() ) ) { - $this->category = $par; + if ( in_array( $subPage, array_merge( + $this->categoryManager->getVisibleCategories(), + $this->categoryManager->getInvisibleCategories() + ) ) ) { + $this->category = $subPage; } if ( !$this->category ) {