$user = $this->getUser();
if ( $user->isAnon() ) {
- $this->dieUsage( 'Anonymous users cannot use watchlist change notifications', 'notloggedin' );
- }
- if ( !$user->isAllowed( 'editmywatchlist' ) ) {
- $this->dieUsage( 'You don\'t have permission to edit your watchlist', 'permissiondenied' );
+ $this->dieWithError( 'watchlistanontext', 'notloggedin' );
}
+ $this->checkUserRightsAny( 'editmywatchlist' );
$params = $this->extractRequestParams();
$this->requireMaxOneParameter( $params, 'timestamp', 'torevid', 'newerthanrevid' );
$pageSet = $this->getPageSet();
if ( $params['entirewatchlist'] && $pageSet->getDataSource() !== null ) {
- $this->dieUsage(
- "Cannot use 'entirewatchlist' at the same time as '{$pageSet->getDataSource()}'",
+ $this->dieWithError(
+ [
+ 'apierror-invalidparammix-cannotusewith',
+ $this->encodeParamName( 'entirewatchlist' ),
+ $pageSet->encodeParamName( $pageSet->getDataSource() )
+ ],
'multisource'
);
}
if ( isset( $params['torevid'] ) ) {
if ( $params['entirewatchlist'] || $pageSet->getGoodTitleCount() > 1 ) {
- $this->dieUsage( 'torevid may only be used with a single page', 'multpages' );
+ $this->dieWithError( [ 'apierror-multpages', $this->encodeParamName( 'torevid' ) ] );
}
$title = reset( $pageSet->getGoodTitles() );
if ( $title ) {
}
} elseif ( isset( $params['newerthanrevid'] ) ) {
if ( $params['entirewatchlist'] || $pageSet->getGoodTitleCount() > 1 ) {
- $this->dieUsage( 'newerthanrevid may only be used with a single page', 'multpages' );
+ $this->dieWithError( [ 'apierror-multpages', $this->encodeParamName( 'newerthanrevid' ) ] );
}
$title = reset( $pageSet->getGoodTitles() );
if ( $title ) {
);
// Query the results of our update
- $timestamps = [];
- $lb = new LinkBatch( $pageSet->getTitles() );
- $res = $dbw->select(
- 'watchlist',
- [ 'wl_namespace', 'wl_title', 'wl_notificationtimestamp' ],
- [ 'wl_user' => $user->getId(), $lb->constructSet( 'wl', $dbw ) ],
- __METHOD__
+ $timestamps = $watchedItemStore->getNotificationTimestampsBatch(
+ $user,
+ $pageSet->getTitles()
);
- foreach ( $res as $row ) {
- $timestamps[$row->wl_namespace][$row->wl_title] = $row->wl_notificationtimestamp;
- }
// Now, put the valid titles into the result
/** @var $title Title */
];
if ( !$title->exists() ) {
$r['missing'] = true;
+ if ( $title->isKnown() ) {
+ $r['known'] = true;
+ }
}
if ( isset( $timestamps[$ns] ) && array_key_exists( $dbkey, $timestamps[$ns] ) ) {
$r['notificationtimestamp'] = '';