36 private $watchedItemQueryService;
39 private $contentLanguage;
42 private $namespaceInfo;
63 parent::__construct( $query, $moduleName,
'wr' );
64 $this->watchedItemQueryService = $watchedItemQueryService;
65 $this->contentLanguage = $contentLanguage;
66 $this->namespaceInfo = $namespaceInfo;
67 $this->genderCache = $genderCache;
75 $this->run( $resultPageSet );
82 private function run( $resultPageSet =
null ) {
87 $prop = array_fill_keys( (array)$params[
'prop'],
true );
88 $show = array_fill_keys( (array)$params[
'show'],
true );
89 if ( isset( $show[WatchedItemQueryService::FILTER_CHANGED] )
90 && isset( $show[WatchedItemQueryService::FILTER_NOT_CHANGED] )
96 if ( $params[
'namespace'] ) {
97 $options[
'namespaceIds'] = $params[
'namespace'];
99 if ( isset( $show[WatchedItemQueryService::FILTER_CHANGED] ) ) {
102 if ( isset( $show[WatchedItemQueryService::FILTER_NOT_CHANGED] ) ) {
106 if ( isset( $params[
'continue'] ) ) {
107 $cont = explode(
'|', $params[
'continue'] );
116 if ( isset( $params[
'fromtitle'] ) ) {
120 if ( isset( $params[
'totitle'] ) ) {
125 if ( $params[
'dir'] ===
'descending' ) {
128 $options[
'limit'] = $params[
'limit'] + 1;
132 $items = $this->watchedItemQueryService->getWatchedItemsForUser( $user, $options );
135 if ( $items !== [] && $resultPageSet ===
null &&
136 $this->contentLanguage->needsGenderDistinction()
139 foreach ( $items as $item ) {
140 $linkTarget = $item->getTarget();
141 if ( $this->namespaceInfo->hasGenderDistinction( $linkTarget->getNamespace() ) ) {
142 $usernames[] = $linkTarget->getText();
145 if ( $usernames !== [] ) {
146 $this->genderCache->doQuery( $usernames, __METHOD__ );
150 foreach ( $items as $item ) {
151 $ns = $item->getTarget()->getNamespace();
152 $dbKey = $item->getTarget()->getDBkey();
153 if ( ++$count > $params[
'limit'] ) {
161 if ( $resultPageSet ===
null ) {
164 if ( isset( $prop[
'changed'] ) && $item->getNotificationTimestamp() !==
null ) {
165 $vals[
'changed'] =
wfTimestamp( TS_ISO_8601, $item->getNotificationTimestamp() );
176 if ( $resultPageSet ===
null ) {
179 $resultPageSet->populateFromTitles( $titles );
189 ParamValidator::PARAM_ISMULTI =>
true,
190 ParamValidator::PARAM_TYPE =>
'namespace'
193 ParamValidator::PARAM_DEFAULT => 10,
194 ParamValidator::PARAM_TYPE =>
'limit',
195 IntegerDef::PARAM_MIN => 1,
200 ParamValidator::PARAM_ISMULTI =>
true,
201 ParamValidator::PARAM_TYPE => [
207 ParamValidator::PARAM_ISMULTI =>
true,
208 ParamValidator::PARAM_TYPE => [
209 WatchedItemQueryService::FILTER_CHANGED,
210 WatchedItemQueryService::FILTER_NOT_CHANGED
214 ParamValidator::PARAM_TYPE =>
'user',
215 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name' ],
218 ParamValidator::PARAM_TYPE =>
'string',
219 ParamValidator::PARAM_SENSITIVE =>
true,
222 ParamValidator::PARAM_DEFAULT =>
'ascending',
223 ParamValidator::PARAM_TYPE => [
229 ParamValidator::PARAM_TYPE =>
'string'
232 ParamValidator::PARAM_TYPE =>
'string'
239 'action=query&list=watchlistraw'
240 =>
'apihelp-query+watchlistraw-example-simple',
241 'action=query&generator=watchlistraw&gwrshow=changed&prop=info'
242 =>
'apihelp-query+watchlistraw-example-generator',
247 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.
const PARAM_HELP_MSG_PER_VALUE
((string|array|Message)[]) When PARAM_TYPE is an array, this is an array mapping those values to $msg...
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.
Caches user genders when needed to use correct namespace aliases.
Base class for language-specific code.
This is a utility class for dealing with namespaces that encodes all the "magic" behaviors of them ba...
static tryNew( $namespace, $title, $fragment='', $interwiki='')
Constructs a TitleValue, or returns null if the parameters are not valid.
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.