Don't include hidden category counts in page info

Bug: T337275
Bug: T334527
Change-Id: I6439df894c06fc5592422e72dac04150591f4033
This commit is contained in:
Arlo Breault 2024-04-02 15:12:19 -04:00
parent 632d7095d8
commit 397b36e8e3

View file

@ -353,16 +353,21 @@ class Database {
->fetchResultSet(); ->fetchResultSet();
// Initialize zero values // Initialize zero values
$ret = array_fill_keys( $this->categoryManager->getVisibleCategories(), 0 ); $categories = $this->categoryManager->getVisibleCategories();
$ret = array_fill_keys( $categories, 0 );
foreach ( $rows as $row ) { foreach ( $rows as $row ) {
try { try {
$catName = $this->categoryManager->getCategoryName( $row->linter_cat ); $catName = $this->categoryManager->getCategoryName( $row->linter_cat );
} catch ( MissingCategoryException $e ) { } catch ( MissingCategoryException $e ) {
continue; continue;
} }
// Only set visible categories. Alternatively, we could add another
// where clause to the selection above.
if ( !in_array( $catName, $categories, true ) ) {
continue;
}
$ret[$catName] = (int)$row->count; $ret[$catName] = (int)$row->count;
} }
return $ret; return $ret;
} }