59 parent::__construct( $query, $moduleName,
'wr' );
60 $this->watchedItemQueryService = $watchedItemQueryService;
61 $this->contentLanguage = $contentLanguage;
62 $this->namespaceInfo = $namespaceInfo;
63 $this->genderCache = $genderCache;
71 $this->run( $resultPageSet );
78 private function run( $resultPageSet =
null ) {
83 $prop = array_fill_keys( (array)$params[
'prop'],
true );
84 $show = array_fill_keys( (array)$params[
'show'],
true );
85 if ( isset( $show[WatchedItemQueryService::FILTER_CHANGED] )
86 && isset( $show[WatchedItemQueryService::FILTER_NOT_CHANGED] )
92 if ( $params[
'namespace'] ) {
93 $options[
'namespaceIds'] = $params[
'namespace'];
95 if ( isset( $show[WatchedItemQueryService::FILTER_CHANGED] ) ) {
98 if ( isset( $show[WatchedItemQueryService::FILTER_NOT_CHANGED] ) ) {
102 if ( isset( $params[
'continue'] ) ) {
104 $options[
'startFrom'] = TitleValue::tryNew( $cont[0], $cont[1] );
108 if ( isset( $params[
'fromtitle'] ) ) {
112 if ( isset( $params[
'totitle'] ) ) {
117 if ( $params[
'dir'] ===
'descending' ) {
120 $options[
'limit'] = $params[
'limit'] + 1;
124 $items = $this->watchedItemQueryService->getWatchedItemsForUser( $user, $options );
127 if ( $items !== [] && $resultPageSet ===
null &&
128 $this->contentLanguage->needsGenderDistinction()
131 foreach ( $items as $item ) {
132 $linkTarget = $item->getTarget();
133 if ( $this->namespaceInfo->hasGenderDistinction( $linkTarget->getNamespace() ) ) {
134 $usernames[] = $linkTarget->getText();
137 if ( $usernames !== [] ) {
138 $this->genderCache->doQuery( $usernames, __METHOD__ );
142 foreach ( $items as $item ) {
143 $ns = $item->getTarget()->getNamespace();
144 $dbKey = $item->getTarget()->getDBkey();
145 if ( ++$count > $params[
'limit'] ) {
151 $t = Title::makeTitle( $ns, $dbKey );
153 if ( $resultPageSet ===
null ) {
156 if ( isset( $prop[
'changed'] ) && $item->getNotificationTimestamp() !==
null ) {
157 $vals[
'changed'] =
wfTimestamp( TS_ISO_8601, $item->getNotificationTimestamp() );
168 if ( $resultPageSet ===
null ) {
171 $resultPageSet->populateFromTitles( $titles );
181 ParamValidator::PARAM_ISMULTI =>
true,
182 ParamValidator::PARAM_TYPE =>
'namespace'
185 ParamValidator::PARAM_DEFAULT => 10,
186 ParamValidator::PARAM_TYPE =>
'limit',
187 IntegerDef::PARAM_MIN => 1,
192 ParamValidator::PARAM_ISMULTI =>
true,
193 ParamValidator::PARAM_TYPE => [
199 ParamValidator::PARAM_ISMULTI =>
true,
200 ParamValidator::PARAM_TYPE => [
201 WatchedItemQueryService::FILTER_CHANGED,
202 WatchedItemQueryService::FILTER_NOT_CHANGED
206 ParamValidator::PARAM_TYPE =>
'user',
207 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name' ],
210 ParamValidator::PARAM_TYPE =>
'string',
211 ParamValidator::PARAM_SENSITIVE =>
true,
214 ParamValidator::PARAM_DEFAULT =>
'ascending',
215 ParamValidator::PARAM_TYPE => [
221 ParamValidator::PARAM_TYPE =>
'string'
224 ParamValidator::PARAM_TYPE =>
'string'
231 'action=query&list=watchlistraw'
232 =>
'apihelp-query+watchlistraw-example-simple',
233 'action=query&generator=watchlistraw&gwrshow=changed&prop=info'
234 =>
'apihelp-query+watchlistraw-example-generator',
239 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.
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.
Look up "gender" user preference.
Base class for language-specific code.