Code style cleanups to notifyOnPageChange()
[lhc/web/wiklou.git] / includes / mail / EmailNotification.php
index 31dd395..8bac6b8 100644 (file)
@@ -76,7 +76,7 @@ class EmailNotification {
         *  timestamp will not be updated(they have already seen it)
         * @param Title $title The title to update timestamps for
         * @param string $timestamp Set the update timestamp to this value
-        * @return int[]
+        * @return int[] Array of user IDs
         */
        public static function updateWatchlistTimestamp( User $editor, Title $title, $timestamp ) {
                global $wgEnotifWatchlist, $wgShowUpdatedMarker;
@@ -138,7 +138,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 +166,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 +202,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 +249,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 +260,6 @@ class EmailNotification {
                        }
                }
 
-               global $wgUsersNotifiedOnAllChanges;
                foreach ( $wgUsersNotifiedOnAllChanges as $name ) {
                        if ( $editor->getName() == $name ) {
                                // No point notifying the user that actually made the change!