From aa019995ad883245654b17557bba3edf61bb3949 Mon Sep 17 00:00:00 2001 From: Brian Wolff Date: Mon, 17 Jan 2011 02:27:47 +0000 Subject: [PATCH] (follow-up r70415) Fixes the function that determines if category counts are correct to consider each section independantly. Previously, it also partially considered the total of all 3 sections, since before they were all paged as one unit. Now we page them independantly, so they should be independant. As an aside, this (when combined with r80432) fixes bug 18663 (__NOGALLERY__ used to cause mediawiki to think the cat members counts were wrong). --- includes/CategoryPage.php | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/includes/CategoryPage.php b/includes/CategoryPage.php index 7c1bea5935..bf09b0dbe0 100644 --- a/includes/CategoryPage.php +++ b/includes/CategoryPage.php @@ -593,8 +593,8 @@ class CategoryViewer { /** * What to do if the category table conflicts with the number of results - * returned? This function says what. It works the same whether the - * things being counted are articles, subcategories, or files. + * returned? This function says what. Each type is considered independantly + * of the other types. * * Note for grepping: uses the messages category-article-count, * category-article-count-limited, category-subcat-count, @@ -617,24 +617,28 @@ class CategoryViewer { # than $this->limit and there's no offset. In this case we still # know the right figure. # 3) We have no idea. - $totalrescnt = count( $this->articles ) + count( $this->children ) + - ( $this->showGallery ? $this->gallery->count() : count( $this->imgsNoGallery ) ); # Check if there's a "from" or "until" for anything + + // This is a little ugly, but we seem to use different names + // for the paging types then for the messages. + if ( $type === 'article' ) { + $pagingType = 'page'; + } else { + $pagingType = $type; + } + $fromOrUntil = false; - foreach ( array( 'page', 'subcat', 'file' ) as $t ) { - if ( $this->from[$t] !== null || $this->until[$t] !== null ) { - $fromOrUntil = true; - break; - } + if ( $this->from[$pagingType] !== null || $this->until[$pagingType] !== null ) { + $fromOrUntil = true; } - if ( $dbcnt == $rescnt || ( ( $totalrescnt == $this->limit || $fromOrUntil ) + if ( $dbcnt == $rescnt || ( ( $rescnt == $this->limit || $fromOrUntil ) && $dbcnt > $rescnt ) ) { # Case 1: seems sane. $totalcnt = $dbcnt; - } elseif ( $totalrescnt < $this->limit && !$fromOrUntil ) { + } elseif ( $rescnt < $this->limit && !$fromOrUntil ) { # Case 2: not sane, but salvageable. Use the number of results. # Since there are fewer than 200, we can also take this opportunity # to refresh the incorrect category table entry -- which should be -- 2.20.1