Fix comment handling on image upload or deletion
authorBrad Jorsch <bjorsch@wikimedia.org>
Thu, 18 Oct 2018 21:12:44 +0000 (17:12 -0400)
committerBrad Jorsch <bjorsch@wikimedia.org>
Thu, 18 Oct 2018 21:12:44 +0000 (17:12 -0400)
Before Iab5f5215, the call to CommentStore::insertWithTempTable() also
happened to populate image_comment_temp for the later call to
insertSelect() when moving rows from the image table to oldimage or
filearchive. There was nothing in the image table itself that needed
updating.

In that change those calls were changed to CommentStore::insert(), but
it was missed that in that case we do have to update the image table
itself.

Bug: T207419
Change-Id: I26c417c9ab8a9160a7c7ec548ffdfabf17f01980

includes/filerepo/file/LocalFile.php

index 254ceff..32d1301 100644 (file)
@@ -1570,7 +1570,13 @@ class LocalFile extends File {
                                        [ 'image_comment_temp' => [ 'LEFT JOIN', [ 'imgcomment_name = img_name' ] ] ]
                                );
                                foreach ( $res as $row ) {
-                                       $commentStore->insert( $dbw, 'img_description', $row->img_description );
+                                       $imgFields = $commentStore->insert( $dbw, 'img_description', $row->img_description );
+                                       $dbw->update(
+                                               'image',
+                                               $imgFields,
+                                               [ 'img_name' => $row->img_name ],
+                                               __METHOD__
+                                       );
                                }
                        }
 
@@ -2566,7 +2572,13 @@ class LocalFileDeleteBatch {
                                        [ 'image_comment_temp' => [ 'LEFT JOIN', [ 'imgcomment_name = img_name' ] ] ]
                                );
                                foreach ( $res as $row ) {
-                                       $commentStore->insert( $dbw, 'img_description', $row->img_description );
+                                       $imgFields = $commentStore->insert( $dbw, 'img_description', $row->img_description );
+                                       $dbw->update(
+                                               'image',
+                                               $imgFields,
+                                               [ 'img_name' => $row->img_name ],
+                                               __METHOD__
+                                       );
                                }
                        }