ChangeTags: Teach updateTags() to derive log_id from rev_id (and the other way)
authorBartosz Dziewoński <matma.rex@gmail.com>
Thu, 7 Jan 2016 02:31:53 +0000 (18:31 -0800)
committerBartosz Dziewoński <matma.rex@gmail.com>
Thu, 7 Jan 2016 02:37:42 +0000 (18:37 -0800)
This means that, for example, the tags for a file upload's log entry
and the associated page revision should finally be in sync.

Bug: T122090
Change-Id: I3537278ff728d160bbdcf149d0f99fe9621c02e6

includes/changetags/ChangeTags.php

index 5aac495..a8c9f7b 100644 (file)
@@ -212,6 +212,22 @@ class ChangeTags {
                        );
                }
 
+               if ( $log_id && !$rev_id ) {
+                       $rev_id = $dbw->selectField(
+                               'log_search',
+                               'ls_value',
+                               array( 'ls_field' => 'associated_rev_id', 'ls_log_id' => $log_id ),
+                               __METHOD__
+                       );
+               } elseif ( !$log_id && $rev_id ) {
+                       $log_id = $dbw->selectField(
+                               'log_search',
+                               'ls_log_id',
+                               array( 'ls_field' => 'associated_rev_id', 'ls_value' => $rev_id ),
+                               __METHOD__
+                       );
+               }
+
                // update the tag_summary row
                $prevTags = array();
                if ( !self::updateTagSummaryRow( $tagsToAdd, $tagsToRemove, $rc_id, $rev_id,