* @author Tim Starling
* @author Luke Welling lwelling@wikimedia.org
*/
+use MediaWiki\Linker\LinkTarget;
+
+use MediaWiki\MediaWikiServices;
/**
* This module processes the email notifications when the current page is
protected $editor;
/**
+ * @deprecated since 1.27 use WatchedItemStore::updateNotificationTimestamp directly
+ *
* @param User $editor The editor that triggered the update. Their notification
* timestamp will not be updated(they have already seen it)
* @param LinkTarget $linkTarget The link target of the title to update timestamps for
* @param string $timestamp Set the update timestamp to this value
+ *
* @return int[] Array of user IDs
*/
public static function updateWatchlistTimestamp(
LinkTarget $linkTarget,
$timestamp
) {
- global $wgEnotifWatchlist, $wgShowUpdatedMarker;
-
- if ( !$wgEnotifWatchlist && !$wgShowUpdatedMarker ) {
+ // wfDeprecated( __METHOD__, '1.27' );
+ $config = RequestContext::getMain()->getConfig();
+ if ( !$config->get( 'EnotifWatchlist' ) && !$config->get( 'ShowUpdatedMarker' ) ) {
return [];
}
-
- $dbw = wfGetDB( DB_MASTER );
- $res = $dbw->select( [ 'watchlist' ],
- [ 'wl_user' ],
- [
- 'wl_user != ' . intval( $editor->getID() ),
- 'wl_namespace' => $linkTarget->getNamespace(),
- 'wl_title' => $linkTarget->getDBkey(),
- 'wl_notificationtimestamp IS NULL',
- ], __METHOD__
+ return MediaWikiServices::getInstance()->getWatchedItemStore()->updateNotificationTimestamp(
+ $editor,
+ $linkTarget,
+ $timestamp
);
-
- $watchers = [];
- foreach ( $res as $row ) {
- $watchers[] = intval( $row->wl_user );
- }
-
- if ( $watchers ) {
- // Update wl_notificationtimestamp for all watching users except the editor
- $fname = __METHOD__;
- $dbw->onTransactionIdle(
- function () use ( $dbw, $timestamp, $watchers, $linkTarget, $fname ) {
- $dbw->update( 'watchlist',
- [ /* SET */
- 'wl_notificationtimestamp' => $dbw->timestamp( $timestamp )
- ], [ /* WHERE */
- 'wl_user' => $watchers,
- 'wl_namespace' => $linkTarget->getNamespace(),
- 'wl_title' => $linkTarget->getDBkey(),
- ], $fname
- );
- }
- );
- }
-
- return $watchers;
}
/**
}
// update wl_notificationtimestamp for watchers
- $watchers = self::updateWatchlistTimestamp( $editor, $title, $timestamp );
+ $config = RequestContext::getMain()->getConfig();
+ $watchers = [];
+ if ( $config->get( 'EnotifWatchlist' ) || $config->get( 'ShowUpdatedMarker' ) ) {
+ $watchers = MediaWikiServices::getInstance()->getWatchedItemStore()->updateNotificationTimestamp(
+ $editor,
+ $title,
+ $timestamp
+ );
+ }
$sendEmail = true;
// $watchers deals with $wgEnotifWatchlist.
$title,
[
'editor' => $editor->getName(),
- 'editorID' => $editor->getID(),
+ 'editorID' => $editor->getId(),
'timestamp' => $timestamp,
'summary' => $summary,
'minorEdit' => $minorEdit,
if ( $watchingUser->getOption( 'enotifwatchlistpages' )
&& ( !$minorEdit || $watchingUser->getOption( 'enotifminoredits' ) )
&& $watchingUser->isEmailConfirmed()
- && $watchingUser->getID() != $userTalkId
+ && $watchingUser->getId() != $userTalkId
&& !in_array( $watchingUser->getName(), $wgUsersNotifiedOnAllChanges )
&& !( $wgBlockDisablesLogin && $watchingUser->isBlocked() )
) {