Merge "Revert "selenium: add new message banner test to user spec""
[lhc/web/wiklou.git] / includes / api / ApiQueryWatchlist.php
index 2ab8524..f9ac44a 100644 (file)
@@ -1,9 +1,5 @@
 <?php
 /**
- *
- *
- * Created on Sep 25, 2006
- *
  * Copyright © 2006 Yuri Astrakhan "<Firstname><Lastname>@gmail.com"
  *
  * This program is free software; you can redistribute it and/or modify
@@ -34,6 +30,7 @@ use MediaWiki\MediaWikiServices;
  */
 class ApiQueryWatchlist extends ApiQueryGeneratorBase {
 
+       /** @var CommentStore */
        private $commentStore;
 
        public function __construct( ApiQuery $query, $moduleName ) {
@@ -52,7 +49,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
@@ -81,6 +78,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() ) {
@@ -242,6 +240,9 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase {
                if ( $this->fld_loginfo ) {
                        $includeFields[] = WatchedItemQueryService::INCLUDE_LOG_INFO;
                }
+               if ( $this->fld_tags ) {
+                       $includeFields[] = WatchedItemQueryService::INCLUDE_TAGS;
+               }
                return $includeFields;
        }
 
@@ -260,10 +261,7 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase {
 
        private function extractOutputData( WatchedItem $watchedItem, array $recentChangeInfo ) {
                /* Determine the title of the page that has been changed. */
-               $title = Title::makeTitle(
-                       $watchedItem->getLinkTarget()->getNamespace(),
-                       $watchedItem->getLinkTarget()->getDBkey()
-               );
+               $title = Title::newFromLinkTarget( $watchedItem->getLinkTarget() );
                $user = $this->getUser();
 
                /* Our output data. */
@@ -393,6 +391,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;
                }
@@ -455,6 +463,7 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase {
                                        'sizes',
                                        'notificationtimestamp',
                                        'loginfo',
+                                       'tags',
                                ]
                        ],
                        'show' => [