From: Umherirrender Date: Wed, 6 Dec 2017 19:56:19 +0000 (+0100) Subject: Add edit tags to list=watchlist X-Git-Tag: 1.31.0-rc.0~914^2 X-Git-Url: http://git.cyclocoop.org/?a=commitdiff_plain;h=46942c2536446e3e810467773f773e9b8b89968c;p=lhc%2Fweb%2Fwiklou.git Add edit tags to list=watchlist It is using the same query as list=recentchanges by left joining tag_summary Bug: T181975 Change-Id: I9e9ab9753ec0f813e9e555106cc81fd15ad9fb4a --- diff --git a/includes/api/ApiQueryWatchlist.php b/includes/api/ApiQueryWatchlist.php index 1e3b2c7398..710550abec 100644 --- a/includes/api/ApiQueryWatchlist.php +++ b/includes/api/ApiQueryWatchlist.php @@ -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' => [ diff --git a/includes/api/i18n/en.json b/includes/api/i18n/en.json index cceed01dcf..a897f06658 100644 --- a/includes/api/i18n/en.json +++ b/includes/api/i18n/en.json @@ -1331,6 +1331,7 @@ "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.", diff --git a/includes/api/i18n/qqq.json b/includes/api/i18n/qqq.json index d21f29c7a9..1e4bfc8d29 100644 --- a/includes/api/i18n/qqq.json +++ b/includes/api/i18n/qqq.json @@ -1245,6 +1245,7 @@ "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}}", diff --git a/includes/watcheditem/WatchedItemQueryService.php b/includes/watcheditem/WatchedItemQueryService.php index d0f45bec17..3478b0894c 100644 --- a/includes/watcheditem/WatchedItemQueryService.php +++ b/includes/watcheditem/WatchedItemQueryService.php @@ -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; }