From de75c4e63bd6aca3baaee57fdf79a757d4c1f622 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Wed, 18 Apr 2018 17:10:35 -0700 Subject: [PATCH] Avoid triggering Category::refreshCounts() on HTTP GET requests Trigger count refreshes more often during updates instead. Change-Id: I0f4575e648109befb86a2c8f08b491a132fe56c3 --- includes/CategoryViewer.php | 4 ---- includes/deferred/LinksDeletionUpdate.php | 5 ++--- includes/page/WikiPage.php | 6 ++---- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/includes/CategoryViewer.php b/includes/CategoryViewer.php index f36c75800b..4202249578 100644 --- a/includes/CategoryViewer.php +++ b/includes/CategoryViewer.php @@ -735,11 +735,7 @@ class CategoryViewer extends ContextSource { $totalcnt = $dbcnt; } 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 - // quick due to the small number of entries. $totalcnt = $rescnt; - DeferredUpdates::addCallableUpdate( [ $this->cat, 'refreshCounts' ] ); } else { // Case 3: hopeless. Don't give a total count at all. // Messages: category-subcat-count-limited, category-article-count-limited, diff --git a/includes/deferred/LinksDeletionUpdate.php b/includes/deferred/LinksDeletionUpdate.php index 52e996a047..3c86d11ac6 100644 --- a/includes/deferred/LinksDeletionUpdate.php +++ b/includes/deferred/LinksDeletionUpdate.php @@ -96,13 +96,12 @@ class LinksDeletionUpdate extends DataUpdate implements EnqueueableDataUpdate { } } - // Refresh the category table entry if it seems to have no pages. Check - // master for the most up-to-date cat_pages count. + // Refresh counts on categories that should be empty now if ( $title->getNamespace() === NS_CATEGORY ) { $row = $dbw->selectRow( 'category', [ 'cat_id', 'cat_title', 'cat_pages', 'cat_subcats', 'cat_files' ], - [ 'cat_title' => $title->getDBkey(), 'cat_pages <= 0' ], + [ 'cat_title' => $title->getDBkey(), 'cat_pages <= 100' ], __METHOD__ ); if ( $row ) { diff --git a/includes/page/WikiPage.php b/includes/page/WikiPage.php index afe266bf71..d4a17c82b3 100644 --- a/includes/page/WikiPage.php +++ b/includes/page/WikiPage.php @@ -3616,14 +3616,12 @@ class WikiPage implements Page, IDBAccessObject { Hooks::run( 'CategoryAfterPageRemoved', [ $cat, $this, $id ] ); } - // Refresh counts on categories that should be empty now, to - // trigger possible deletion. Check master for the most - // up-to-date cat_pages. + // Refresh counts on categories that should be empty now if ( count( $deleted ) ) { $rows = $dbw->select( 'category', [ 'cat_id', 'cat_title', 'cat_pages', 'cat_subcats', 'cat_files' ], - [ 'cat_title' => $deleted, 'cat_pages <= 0' ], + [ 'cat_title' => $deleted, 'cat_pages <= 100' ], __METHOD__ ); foreach ( $rows as $row ) { -- 2.20.1