X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fdeferred%2FLinksDeletionUpdate.php;h=5ab83c62c6a69e4371359b74824a77949c11f9d3;hp=9f6257c810b9e327b9d4aaa3eaf6d954811b7ea6;hb=4df0c71911500466a6330b8fe29c623ef5b51e41;hpb=9c185ca85c3c58f96e866c9347c2b7f031ddb289 diff --git a/includes/deferred/LinksDeletionUpdate.php b/includes/deferred/LinksDeletionUpdate.php index 9f6257c810..5ab83c62c6 100644 --- a/includes/deferred/LinksDeletionUpdate.php +++ b/includes/deferred/LinksDeletionUpdate.php @@ -71,6 +71,9 @@ class LinksDeletionUpdate extends DataUpdate implements EnqueueableDataUpdate { // Make sure all links update threads see the changes of each other. // This handles the case when updates have to batched into several COMMITs. $scopedLock = LinksUpdate::acquirePageLock( $this->getDB(), $id ); + if ( !$scopedLock ) { + throw new RuntimeException( "Could not acquire lock for page ID '{$id}'." ); + } } $title = $this->page->getTitle(); @@ -101,7 +104,8 @@ class LinksDeletionUpdate extends DataUpdate implements EnqueueableDataUpdate { if ( $title->getNamespace() === NS_CATEGORY ) { // T166757: do the update after the main job DB commit DeferredUpdates::addCallableUpdate( function () use ( $title ) { - $this->refreshCategoryIfEmpty( $title ); + $cat = Category::newFromName( $title->getDBkey() ); + $cat->refreshCountsIfEmpty(); } ); } @@ -187,35 +191,6 @@ class LinksDeletionUpdate extends DataUpdate implements EnqueueableDataUpdate { ScopedCallback::consume( $scopedLock ); } - /** - * @param Title $title - */ - private function refreshCategoryIfEmpty( Title $title ) { - $dbw = $this->getDB(); - - $row = $dbw->selectRow( - 'category', - [ 'cat_id', 'cat_title', 'cat_pages', 'cat_subcats', 'cat_files' ], - [ 'cat_title' => $title->getDBkey(), 'cat_pages <= 100' ], - __METHOD__ - ); - - if ( !$row ) { - return; // nothing to delete - } - - $cat = Category::newFromRow( $row, $title ); - $hasLink = $dbw->selectField( - 'categorylinks', - '1', - [ 'cl_to' => $title->getDBkey() ], - __METHOD__ - ); - if ( !$hasLink ) { - $cat->refreshCounts(); // delete the category table entry - } - } - private function batchDeleteByPK( $table, array $conds, array $pk, $bSize ) { $services = MediaWikiServices::getInstance(); $lbFactory = $services->getDBLoadBalancerFactory();