Avoid scoped lock errors in Category::refreshCounts() due to nesting
authorAaron Schulz <aschulz@wikimedia.org>
Thu, 1 Jun 2017 05:18:12 +0000 (22:18 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Thu, 1 Jun 2017 05:18:12 +0000 (22:18 -0700)
Bug: T166757
Change-Id: Ie59523a8b3315f063c914cd25d7b53c11e03fbcd

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

index ca29078..3dd9de6 100644 (file)
@@ -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();
+                               } );
                        }
                }
 
index 7489f44..2adc5fb 100644 (file)
@@ -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();
+                               } );
                        }
                }
        }