21use Wikimedia\Timestamp\TimestampFormat as TS;
35 private readonly
Language $contentLanguage,
39 parent::__construct( $query, $moduleName,
'wr' );
48 $this->run( $resultPageSet );
55 private function run( $resultPageSet =
null ) {
60 $prop = array_fill_keys( (array)$params[
'prop'],
true );
61 $show = array_fill_keys( (array)$params[
'show'],
true );
62 if ( isset( $show[WatchedItemQueryService::FILTER_CHANGED] )
63 && isset( $show[WatchedItemQueryService::FILTER_NOT_CHANGED] )
69 if ( $params[
'namespace'] ) {
70 $options[
'namespaceIds'] = $params[
'namespace'];
72 if ( isset( $show[WatchedItemQueryService::FILTER_CHANGED] ) ) {
73 $options[
'filter'] = WatchedItemQueryService::FILTER_CHANGED;
75 if ( isset( $show[WatchedItemQueryService::FILTER_NOT_CHANGED] ) ) {
76 $options[
'filter'] = WatchedItemQueryService::FILTER_NOT_CHANGED;
79 if ( isset( $params[
'continue'] ) ) {
81 $options[
'startFrom'] = TitleValue::tryNew( $cont[0], $cont[1] );
85 if ( isset( $params[
'fromtitle'] ) ) {
89 if ( isset( $params[
'totitle'] ) ) {
93 $options[
'sort'] = WatchedItemStore::SORT_ASC;
94 if ( $params[
'dir'] ===
'descending' ) {
95 $options[
'sort'] = WatchedItemStore::SORT_DESC;
97 $options[
'limit'] =
$params[
'limit'] + 1;
101 $items = $this->watchedItemQueryService->getWatchedItemsForUser( $user, $options );
104 if ( $items !== [] && $resultPageSet ===
null &&
105 $this->contentLanguage->needsGenderDistinction()
108 foreach ( $items as $item ) {
109 $target = $item->getTarget();
110 if ( $this->namespaceInfo->hasGenderDistinction( $target->getNamespace() ) ) {
112 $usernames[] = $target->getDBkey();
115 if ( $usernames !== [] ) {
116 $this->genderCache->doQuery( $usernames, __METHOD__ );
120 foreach ( $items as $item ) {
121 $ns = $item->getTarget()->getNamespace();
122 $dbKey = $item->getTarget()->getDBkey();
123 if ( ++$count > $params[
'limit'] ) {
131 if ( $resultPageSet ===
null ) {
134 if ( isset( $prop[
'changed'] ) && $item->getNotificationTimestamp() !==
null ) {
135 $vals[
'changed'] =
wfTimestamp( TS::ISO_8601, $item->getNotificationTimestamp() );
146 if ( $resultPageSet ===
null ) {
149 $resultPageSet->populateFromTitles( $titles );
160 ParamValidator::PARAM_ISMULTI =>
true,
161 ParamValidator::PARAM_TYPE =>
'namespace'
164 ParamValidator::PARAM_DEFAULT => 10,
165 ParamValidator::PARAM_TYPE =>
'limit',
166 IntegerDef::PARAM_MIN => 1,
171 ParamValidator::PARAM_ISMULTI =>
true,
172 ParamValidator::PARAM_TYPE => [
178 ParamValidator::PARAM_ISMULTI =>
true,
179 ParamValidator::PARAM_TYPE => [
180 WatchedItemQueryService::FILTER_CHANGED,
181 WatchedItemQueryService::FILTER_NOT_CHANGED
185 ParamValidator::PARAM_TYPE =>
'user',
186 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name' ],
189 ParamValidator::PARAM_TYPE =>
'string',
190 ParamValidator::PARAM_SENSITIVE =>
true,
193 ParamValidator::PARAM_DEFAULT =>
'ascending',
194 ParamValidator::PARAM_TYPE => [
200 ParamValidator::PARAM_TYPE =>
'string'
203 ParamValidator::PARAM_TYPE =>
'string'
211 'action=query&list=watchlistraw'
212 =>
'apihelp-query+watchlistraw-example-simple',
213 'action=query&generator=watchlistraw&gwrshow=changed&prop=info'
214 =>
'apihelp-query+watchlistraw-example-generator',
220 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Watchlistraw';
225class_alias( ApiQueryWatchlistRaw::class,
'ApiQueryWatchlistRaw' );
wfTimestamp( $outputtype=TS::UNIX, $ts=0)
Get a timestamp string in one of various formats.