+ $changeTagMapping = [];
+ if ( $wgChangeTagsSchemaMigrationStage > MIGRATION_OLD ) {
+ $tagDefRows = [];
+ foreach ( $tagsToAdd as $tag ) {
+ $tagDefRows[] = [
+ 'ctd_name' => $tag,
+ 'ctd_user_defined' => 0,
+ 'ctd_count' => 1
+ ];
+ }
+
+ $dbw->upsert(
+ 'change_tag_def',
+ $tagDefRows,
+ [ 'ctd_name' ],
+ [ 'ctd_count = ctd_count + 1' ],
+ __METHOD__
+ );
+
+ $res = $dbw->select(
+ 'change_tag_def',
+ [ 'ctd_name', 'ctd_id' ],
+ [ 'ctd_name' => $tagsToAdd ]
+ );
+ foreach ( $res as $row ) {
+ $changeTagMapping[$row->ctd_name] = $row->ctd_id;
+ }
+ }
+