From dbaec78dbba7de0cf063d01fcb4bcb53ba1e4e4e Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Wed, 31 May 2017 22:18:12 -0700 Subject: [PATCH] Avoid scoped lock errors in Category::refreshCounts() due to nesting Bug: T166757 Change-Id: Ie59523a8b3315f063c914cd25d7b53c11e03fbcd --- includes/deferred/LinksDeletionUpdate.php | 6 +++++- includes/page/WikiPage.php | 5 ++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/includes/deferred/LinksDeletionUpdate.php b/includes/deferred/LinksDeletionUpdate.php index ca29078c63..3dd9de6f91 100644 --- a/includes/deferred/LinksDeletionUpdate.php +++ b/includes/deferred/LinksDeletionUpdate.php @@ -106,7 +106,11 @@ class LinksDeletionUpdate extends DataUpdate implements EnqueueableDataUpdate { __METHOD__ ); if ( $row ) { - Category::newFromRow( $row, $title )->refreshCounts(); + $cat = Category::newFromRow( $row, $title ); + // T166757: do the update after the main job DB commit + DeferredUpdates::addCallableUpdate( function () use ( $cat ) { + $cat->refreshCounts(); + } ); } } diff --git a/includes/page/WikiPage.php b/includes/page/WikiPage.php index 7489f44627..2adc5fbc10 100644 --- a/includes/page/WikiPage.php +++ b/includes/page/WikiPage.php @@ -3496,7 +3496,10 @@ class WikiPage implements Page, IDBAccessObject { ); foreach ( $rows as $row ) { $cat = Category::newFromRow( $row ); - $cat->refreshCounts(); + // T166757: do the update after this DB commit + DeferredUpdates::addCallableUpdate( function () use ( $cat ) { + $cat->refreshCounts(); + } ); } } } -- 2.20.1