Move image_comment_temp entries when the file is moved
authorBrad Jorsch <bjorsch@wikimedia.org>
Sun, 18 Mar 2018 15:37:05 +0000 (11:37 -0400)
committerBrad Jorsch <bjorsch@wikimedia.org>
Sun, 18 Mar 2018 15:37:05 +0000 (11:37 -0400)
Bug: T189985
Change-Id: I437102d62cb94fd3195ff06ee8185ce5a2dc941e

includes/filerepo/file/LocalFile.php

index ec4a5fb..7fc45eb 100644 (file)
@@ -3374,6 +3374,8 @@ class LocalFileMoveBatch {
         * many rows where updated.
         */
        protected function doDBUpdates() {
+               global $wgCommentTableSchemaMigrationStage;
+
                $dbw = $this->db;
 
                // Update current image
@@ -3383,6 +3385,15 @@ class LocalFileMoveBatch {
                        [ 'img_name' => $this->oldName ],
                        __METHOD__
                );
+               if ( $wgCommentTableSchemaMigrationStage > MIGRATION_OLD ) {
+                       $dbw->update(
+                               'image_comment_temp',
+                               [ 'imgcomment_name' => $this->newName ],
+                               [ 'imgcomment_name' => $this->oldName ],
+                               __METHOD__
+                       );
+               }
+
                // Update old images
                $dbw->update(
                        'oldimage',