Merge "Migrate SpecialUndelete and Diff from tag_summary to change_tag"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Wed, 12 Dec 2018 22:30:55 +0000 (22:30 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Wed, 12 Dec 2018 22:30:55 +0000 (22:30 +0000)
1  2 
includes/diff/DifferenceEngine.php

   * @ingroup DifferenceEngine
   */
  
+ use MediaWiki\MediaWikiServices;
  use MediaWiki\Revision\RevisionRecord;
  use MediaWiki\Revision\SlotRecord;
+ use MediaWiki\Storage\NameTableAccessException;
  
  /**
   * DifferenceEngine is responsible for rendering the difference between two revisions as HTML.
@@@ -1055,7 -1057,7 +1057,7 @@@ class DifferenceEngine extends ContextS
                        $slotDiff = $slotDiffRenderer->getDiff( $slotContents[$role]['old'],
                                $slotContents[$role]['new'] );
                        if ( $slotDiff && $role !== SlotRecord::MAIN ) {
 -                              // TODO use human-readable role name at least
 +                              // FIXME: ask SlotRoleHandler::getSlotNameMessage
                                $slotTitle = $role;
                                $difftext .= $this->getSlotHeader( $slotTitle );
                        }
  
                // Load tags information for both revisions
                $dbr = wfGetDB( DB_REPLICA );
+               $changeTagDefStore = MediaWikiServices::getInstance()->getChangeTagDefStore();
                if ( $this->mOldid !== false ) {
-                       $this->mOldTags = $dbr->selectField(
-                               'tag_summary',
-                               'ts_tags',
-                               [ 'ts_rev_id' => $this->mOldid ],
+                       $tagIds = $dbr->selectFieldValues(
+                               'change_tag',
+                               'ct_tag_id',
+                               [ 'ct_rev_id' => $this->mOldid ],
                                __METHOD__
                        );
+                       $tags = [];
+                       foreach ( $tagIds as $tagId ) {
+                               try {
+                                       $tags[] = $changeTagDefStore->getName( (int)$tagId );
+                               } catch ( NameTableAccessException $exception ) {
+                                       continue;
+                               }
+                       }
+                       $this->mOldTags = implode( ',', $tags );
                } else {
                        $this->mOldTags = false;
                }
-               $this->mNewTags = $dbr->selectField(
-                       'tag_summary',
-                       'ts_tags',
-                       [ 'ts_rev_id' => $this->mNewid ],
+               $tagIds = $dbr->selectFieldValues(
+                       'change_tag',
+                       'ct_tag_id',
+                       [ 'ct_rev_id' => $this->mNewid ],
                        __METHOD__
                );
+               $tags = [];
+               foreach ( $tagIds as $tagId ) {
+                       try {
+                               $tags[] = $changeTagDefStore->getName( (int)$tagId );
+                       } catch ( NameTableAccessException $exception ) {
+                               continue;
+                       }
+               }
+               $this->mNewTags = implode( ',', $tags );
  
                return true;
        }