Avoid triggering Category::refreshCounts() on HTTP GET requests
authorAaron Schulz <aschulz@wikimedia.org>
Thu, 19 Apr 2018 00:10:35 +0000 (17:10 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Thu, 19 Apr 2018 04:45:24 +0000 (04:45 +0000)
Trigger count refreshes more often during updates instead.

Change-Id: I0f4575e648109befb86a2c8f08b491a132fe56c3

includes/CategoryViewer.php
includes/deferred/LinksDeletionUpdate.php
includes/page/WikiPage.php

index f36c758..4202249 100644 (file)
@@ -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,
index 52e996a..3c86d11 100644 (file)
@@ -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 ) {
index afe266b..d4a17c8 100644 (file)
@@ -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 ) {