Add edit tags to list=watchlist
authorUmherirrender <umherirrender_de.wp@web.de>
Wed, 6 Dec 2017 19:56:19 +0000 (20:56 +0100)
committerUmherirrender <umherirrender_de.wp@web.de>
Tue, 9 Jan 2018 20:02:14 +0000 (20:02 +0000)
It is using the same query as list=recentchanges by left joining
tag_summary

Bug: T181975
Change-Id: I9e9ab9753ec0f813e9e555106cc81fd15ad9fb4a

includes/api/ApiQueryWatchlist.php
includes/api/i18n/en.json
includes/api/i18n/qqq.json
includes/watcheditem/WatchedItemQueryService.php

index 1e3b2c7..710550a 100644 (file)
@@ -53,7 +53,7 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase {
                $fld_flags = false, $fld_timestamp = false, $fld_user = false,
                $fld_comment = false, $fld_parsedcomment = false, $fld_sizes = false,
                $fld_notificationtimestamp = false, $fld_userid = false,
-               $fld_loginfo = false;
+               $fld_loginfo = false, $fld_tags;
 
        /**
         * @param ApiPageSet $resultPageSet
@@ -82,6 +82,7 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase {
                        $this->fld_patrol = isset( $prop['patrol'] );
                        $this->fld_notificationtimestamp = isset( $prop['notificationtimestamp'] );
                        $this->fld_loginfo = isset( $prop['loginfo'] );
+                       $this->fld_tags = isset( $prop['tags'] );
 
                        if ( $this->fld_patrol ) {
                                if ( !$user->useRCPatrol() && !$user->useNPPatrol() ) {
@@ -243,6 +244,9 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase {
                if ( $this->fld_loginfo ) {
                        $includeFields[] = WatchedItemQueryService::INCLUDE_LOG_INFO;
                }
+               if ( $this->fld_tags ) {
+                       $includeFields[] = WatchedItemQueryService::INCLUDE_TAGS;
+               }
                return $includeFields;
        }
 
@@ -391,6 +395,16 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase {
                        }
                }
 
+               if ( $this->fld_tags ) {
+                       if ( $recentChangeInfo['rc_tags'] ) {
+                               $tags = explode( ',', $recentChangeInfo['rc_tags'] );
+                               ApiResult::setIndexedTagName( $tags, 'tag' );
+                               $vals['tags'] = $tags;
+                       } else {
+                               $vals['tags'] = [];
+                       }
+               }
+
                if ( $anyHidden && ( $recentChangeInfo['rc_deleted'] & Revision::DELETED_RESTRICTED ) ) {
                        $vals['suppressed'] = true;
                }
@@ -453,6 +467,7 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase {
                                        'sizes',
                                        'notificationtimestamp',
                                        'loginfo',
+                                       'tags',
                                ]
                        ],
                        'show' => [
index cceed01..a897f06 100644 (file)
        "apihelp-query+watchlist-paramvalue-prop-sizes": "Adds the old and new lengths of the page.",
        "apihelp-query+watchlist-paramvalue-prop-notificationtimestamp": "Adds timestamp of when the user was last notified about the edit.",
        "apihelp-query+watchlist-paramvalue-prop-loginfo": "Adds log information where appropriate.",
+       "apihelp-query+watchlist-paramvalue-prop-tags": "Lists tags for the entry.",
        "apihelp-query+watchlist-param-show": "Show only items that meet these criteria. For example, to see only minor edits done by logged-in users, set $1show=minor|!anon.",
        "apihelp-query+watchlist-param-type": "Which types of changes to show:",
        "apihelp-query+watchlist-paramvalue-type-edit": "Regular page edits.",
index d21f29c..1e4bfc8 100644 (file)
        "apihelp-query+watchlist-paramvalue-prop-sizes": "{{doc-apihelp-paramvalue|query+watchlist|prop|sizes}}",
        "apihelp-query+watchlist-paramvalue-prop-notificationtimestamp": "{{doc-apihelp-paramvalue|query+watchlist|prop|notificationtimestamp}}",
        "apihelp-query+watchlist-paramvalue-prop-loginfo": "{{doc-apihelp-paramvalue|query+watchlist|prop|loginfo}}",
+       "apihelp-query+watchlist-paramvalue-prop-tags": "{{doc-apihelp-paramvalue|query+watchlist|prop|tags}}",
        "apihelp-query+watchlist-param-show": "{{doc-apihelp-param|query+watchlist|show}}",
        "apihelp-query+watchlist-param-type": "{{doc-apihelp-param|query+watchlist|type}}",
        "apihelp-query+watchlist-paramvalue-type-edit": "{{doc-apihelp-paramvalue|query+watchlist|type|edit}}",
index d0f45be..3478b08 100644 (file)
@@ -27,6 +27,7 @@ class WatchedItemQueryService {
        const INCLUDE_PATROL_INFO = 'patrol';
        const INCLUDE_SIZES = 'sizes';
        const INCLUDE_LOG_INFO = 'loginfo';
+       const INCLUDE_TAGS = 'tags';
 
        // FILTER_* constants are part of public API (are used in ApiQueryWatchlist and
        // ApiQueryWatchlistRaw classes) and should not be changed.
@@ -335,6 +336,9 @@ class WatchedItemQueryService {
                if ( in_array( self::INCLUDE_COMMENT, $options['includeFields'] ) ) {
                        $tables += $this->getCommentStore()->getJoin()['tables'];
                }
+               if ( in_array( self::INCLUDE_TAGS, $options['includeFields'] ) ) {
+                       $tables[] = 'tag_summary';
+               }
                return $tables;
        }
 
@@ -384,6 +388,10 @@ class WatchedItemQueryService {
                if ( in_array( self::INCLUDE_LOG_INFO, $options['includeFields'] ) ) {
                        $fields = array_merge( $fields, [ 'rc_logid', 'rc_log_type', 'rc_log_action', 'rc_params' ] );
                }
+               if ( in_array( self::INCLUDE_TAGS, $options['includeFields'] ) ) {
+                       // prefixed with rc_ to include the field in getRecentChangeFieldsFromRow
+                       $fields['rc_tags'] = 'ts_tags';
+               }
 
                return $fields;
        }
@@ -678,6 +686,9 @@ class WatchedItemQueryService {
                if ( in_array( self::INCLUDE_COMMENT, $options['includeFields'] ) ) {
                        $joinConds += $this->getCommentStore()->getJoin()['joins'];
                }
+               if ( in_array( self::INCLUDE_TAGS, $options['includeFields'] ) ) {
+                       $joinConds['tag_summary'] = [ 'LEFT JOIN', [ 'rc_id=ts_rc_id' ] ];
+               }
                return $joinConds;
        }