Add COALESCE for image deletion and imgcomment_description_id
authorBrad Jorsch <bjorsch@wikimedia.org>
Thu, 18 Oct 2018 20:51:42 +0000 (16:51 -0400)
committerBrad Jorsch <bjorsch@wikimedia.org>
Thu, 18 Oct 2018 20:55:55 +0000 (16:55 -0400)
I have no idea why this suddenly started raising an error rather than it
doing so since February (I0dd7258fe). But this should fix it.

Bug: T207419
Change-Id: Id97e1c7c2655d90928c777bc3377e5ea23f49f6b

includes/filerepo/file/LocalFile.php

index 254ceff..d22c9a6 100644 (file)
@@ -1543,8 +1543,8 @@ class LocalFile extends File {
                        }
                        if ( $wgCommentTableSchemaMigrationStage >= MIGRATION_WRITE_BOTH ) {
                                $tables[] = 'image_comment_temp';
-                               $fields['oi_description_id'] =
-                                       'CASE WHEN img_description_id = 0 THEN imgcomment_description_id ELSE img_description_id END';
+                               $fields['oi_description_id'] = 'CASE WHEN img_description_id = 0 '
+                                       . 'THEN COALESCE(imgcomment_description_id, 0) ELSE img_description_id END';
                                $joins['image_comment_temp'] = [
                                        $wgCommentTableSchemaMigrationStage === MIGRATION_NEW ? 'JOIN' : 'LEFT JOIN',
                                        [ 'imgcomment_name = img_name' ]
@@ -2539,8 +2539,8 @@ class LocalFileDeleteBatch {
                        }
                        if ( $wgCommentTableSchemaMigrationStage >= MIGRATION_WRITE_BOTH ) {
                                $tables[] = 'image_comment_temp';
-                               $fields['fa_description_id'] =
-                                       'CASE WHEN img_description_id = 0 THEN imgcomment_description_id ELSE img_description_id END';
+                               $fields['fa_description_id'] = 'CASE WHEN img_description_id = 0 '
+                                       . 'THEN COALESCE(imgcomment_description_id, 0) ELSE img_description_id END';
                                $joins['image_comment_temp'] = [
                                        $wgCommentTableSchemaMigrationStage === MIGRATION_NEW ? 'JOIN' : 'LEFT JOIN',
                                        [ 'imgcomment_name = img_name' ]