X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fmail%2FEmailNotification.php;h=1d0bdf6d779cde4003067a94d8b0f90550880783;hb=2ff4b95bd19fe3a272d55ad53690e6ddfbcf067f;hp=30907e636c93315b941c100aaa5844907e54d298;hpb=4b73a8b6fbb6da651af850a7d667e6e8d59e6fce;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/mail/EmailNotification.php b/includes/mail/EmailNotification.php index 30907e636c..1d0bdf6d77 100644 --- a/includes/mail/EmailNotification.php +++ b/includes/mail/EmailNotification.php @@ -23,6 +23,9 @@ * @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 @@ -72,10 +75,13 @@ class EmailNotification { 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( @@ -83,47 +89,16 @@ class EmailNotification { 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; } /** @@ -149,7 +124,15 @@ class EmailNotification { } // 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. @@ -175,7 +158,7 @@ class EmailNotification { $title, [ 'editor' => $editor->getName(), - 'editorID' => $editor->getID(), + 'editorID' => $editor->getId(), 'timestamp' => $timestamp, 'summary' => $summary, 'minorEdit' => $minorEdit, @@ -252,7 +235,7 @@ class EmailNotification { if ( $watchingUser->getOption( 'enotifwatchlistpages' ) && ( !$minorEdit || $watchingUser->getOption( 'enotifminoredits' ) ) && $watchingUser->isEmailConfirmed() - && $watchingUser->getID() != $userTalkId + && $watchingUser->getId() != $userTalkId && !in_array( $watchingUser->getName(), $wgUsersNotifiedOnAllChanges ) && !( $wgBlockDisablesLogin && $watchingUser->isBlocked() ) ) {