60 parent::__construct( $main, $action );
70 if ( !$user->isRegistered() ) {
71 $this->
dieWithError(
'watchlistanontext',
'notloggedin' );
82 if ( $params[
'entirewatchlist'] && $pageSet->getDataSource() !==
null ) {
85 'apierror-invalidparammix-cannotusewith',
87 $pageSet->encodeParamName( $pageSet->getDataSource() )
93 $dbw = $this->loadBalancer->getConnectionRef(
DB_PRIMARY,
'api' );
96 if ( isset( $params[
'timestamp'] ) ) {
97 $timestamp = $dbw->timestamp( $params[
'timestamp'] );
100 if ( !$params[
'entirewatchlist'] ) {
104 if ( isset( $params[
'torevid'] ) ) {
105 if ( $params[
'entirewatchlist'] || $pageSet->getGoodTitleCount() > 1 ) {
108 $titles = $pageSet->getGoodTitles();
109 $title = reset( $titles );
112 $timestamp = $this->revisionStore->getTimestampFromId(
114 IDBAccessObject::READ_LATEST
117 $timestamp = $dbw->timestamp( $timestamp );
122 } elseif ( isset( $params[
'newerthanrevid'] ) ) {
123 if ( $params[
'entirewatchlist'] || $pageSet->getGoodTitleCount() > 1 ) {
126 $titles = $pageSet->getGoodTitles();
127 $title = reset( $titles );
130 $currRev = $this->revisionStore->getRevisionById(
131 $params[
'newerthanrevid'],
135 $nextRev = $this->revisionStore->getNextRevision(
140 $timestamp = $dbw->timestamp( $nextRev->getTimestamp() );
148 if ( $params[
'entirewatchlist'] ) {
150 $this->watchedItemStore->resetAllNotificationTimestampsForUser( $user, $timestamp );
152 $result[
'notificationtimestamp'] = $timestamp ===
null
157 foreach ( $pageSet->getInvalidTitlesAndReasons() as $r ) {
158 $r[
'invalid'] =
true;
161 foreach ( $pageSet->getMissingPageIDs() as $p ) {
163 $page[
'pageid'] = $p;
164 $page[
'missing'] =
true;
165 $page[
'notwatched'] =
true;
168 foreach ( $pageSet->getMissingRevisionIDs() as $r ) {
171 $rev[
'missing'] =
true;
172 $rev[
'notwatched'] =
true;
176 if ( $pageSet->getPages() ) {
178 $this->watchedItemStore->setNotificationTimestampsForUser(
185 $timestamps = $this->watchedItemStore->getNotificationTimestampsBatch(
192 foreach ( $pageSet->getTitles() as
$title ) {
193 $ns =
$title->getNamespace();
194 $dbkey =
$title->getDBkey();
197 'title' =>
$title->getPrefixedText(),
199 if ( !
$title->exists() ) {
200 $r[
'missing'] =
true;
201 if (
$title->isKnown() ) {
205 if ( isset( $timestamps[$ns] ) && array_key_exists( $dbkey, $timestamps[$ns] ) ) {
206 $r[
'notificationtimestamp'] =
'';
207 if ( $timestamps[$ns][$dbkey] !==
null ) {
208 $r[
'notificationtimestamp'] =
wfTimestamp( TS_ISO_8601, $timestamps[$ns][$dbkey] );
211 $r[
'notwatched'] =
true;
217 ApiResult::setIndexedTagName( $result,
'page' );
219 $apiResult->addValue(
null, $this->
getModuleName(), $result );
222 $continuationManager->setContinuationIntoResult( $apiResult );
230 if ( $this->mPageSet ===
null ) {
251 'entirewatchlist' => [
260 'newerthanrevid' => [
268 $result += $this->
getPageSet()->getFinalParams( $flags );
276 'action=setnotificationtimestamp&entirewatchlist=&token=123ABC'
277 =>
'apihelp-setnotificationtimestamp-example-all',
278 'action=setnotificationtimestamp&titles=Main_page&token=123ABC'
279 =>
'apihelp-setnotificationtimestamp-example-page',
280 'action=setnotificationtimestamp&titles=Main_page&' .
281 'timestamp=2012-01-01T00:00:00Z&token=123ABC'
282 =>
'apihelp-setnotificationtimestamp-example-pagetimestamp',
283 'action=setnotificationtimestamp&generator=allpages&gapnamespace=2&token=123ABC'
284 =>
'apihelp-setnotificationtimestamp-example-allpages',
289 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:SetNotificationTimestamp';
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.
dieWithError( $msg, $code=null, $data=null, $httpCode=0)
Abort execution with an error.
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.
requireMaxOneParameter( $params,... $required)
Die if more than one of a certain set of parameters is set and not false.
setContinuationManager(ApiContinuationManager $manager=null)
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.
getModuleName()
Get the name of the module being executed by this instance.
This manages continuation state.
This is the main API class, used for both external and internal processing.
This class contains a list of pages that the client has requested.
API interface for setting the wl_notificationtimestamp field.
WatchedItemStoreInterface $watchedItemStore
getExamplesMessages()
Returns usage examples for this module.
ILoadBalancer $loadBalancer
RevisionStore $revisionStore
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.
__construct(ApiMain $main, $action, ILoadBalancer $loadBalancer, RevisionStore $revisionStore, WatchedItemStoreInterface $watchedItemStore)
needsToken()
Returns the token type this module requires in order to execute.
isWriteMode()
Indicates whether this module requires write mode.
Represents a title within MediaWiki.