- if ( $wgCommentTableSchemaMigrationStage <= MIGRATION_WRITE_BOTH ) {
- $fields['fa_description'] = 'img_description';
- }
- if ( $wgCommentTableSchemaMigrationStage >= MIGRATION_WRITE_BOTH ) {
- $fields['fa_description_id'] = 'img_description_id';
- }
-
- if ( $wgCommentTableSchemaMigrationStage !== MIGRATION_OLD &&
- $wgCommentTableSchemaMigrationStage !== MIGRATION_NEW
- ) {
- // Upgrade any rows that are still old-style. Otherwise an upgrade
- // might be missed if a deletion happens while the migration script
- // is running.
- $res = $dbw->select(
- [ 'image' ],
- [ 'img_name', 'img_description' ],
- [
- 'img_name' => $this->file->getName(),
- 'img_description_id' => 0,
- ],
- __METHOD__
- );
- foreach ( $res as $row ) {
- $imgFields = $commentStore->insert( $dbw, 'img_description', $row->img_description );
- $dbw->update(
- 'image',
- $imgFields,
- [ 'img_name' => $row->img_name ],
- __METHOD__
- );
- }
- }
-