X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fapi%2FApiQueryWatchlist.php;h=318247599b63959fecf443e129e070defe02f3a2;hp=3f597511a1325855bba8a18478ce86eda6600b5d;hb=996587e228e71436dc4bf2bceb41ce5a94e9288c;hpb=af614d2c3bebbf35e383e02bb957e41a295c159c diff --git a/includes/api/ApiQueryWatchlist.php b/includes/api/ApiQueryWatchlist.php index 3f597511a1..318247599b 100644 --- a/includes/api/ApiQueryWatchlist.php +++ b/includes/api/ApiQueryWatchlist.php @@ -34,6 +34,8 @@ use MediaWiki\MediaWikiServices; */ class ApiQueryWatchlist extends ApiQueryGeneratorBase { + private $commentStore; + public function __construct( ApiQuery $query, $moduleName ) { parent::__construct( $query, $moduleName, 'wl' ); } @@ -85,6 +87,10 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase { $this->dieWithError( 'apierror-permissiondenied-patrolflag', 'patrol' ); } } + + if ( $this->fld_comment || $this->fld_parsedcomment ) { + $this->commentStore = new CommentStore( 'rc_comment' ); + } } $options = [ @@ -179,7 +185,7 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase { $watchedItemQuery = MediaWikiServices::getInstance()->getWatchedItemQueryService(); $items = $watchedItemQuery->getWatchedItemsWithRecentChangeInfo( $wlowner, $options, $startFrom ); - foreach ( $items as list ( $watchedItem, $recentChangeInfo ) ) { + foreach ( $items as list( $watchedItem, $recentChangeInfo ) ) { /** @var WatchedItem $watchedItem */ if ( is_null( $resultPageSet ) ) { $vals = $this->extractOutputData( $watchedItem, $recentChangeInfo ); @@ -254,10 +260,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. */ @@ -353,12 +356,13 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase { Revision::DELETED_COMMENT, $user ) ) { - if ( $this->fld_comment && isset( $recentChangeInfo['rc_comment'] ) ) { - $vals['comment'] = $recentChangeInfo['rc_comment']; + $comment = $this->commentStore->getComment( $recentChangeInfo )->text; + if ( $this->fld_comment ) { + $vals['comment'] = $comment; } - if ( $this->fld_parsedcomment && isset( $recentChangeInfo['rc_comment'] ) ) { - $vals['parsedcomment'] = Linker::formatComment( $recentChangeInfo['rc_comment'], $title ); + if ( $this->fld_parsedcomment ) { + $vals['parsedcomment'] = Linker::formatComment( $comment, $title ); } } } @@ -475,7 +479,8 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase { ApiBase::PARAM_TYPE => 'user' ], 'token' => [ - ApiBase::PARAM_TYPE => 'string' + ApiBase::PARAM_TYPE => 'string', + ApiBase::PARAM_SENSITIVE => true, ], 'continue' => [ ApiBase::PARAM_HELP_MSG => 'api-help-param-continue', @@ -501,6 +506,6 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase { } public function getHelpUrls() { - return 'https://www.mediawiki.org/wiki/API:Watchlist'; + return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Watchlist'; } }