35 parent::__construct( $query, $moduleName,
'wr' );
43 $this->
run( $resultPageSet );
50 private function run( $resultPageSet =
null ) {
55 $prop = array_flip( (array)$params[
'prop'] );
56 $show = array_flip( (array)$params[
'show'] );
57 if ( isset( $show[WatchedItemQueryService::FILTER_CHANGED] )
58 && isset( $show[WatchedItemQueryService::FILTER_NOT_CHANGED] )
64 if ( $params[
'namespace'] ) {
65 $options[
'namespaceIds'] = $params[
'namespace'];
67 if ( isset( $show[WatchedItemQueryService::FILTER_CHANGED] ) ) {
68 $options[
'filter'] = WatchedItemQueryService::FILTER_CHANGED;
70 if ( isset( $show[WatchedItemQueryService::FILTER_NOT_CHANGED] ) ) {
71 $options[
'filter'] = WatchedItemQueryService::FILTER_NOT_CHANGED;
74 if ( isset( $params[
'continue'] ) ) {
75 $cont = explode(
'|', $params[
'continue'] );
84 if ( isset( $params[
'fromtitle'] ) ) {
88 if ( isset( $params[
'totitle'] ) ) {
93 if ( $params[
'dir'] ===
'descending' ) {
96 $options[
'limit'] = $params[
'limit'] + 1;
100 $services = MediaWikiServices::getInstance();
101 $items = $services->getWatchedItemQueryService()
102 ->getWatchedItemsForUser( $user, $options );
105 if ( $items !== [] && $resultPageSet ===
null &&
106 $services->getContentLanguage()->needsGenderDistinction()
108 $nsInfo = $services->getNamespaceInfo();
110 foreach ( $items as $item ) {
111 $linkTarget = $item->getLinkTarget();
112 if ( $nsInfo->hasGenderDistinction( $linkTarget->getNamespace() ) ) {
113 $usernames[] = $linkTarget->getText();
116 if ( $usernames !== [] ) {
117 $services->getGenderCache()->doQuery( $usernames, __METHOD__ );
121 foreach ( $items as $item ) {
122 $ns = $item->getLinkTarget()->getNamespace();
123 $dbKey = $item->getLinkTarget()->getDBkey();
124 if ( ++$count > $params[
'limit'] ) {
130 $t = Title::makeTitle( $ns, $dbKey );
132 if ( $resultPageSet ===
null ) {
135 if ( isset( $prop[
'changed'] ) && $item->getNotificationTimestamp() !==
null ) {
136 $vals[
'changed'] =
wfTimestamp( TS_ISO_8601, $item->getNotificationTimestamp() );
147 if ( $resultPageSet ===
null ) {
150 $resultPageSet->populateFromTitles( $titles );
180 WatchedItemQueryService::FILTER_CHANGED,
181 WatchedItemQueryService::FILTER_NOT_CHANGED
186 UserDef::PARAM_ALLOWED_USER_TYPES => [
'name' ],
210 'action=query&list=watchlistraw'
211 =>
'apihelp-query+watchlistraw-example-simple',
212 'action=query&generator=watchlistraw&gwrshow=changed&prop=info'
213 =>
'apihelp-query+watchlistraw-example-generator',
218 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.
run( $resultPageSet=null)
getHelpUrls()
Return links to more detailed help pages about the module.
getExamplesMessages()
Returns usage examples for this module.
executeGenerator( $resultPageSet)
Execute this module as a generator.
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
__construct(ApiQuery $query, $moduleName)
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
This is the main query class.
static tryNew( $namespace, $title, $fragment='', $interwiki='')
Constructs a TitleValue, or returns null if the parameters are not valid.