42 private Language $contentLanguage;
58 Language $contentLanguage,
62 parent::__construct( $query, $moduleName,
'wr' );
63 $this->watchedItemQueryService = $watchedItemQueryService;
64 $this->contentLanguage = $contentLanguage;
65 $this->namespaceInfo = $namespaceInfo;
66 $this->genderCache = $genderCache;
74 $this->
run( $resultPageSet );
81 private function run( $resultPageSet =
null ) {
86 $prop = array_fill_keys( (array)
$params[
'prop'],
true );
87 $show = array_fill_keys( (array)
$params[
'show'],
true );
88 if ( isset( $show[WatchedItemQueryService::FILTER_CHANGED] )
89 && isset( $show[WatchedItemQueryService::FILTER_NOT_CHANGED] )
96 $options[
'namespaceIds'] =
$params[
'namespace'];
98 if ( isset( $show[WatchedItemQueryService::FILTER_CHANGED] ) ) {
99 $options[
'filter'] = WatchedItemQueryService::FILTER_CHANGED;
101 if ( isset( $show[WatchedItemQueryService::FILTER_NOT_CHANGED] ) ) {
102 $options[
'filter'] = WatchedItemQueryService::FILTER_NOT_CHANGED;
105 if ( isset(
$params[
'continue'] ) ) {
107 $options[
'startFrom'] = TitleValue::tryNew( $cont[0], $cont[1] );
111 if ( isset(
$params[
'fromtitle'] ) ) {
115 if ( isset(
$params[
'totitle'] ) ) {
119 $options[
'sort'] = WatchedItemStore::SORT_ASC;
120 if (
$params[
'dir'] ===
'descending' ) {
121 $options[
'sort'] = WatchedItemStore::SORT_DESC;
123 $options[
'limit'] =
$params[
'limit'] + 1;
127 $items = $this->watchedItemQueryService->getWatchedItemsForUser( $user, $options );
130 if ( $items !== [] && $resultPageSet ===
null &&
131 $this->contentLanguage->needsGenderDistinction()
134 foreach ( $items as $item ) {
135 $linkTarget = $item->getTarget();
136 if ( $this->namespaceInfo->hasGenderDistinction( $linkTarget->getNamespace() ) ) {
137 $usernames[] = $linkTarget->getText();
140 if ( $usernames !== [] ) {
141 $this->genderCache->doQuery( $usernames, __METHOD__ );
145 foreach ( $items as $item ) {
146 $ns = $item->getTarget()->getNamespace();
147 $dbKey = $item->getTarget()->getDBkey();
148 if ( ++$count >
$params[
'limit'] ) {
154 $t = Title::makeTitle( $ns, $dbKey );
156 if ( $resultPageSet ===
null ) {
159 if ( isset( $prop[
'changed'] ) && $item->getNotificationTimestamp() !==
null ) {
160 $vals[
'changed'] =
wfTimestamp( TS_ISO_8601, $item->getNotificationTimestamp() );
171 if ( $resultPageSet ===
null ) {
174 $resultPageSet->populateFromTitles( $titles );
184 ParamValidator::PARAM_ISMULTI =>
true,
185 ParamValidator::PARAM_TYPE =>
'namespace'
188 ParamValidator::PARAM_DEFAULT => 10,
189 ParamValidator::PARAM_TYPE =>
'limit',
190 IntegerDef::PARAM_MIN => 1,
195 ParamValidator::PARAM_ISMULTI =>
true,
196 ParamValidator::PARAM_TYPE => [
202 ParamValidator::PARAM_ISMULTI =>
true,
203 ParamValidator::PARAM_TYPE => [
204 WatchedItemQueryService::FILTER_CHANGED,
205 WatchedItemQueryService::FILTER_NOT_CHANGED
209 ParamValidator::PARAM_TYPE =>
'user',
210 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name' ],
213 ParamValidator::PARAM_TYPE =>
'string',
214 ParamValidator::PARAM_SENSITIVE =>
true,
217 ParamValidator::PARAM_DEFAULT =>
'ascending',
218 ParamValidator::PARAM_TYPE => [
224 ParamValidator::PARAM_TYPE =>
'string'
227 ParamValidator::PARAM_TYPE =>
'string'
234 'action=query&list=watchlistraw'
235 =>
'apihelp-query+watchlistraw-example-simple',
236 'action=query&generator=watchlistraw&gwrshow=changed&prop=info'
237 =>
'apihelp-query+watchlistraw-example-generator',
242 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Watchlistraw';
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
array $params
The job parameters.
dieWithError( $msg, $code=null, $data=null, $httpCode=0)
Abort execution with an error.
getWatchlistUser( $params)
Gets the user for whom to get the watchlist.
dieContinueUsageIf( $condition)
Die with the 'badcontinue' error.
parseContinueParamOrDie(string $continue, array $types)
Parse the 'continue' parameter in the usual format and validate the types of each part,...
const PARAM_HELP_MSG_PER_VALUE
((string|array|Message)[]) When PARAM_TYPE is an array, or 'string' with PARAM_ISMULTI,...
const LIMIT_BIG1
Fast query, standard limit.
getResult()
Get the result object.
extractRequestParams( $options=[])
Using getAllowedParams(), this function makes an array of the values provided by the user,...
const PARAM_HELP_MSG
(string|array|Message) Specify an alternative i18n documentation message for this parameter.
const LIMIT_BIG2
Fast query, apihighlimits limit.
getModuleName()
Get the name of the module being executed by this instance.
static addTitleInfo(&$arr, $title, $prefix='')
Add information (title and namespace) about a Title object to a result array.
parsePrefixedTitlePart( $titlePart, $defaultNamespace=NS_MAIN)
Convert an input title or title prefix into a TitleValue.
setContinueEnumParameter( $paramName, $paramValue)
Overridden to set the generator param if in generator mode.
This query action allows clients to retrieve a list of pages on the logged-in user's watchlist.
getHelpUrls()
Return links to more detailed help pages about the module.
getExamplesMessages()
Returns usage examples for this module.
__construct(ApiQuery $query, $moduleName, WatchedItemQueryService $watchedItemQueryService, Language $contentLanguage, NamespaceInfo $namespaceInfo, GenderCache $genderCache)
executeGenerator( $resultPageSet)
Execute this module as a generator.
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
This is the main query class.