From 52c3a500284589098d994207ed7cd8bbff528c55 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Wed, 19 Apr 2017 20:43:56 -0700 Subject: [PATCH] Fix bogus field reference in Category::getCountMessage() callback Follows-up 922e68f739f143. (T162121) Bug: T162941 Change-Id: I40623203e97f7155c2af171a37b1128a59415315 --- includes/Category.php | 7 +++++++ includes/CategoryViewer.php | 11 +---------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/includes/Category.php b/includes/Category.php index ece32ea105..50ffeec1c8 100644 --- a/includes/Category.php +++ b/includes/Category.php @@ -321,6 +321,13 @@ class Category { } $dbw = wfGetDB( DB_MASTER ); + # Avoid excess contention on the same category (T162121) + $name = __METHOD__ . ':' . md5( $this->mName ); + $scopedLock = $dbw->getScopedLockAndFlush( $name, __METHOD__, 1 ); + if ( !$scopedLock ) { + return; + } + $dbw->startAtomic( __METHOD__ ); $cond1 = $dbw->conditional( [ 'page_namespace' => NS_CATEGORY ], 1, 'NULL' ); diff --git a/includes/CategoryViewer.php b/includes/CategoryViewer.php index 0205d708ca..7086a48b77 100644 --- a/includes/CategoryViewer.php +++ b/includes/CategoryViewer.php @@ -740,16 +740,7 @@ class CategoryViewer extends ContextSource { // to refresh the incorrect category table entry -- which should be // quick due to the small number of entries. $totalcnt = $rescnt; - $category = $this->cat; - DeferredUpdates::addCallableUpdate( function () use ( $category ) { - # Avoid excess contention on the same category (T162121) - $dbw = wfGetDB( DB_MASTER ); - $name = __METHOD__ . ':' . md5( $this->mName ); - $scopedLock = $dbw->getScopedLockAndFlush( $name, __METHOD__, 1 ); - if ( $scopedLock ) { - $category->refreshCounts(); - } - } ); + 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, -- 2.20.1