*
* @file
*/
+use MediaWiki\MediaWikiServices;
/**
* API interface for setting the wl_notificationtimestamp field
}
}
+ $watchedItemStore = MediaWikiServices::getInstance()->getWatchedItemStore();
$apiResult = $this->getResult();
$result = [];
if ( $params['entirewatchlist'] ) {
// Entire watchlist mode: Just update the thing and return a success indicator
- $dbw->update( 'watchlist', [ 'wl_notificationtimestamp' => $timestamp ],
- [ 'wl_user' => $user->getId() ],
- __METHOD__
+ $watchedItemStore->setNotificationTimestampsForUser(
+ $user,
+ $timestamp
);
$result['notificationtimestamp'] = is_null( $timestamp )
if ( $pageSet->getTitles() ) {
// Now process the valid titles
- $lb = new LinkBatch( $pageSet->getTitles() );
- $dbw->update( 'watchlist', [ 'wl_notificationtimestamp' => $timestamp ],
- [ 'wl_user' => $user->getId(), $lb->constructSet( 'wl', $dbw ) ],
- __METHOD__
+ $watchedItemStore->setNotificationTimestampsForUser(
+ $user,
+ $timestamp,
+ $pageSet->getTitles()
);
// Query the results of our update
- $timestamps = [];
- $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'] = '';