From: Aaron Schulz Date: Wed, 24 Oct 2018 21:09:41 +0000 (-0700) Subject: Use a pre-commit hook for change_tag_def count updates X-Git-Tag: 1.34.0-rc.0~3663^2 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/User:Test/123?a=commitdiff_plain;h=30d0c549501f2cc7a0f821859f303e5ad89af4ee;p=lhc%2Fweb%2Fwiklou.git Use a pre-commit hook for change_tag_def count updates Bug: T207881 Change-Id: I3000f14d0e49482b0c90ffcfc494211fbc198a20 --- diff --git a/includes/changetags/ChangeTags.php b/includes/changetags/ChangeTags.php index 1d303c77b5..b28983f9ef 100644 --- a/includes/changetags/ChangeTags.php +++ b/includes/changetags/ChangeTags.php @@ -351,13 +351,15 @@ class ChangeTags { foreach ( $tagsToAdd as $tag ) { $changeTagMapping[$tag] = $changeTagDefStore->acquireId( $tag ); } - - $dbw->update( - 'change_tag_def', - [ 'ctd_count = ctd_count + 1' ], - [ 'ctd_name' => $tagsToAdd ], - __METHOD__ - ); + // T207881: update the counts at the end of the transaction + $dbw->onTransactionPreCommitOrIdle( function () use ( $dbw, $tagsToAdd ) { + $dbw->update( + 'change_tag_def', + [ 'ctd_count = ctd_count + 1' ], + [ 'ctd_name' => $tagsToAdd ], + __METHOD__ + ); + } ); } $tagsRows = []; @@ -408,18 +410,21 @@ class ChangeTags { ); $dbw->delete( 'change_tag', $conds, __METHOD__ ); if ( $dbw->affectedRows() && $wgChangeTagsSchemaMigrationStage > MIGRATION_OLD ) { - $dbw->update( - 'change_tag_def', - [ 'ctd_count = ctd_count - 1' ], - [ 'ctd_name' => $tag ], - __METHOD__ - ); - - $dbw->delete( - 'change_tag_def', - [ 'ctd_name' => $tag, 'ctd_count' => 0, 'ctd_user_defined' => 0 ], - __METHOD__ - ); + // T207881: update the counts at the end of the transaction + $dbw->onTransactionPreCommitOrIdle( function () use ( $dbw, $tag ) { + $dbw->update( + 'change_tag_def', + [ 'ctd_count = ctd_count - 1' ], + [ 'ctd_name' => $tag ], + __METHOD__ + ); + + $dbw->delete( + 'change_tag_def', + [ 'ctd_name' => $tag, 'ctd_count' => 0, 'ctd_user_defined' => 0 ], + __METHOD__ + ); + } ); } } }