From 29b0524b4eb5ec3642883e9c414b15c4acf5b75a Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Thu, 2 Jun 2016 22:07:58 -0700 Subject: [PATCH] Avoid DBPerformance warnings in Category::initialize() Use DeferredUpdates and zero-out negative values in the meantime. Bug: T92357 Change-Id: Ia1339395b70b042edba6dc1d570acb92c90a287b --- includes/Category.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/includes/Category.php b/includes/Category.php index 6209a1a9ea..28b566a7f9 100644 --- a/includes/Category.php +++ b/includes/Category.php @@ -95,7 +95,11 @@ class Category { # and should not be kept, and 2) we *probably* don't have to scan many # rows to obtain the correct figure, so let's risk a one-time recount. if ( $this->mPages < 0 || $this->mSubcats < 0 || $this->mFiles < 0 ) { - $this->refreshCounts(); + $this->mPages = max( $this->mPages, 0 ); + $this->mSubcats = max( $this->mSubcats, 0 ); + $this->mFiles = max( $this->mFiles, 0 ); + + DeferredUpdates::addCallableUpdate( [ $this, 'refreshCounts' ] ); } return true; -- 2.20.1