57 parent::__construct( $query, $moduleName,
'wr' );
58 $this->watchedItemQueryService = $watchedItemQueryService;
59 $this->contentLanguage = $contentLanguage;
60 $this->namespaceInfo = $namespaceInfo;
61 $this->genderCache = $genderCache;
69 $this->run( $resultPageSet );
76 private function run( $resultPageSet =
null ) {
81 $prop = array_fill_keys( (array)$params[
'prop'],
true );
82 $show = array_fill_keys( (array)$params[
'show'],
true );
83 if ( isset( $show[WatchedItemQueryService::FILTER_CHANGED] )
84 && isset( $show[WatchedItemQueryService::FILTER_NOT_CHANGED] )
90 if ( $params[
'namespace'] ) {
91 $options[
'namespaceIds'] = $params[
'namespace'];
93 if ( isset( $show[WatchedItemQueryService::FILTER_CHANGED] ) ) {
94 $options[
'filter'] = WatchedItemQueryService::FILTER_CHANGED;
96 if ( isset( $show[WatchedItemQueryService::FILTER_NOT_CHANGED] ) ) {
97 $options[
'filter'] = WatchedItemQueryService::FILTER_NOT_CHANGED;
100 if ( isset( $params[
'continue'] ) ) {
102 $options[
'startFrom'] = TitleValue::tryNew( $cont[0], $cont[1] );
106 if ( isset( $params[
'fromtitle'] ) ) {
110 if ( isset( $params[
'totitle'] ) ) {
114 $options[
'sort'] = WatchedItemStore::SORT_ASC;
115 if ( $params[
'dir'] ===
'descending' ) {
116 $options[
'sort'] = WatchedItemStore::SORT_DESC;
118 $options[
'limit'] =
$params[
'limit'] + 1;
122 $items = $this->watchedItemQueryService->getWatchedItemsForUser( $user, $options );
125 if ( $items !== [] && $resultPageSet ===
null &&
126 $this->contentLanguage->needsGenderDistinction()
129 foreach ( $items as $item ) {
130 $linkTarget = $item->getTarget();
131 if ( $this->namespaceInfo->hasGenderDistinction( $linkTarget->getNamespace() ) ) {
132 $usernames[] = $linkTarget->getText();
135 if ( $usernames !== [] ) {
136 $this->genderCache->doQuery( $usernames, __METHOD__ );
140 foreach ( $items as $item ) {
141 $ns = $item->getTarget()->getNamespace();
142 $dbKey = $item->getTarget()->getDBkey();
143 if ( ++$count > $params[
'limit'] ) {
149 $t = Title::makeTitle( $ns, $dbKey );
151 if ( $resultPageSet ===
null ) {
154 if ( isset( $prop[
'changed'] ) && $item->getNotificationTimestamp() !==
null ) {
155 $vals[
'changed'] =
wfTimestamp( TS_ISO_8601, $item->getNotificationTimestamp() );
166 if ( $resultPageSet ===
null ) {
169 $resultPageSet->populateFromTitles( $titles );
179 ParamValidator::PARAM_ISMULTI =>
true,
180 ParamValidator::PARAM_TYPE =>
'namespace'
183 ParamValidator::PARAM_DEFAULT => 10,
184 ParamValidator::PARAM_TYPE =>
'limit',
185 IntegerDef::PARAM_MIN => 1,
190 ParamValidator::PARAM_ISMULTI =>
true,
191 ParamValidator::PARAM_TYPE => [
197 ParamValidator::PARAM_ISMULTI =>
true,
198 ParamValidator::PARAM_TYPE => [
199 WatchedItemQueryService::FILTER_CHANGED,
200 WatchedItemQueryService::FILTER_NOT_CHANGED
204 ParamValidator::PARAM_TYPE =>
'user',
205 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name' ],
208 ParamValidator::PARAM_TYPE =>
'string',
209 ParamValidator::PARAM_SENSITIVE =>
true,
212 ParamValidator::PARAM_DEFAULT =>
'ascending',
213 ParamValidator::PARAM_TYPE => [
219 ParamValidator::PARAM_TYPE =>
'string'
222 ParamValidator::PARAM_TYPE =>
'string'
229 'action=query&list=watchlistraw'
230 =>
'apihelp-query+watchlistraw-example-simple',
231 'action=query&generator=watchlistraw&gwrshow=changed&prop=info'
232 =>
'apihelp-query+watchlistraw-example-generator',
237 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Watchlistraw';
242class_alias( ApiQueryWatchlistRaw::class,
'ApiQueryWatchlistRaw' );
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.