38 if ( $user->isAnon() ) {
39 $this->
dieWithError(
'watchlistanontext',
'notloggedin' );
50 if (
$params[
'entirewatchlist'] && $pageSet->getDataSource() !==
null ) {
53 'apierror-invalidparammix-cannotusewith',
55 $pageSet->encodeParamName( $pageSet->getDataSource() )
64 if ( isset(
$params[
'timestamp'] ) ) {
65 $timestamp = $dbw->timestamp(
$params[
'timestamp'] );
68 if ( !
$params[
'entirewatchlist'] ) {
72 if ( isset(
$params[
'torevid'] ) ) {
73 if (
$params[
'entirewatchlist'] || $pageSet->getGoodTitleCount() > 1 ) {
76 $title = reset( $pageSet->getGoodTitles() );
78 $timestamp = Revision::getTimestampFromId(
79 $title,
$params[
'torevid'], Revision::READ_LATEST );
81 $timestamp = $dbw->timestamp( $timestamp );
86 } elseif ( isset(
$params[
'newerthanrevid'] ) ) {
87 if (
$params[
'entirewatchlist'] || $pageSet->getGoodTitleCount() > 1 ) {
90 $title = reset( $pageSet->getGoodTitles() );
92 $revid = $title->getNextRevisionID(
93 $params[
'newerthanrevid'], Title::GAID_FOR_UPDATE );
95 $timestamp = $dbw->timestamp( Revision::getTimestampFromId( $title, $revid ) );
102 $watchedItemStore = MediaWikiServices::getInstance()->getWatchedItemStore();
105 if (
$params[
'entirewatchlist'] ) {
107 $watchedItemStore->setNotificationTimestampsForUser(
112 $result[
'notificationtimestamp'] = is_null( $timestamp )
117 foreach ( $pageSet->getInvalidTitlesAndReasons() as $r ) {
118 $r[
'invalid'] =
true;
121 foreach ( $pageSet->getMissingPageIDs() as $p ) {
123 $page[
'pageid'] = $p;
124 $page[
'missing'] =
true;
125 $page[
'notwatched'] =
true;
128 foreach ( $pageSet->getMissingRevisionIDs() as $r ) {
131 $rev[
'missing'] =
true;
132 $rev[
'notwatched'] =
true;
136 if ( $pageSet->getTitles() ) {
138 $watchedItemStore->setNotificationTimestampsForUser(
141 $pageSet->getTitles()
145 $timestamps = $watchedItemStore->getNotificationTimestampsBatch(
147 $pageSet->getTitles()
152 foreach ( $pageSet->getTitles() as $title ) {
153 $ns = $title->getNamespace();
154 $dbkey = $title->getDBkey();
156 'ns' => intval( $ns ),
157 'title' => $title->getPrefixedText(),
159 if ( !$title->exists() ) {
160 $r[
'missing'] =
true;
161 if ( $title->isKnown() ) {
165 if ( isset( $timestamps[$ns] ) && array_key_exists( $dbkey, $timestamps[$ns] ) ) {
166 $r[
'notificationtimestamp'] =
'';
167 if ( $timestamps[$ns][$dbkey] !==
null ) {
168 $r[
'notificationtimestamp'] =
wfTimestamp( TS_ISO_8601, $timestamps[$ns][$dbkey] );
171 $r[
'notwatched'] =
true;
179 $apiResult->addValue(
null, $this->
getModuleName(), $result );
182 $continuationManager->setContinuationIntoResult( $apiResult );
190 if ( $this->mPageSet ===
null ) {
211 'entirewatchlist' => [
220 'newerthanrevid' => [
228 $result += $this->
getPageSet()->getFinalParams( $flags );
236 'action=setnotificationtimestamp&entirewatchlist=&token=123ABC'
237 =>
'apihelp-setnotificationtimestamp-example-all',
238 'action=setnotificationtimestamp&titles=Main_page&token=123ABC'
239 =>
'apihelp-setnotificationtimestamp-example-page',
240 'action=setnotificationtimestamp&titles=Main_page&' .
241 'timestamp=2012-01-01T00:00:00Z&token=123ABC'
242 =>
'apihelp-setnotificationtimestamp-example-pagetimestamp',
243 'action=setnotificationtimestamp&generator=allpages&gapnamespace=2&token=123ABC'
244 =>
'apihelp-setnotificationtimestamp-example-allpages',
249 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:SetNotificationTimestamp';
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
This abstract class implements many basic API functions, and is the base of all API classes.
checkUserRightsAny( $rights, $user=null)
Helper function for permission-denied errors.
encodeParamName( $paramName)
This method mangles parameter name based on the prefix supplied to the constructor.
dieWithError( $msg, $code=null, $data=null, $httpCode=null)
Abort execution with an error.
const PARAM_TYPE
(string|string[]) Either an array of allowed value strings, or a string type as described below.
extractRequestParams( $parseLimit=true)
Using getAllowedParams(), this function makes an array of the values provided by the user,...
setContinuationManager(ApiContinuationManager $manager=null)
Set the continuation manager.
getResult()
Get the result object.
requireMaxOneParameter( $params, $required)
Die if more than one of a certain set of parameters is set and not false.
const PARAM_HELP_MSG
(string|array|Message) Specify an alternative i18n documentation message for this parameter.
getModuleName()
Get the name of the module being executed by this instance.
This manages continuation state.
This class contains a list of pages that the client has requested.
static setIndexedTagName(array &$arr, $tag)
Set the tag name for numeric-keyed values in XML format.
API interface for setting the wl_notificationtimestamp field.
getExamplesMessages()
Returns usage examples for this module.
getPageSet()
Get a cached instance of an ApiPageSet object.
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
getAllowedParams( $flags=0)
getHelpUrls()
Return links to more detailed help pages about the module.
mustBePosted()
Indicates whether this module must be called with a POST request.
needsToken()
Returns the token type this module requires in order to execute.
isWriteMode()
Indicates whether this module requires write mode.
namespace being checked & $result
presenting them properly to the user as errors is done by the caller return true use this to change the list i e etc $rev