21use Wikimedia\Timestamp\TimestampFormat as TS;
44 parent::__construct( $query, $moduleName,
'wr' );
45 $this->watchedItemQueryService = $watchedItemQueryService;
46 $this->contentLanguage = $contentLanguage;
47 $this->namespaceInfo = $namespaceInfo;
48 $this->genderCache = $genderCache;
57 $this->run( $resultPageSet );
64 private function run( $resultPageSet =
null ) {
69 $prop = array_fill_keys( (array)$params[
'prop'],
true );
70 $show = array_fill_keys( (array)$params[
'show'],
true );
71 if ( isset( $show[WatchedItemQueryService::FILTER_CHANGED] )
72 && isset( $show[WatchedItemQueryService::FILTER_NOT_CHANGED] )
78 if ( $params[
'namespace'] ) {
79 $options[
'namespaceIds'] = $params[
'namespace'];
81 if ( isset( $show[WatchedItemQueryService::FILTER_CHANGED] ) ) {
82 $options[
'filter'] = WatchedItemQueryService::FILTER_CHANGED;
84 if ( isset( $show[WatchedItemQueryService::FILTER_NOT_CHANGED] ) ) {
85 $options[
'filter'] = WatchedItemQueryService::FILTER_NOT_CHANGED;
88 if ( isset( $params[
'continue'] ) ) {
90 $options[
'startFrom'] = TitleValue::tryNew( $cont[0], $cont[1] );
94 if ( isset( $params[
'fromtitle'] ) ) {
98 if ( isset( $params[
'totitle'] ) ) {
102 $options[
'sort'] = WatchedItemStore::SORT_ASC;
103 if ( $params[
'dir'] ===
'descending' ) {
104 $options[
'sort'] = WatchedItemStore::SORT_DESC;
106 $options[
'limit'] =
$params[
'limit'] + 1;
110 $items = $this->watchedItemQueryService->getWatchedItemsForUser( $user, $options );
113 if ( $items !== [] && $resultPageSet ===
null &&
114 $this->contentLanguage->needsGenderDistinction()
117 foreach ( $items as $item ) {
118 $target = $item->getTarget();
119 if ( $this->namespaceInfo->hasGenderDistinction( $target->getNamespace() ) ) {
121 $usernames[] = $target->getDBkey();
124 if ( $usernames !== [] ) {
125 $this->genderCache->doQuery( $usernames, __METHOD__ );
129 foreach ( $items as $item ) {
130 $ns = $item->getTarget()->getNamespace();
131 $dbKey = $item->getTarget()->getDBkey();
132 if ( ++$count > $params[
'limit'] ) {
140 if ( $resultPageSet ===
null ) {
143 if ( isset( $prop[
'changed'] ) && $item->getNotificationTimestamp() !==
null ) {
144 $vals[
'changed'] =
wfTimestamp( TS::ISO_8601, $item->getNotificationTimestamp() );
155 if ( $resultPageSet ===
null ) {
158 $resultPageSet->populateFromTitles( $titles );
169 ParamValidator::PARAM_ISMULTI =>
true,
170 ParamValidator::PARAM_TYPE =>
'namespace'
173 ParamValidator::PARAM_DEFAULT => 10,
174 ParamValidator::PARAM_TYPE =>
'limit',
175 IntegerDef::PARAM_MIN => 1,
180 ParamValidator::PARAM_ISMULTI =>
true,
181 ParamValidator::PARAM_TYPE => [
187 ParamValidator::PARAM_ISMULTI =>
true,
188 ParamValidator::PARAM_TYPE => [
189 WatchedItemQueryService::FILTER_CHANGED,
190 WatchedItemQueryService::FILTER_NOT_CHANGED
194 ParamValidator::PARAM_TYPE =>
'user',
195 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name' ],
198 ParamValidator::PARAM_TYPE =>
'string',
199 ParamValidator::PARAM_SENSITIVE =>
true,
202 ParamValidator::PARAM_DEFAULT =>
'ascending',
203 ParamValidator::PARAM_TYPE => [
209 ParamValidator::PARAM_TYPE =>
'string'
212 ParamValidator::PARAM_TYPE =>
'string'
220 'action=query&list=watchlistraw'
221 =>
'apihelp-query+watchlistraw-example-simple',
222 'action=query&generator=watchlistraw&gwrshow=changed&prop=info'
223 =>
'apihelp-query+watchlistraw-example-generator',
229 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Watchlistraw';
234class_alias( ApiQueryWatchlistRaw::class,
'ApiQueryWatchlistRaw' );
wfTimestamp( $outputtype=TS::UNIX, $ts=0)
Get a timestamp string in one of various formats.