From: Aaron Schulz Date: Thu, 1 Jun 2017 05:18:12 +0000 (-0700) Subject: Avoid scoped lock errors in Category::refreshCounts() due to nesting X-Git-Tag: 1.31.0-rc.0~3059^2 X-Git-Url: http://git.cyclocoop.org/%40spipnet%40?a=commitdiff_plain;h=dbaec78dbba7de0cf063d01fcb4bcb53ba1e4e4e;p=lhc%2Fweb%2Fwiklou.git Avoid scoped lock errors in Category::refreshCounts() due to nesting Bug: T166757 Change-Id: Ie59523a8b3315f063c914cd25d7b53c11e03fbcd --- 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(); + } ); } } }