- $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__
+ );
+ } );