X-Git-Url: https://git.cyclocoop.org/%242?a=blobdiff_plain;f=includes%2Fmail%2FEmailNotification.php;h=9bda12cb4d1e3e5d3ec4d8022078ecfdc353c78c;hb=afa2e1e66088ae2c35b03e616549203138e1e03b;hp=044bb5343d8f35c8a133f01f185540560d3c3238;hpb=91d69e12e1d2e00953cae3c153e37f3d36e5903c;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/mail/EmailNotification.php b/includes/mail/EmailNotification.php index 044bb5343d..9bda12cb4d 100644 --- a/includes/mail/EmailNotification.php +++ b/includes/mail/EmailNotification.php @@ -74,11 +74,15 @@ class EmailNotification { /** * @param User $editor The editor that triggered the update. Their notification * timestamp will not be updated(they have already seen it) - * @param Title $title The title to update timestamps for + * @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( User $editor, Title $title, $timestamp ) { + public static function updateWatchlistTimestamp( + User $editor, + LinkTarget $linkTarget, + $timestamp + ) { global $wgEnotifWatchlist, $wgShowUpdatedMarker; if ( !$wgEnotifWatchlist && !$wgShowUpdatedMarker ) { @@ -90,8 +94,8 @@ class EmailNotification { array( 'wl_user' ), array( 'wl_user != ' . intval( $editor->getID() ), - 'wl_namespace' => $title->getNamespace(), - 'wl_title' => $title->getDBkey(), + 'wl_namespace' => $linkTarget->getNamespace(), + 'wl_title' => $linkTarget->getDBkey(), 'wl_notificationtimestamp IS NULL', ), __METHOD__ ); @@ -105,14 +109,14 @@ class EmailNotification { // Update wl_notificationtimestamp for all watching users except the editor $fname = __METHOD__; $dbw->onTransactionIdle( - function () use ( $dbw, $timestamp, $watchers, $title, $fname ) { + function () use ( $dbw, $timestamp, $watchers, $linkTarget, $fname ) { $dbw->update( 'watchlist', array( /* SET */ 'wl_notificationtimestamp' => $dbw->timestamp( $timestamp ) ), array( /* WHERE */ 'wl_user' => $watchers, - 'wl_namespace' => $title->getNamespace(), - 'wl_title' => $title->getDBkey(), + 'wl_namespace' => $linkTarget->getNamespace(), + 'wl_title' => $linkTarget->getDBkey(), ), $fname ); } @@ -138,7 +142,7 @@ class EmailNotification { public function notifyOnPageChange( $editor, $title, $timestamp, $summary, $minorEdit, $oldid = false, $pageStatus = 'changed' ) { - global $wgEnotifUseJobQ, $wgEnotifMinorEdits, $wgUsersNotifiedOnAllChanges, $wgEnotifUserTalk; + global $wgEnotifMinorEdits, $wgUsersNotifiedOnAllChanges, $wgEnotifUserTalk; if ( $title->getNamespace() < 0 ) { return; @@ -166,34 +170,20 @@ class EmailNotification { } } - if ( !$sendEmail ) { - return; - } - - if ( $wgEnotifUseJobQ ) { - $params = array( - 'editor' => $editor->getName(), - 'editorID' => $editor->getID(), - 'timestamp' => $timestamp, - 'summary' => $summary, - 'minorEdit' => $minorEdit, - 'oldid' => $oldid, - 'watchers' => $watchers, - 'pageStatus' => $pageStatus - ); - $job = new EnotifNotifyJob( $title, $params ); - JobQueueGroup::singleton()->lazyPush( $job ); - } else { - $this->actuallyNotifyOnPageChange( - $editor, + if ( $sendEmail ) { + JobQueueGroup::singleton()->lazyPush( new EnotifNotifyJob( $title, - $timestamp, - $summary, - $minorEdit, - $oldid, - $watchers, - $pageStatus - ); + array( + 'editor' => $editor->getName(), + 'editorID' => $editor->getID(), + 'timestamp' => $timestamp, + 'summary' => $summary, + 'minorEdit' => $minorEdit, + 'oldid' => $oldid, + 'watchers' => $watchers, + 'pageStatus' => $pageStatus + ) + ) ); } } @@ -216,6 +206,7 @@ class EmailNotification { public function actuallyNotifyOnPageChange( $editor, $title, $timestamp, $summary, $minorEdit, $oldid, $watchers, $pageStatus = 'changed' ) { # we use $wgPasswordSender as sender's address + global $wgUsersNotifiedOnAllChanges; global $wgEnotifWatchlist, $wgBlockDisablesLogin; global $wgEnotifMinorEdits, $wgEnotifUserTalk; @@ -262,6 +253,7 @@ class EmailNotification { && ( !$minorEdit || $watchingUser->getOption( 'enotifminoredits' ) ) && $watchingUser->isEmailConfirmed() && $watchingUser->getID() != $userTalkId + && !in_array( $watchingUser->getName(), $wgUsersNotifiedOnAllChanges ) && !( $wgBlockDisablesLogin && $watchingUser->isBlocked() ) ) { if ( Hooks::run( 'SendWatchlistEmailNotification', array( $watchingUser, $title, $this ) ) ) { @@ -272,7 +264,6 @@ class EmailNotification { } } - global $wgUsersNotifiedOnAllChanges; foreach ( $wgUsersNotifiedOnAllChanges as $name ) { if ( $editor->getName() == $name ) { // No point notifying the user that actually made the change!