* Make enotif job use user ID rather than name for users. Fallback to name for anons...
authorAaron Schulz <aaron@users.mediawiki.org>
Sat, 17 May 2008 23:34:28 +0000 (23:34 +0000)
committerAaron Schulz <aaron@users.mediawiki.org>
Sat, 17 May 2008 23:34:28 +0000 (23:34 +0000)
* User->getID() already returns an integer
* Use != rather than <>, as it looks clearer
* Do not add "updated since" to users for their own edits
* Actually check $wgShowUpdatedMarker properly. It is it's own setting.

includes/EnotifNotifyJob.php
includes/RecentChange.php
includes/UserMailer.php

index 857cd40..10a165f 100644 (file)
@@ -11,13 +11,20 @@ class EnotifNotifyJob extends Job {
 
        function run() {
                $enotif = new EmailNotification();
+               // Get the user from ID (rename safe). Anons are 0, so defer to name.
+               if( isset($this->params['editorID']) && $this->params['editorID'] ) {
+                       $editor = User::newFromId( $this->params['editorID'] );
+               // B/C, only the name might be given.
+               } else {
+                       $editor = User::newFromName( $this->params['editor'], false );
+               }
                $enotif->actuallyNotifyOnPageChange(
-                       User::newFromName( $this->params['editor'], false ),
-                               $this->title,
-                               $this->params['timestamp'],
-                               $this->params['summary'],
-                               $this->params['minorEdit'],
-                               $this->params['oldid']
+                       $editor,
+                       $this->title,
+                       $this->params['timestamp'],
+                       $this->params['summary'],
+                       $this->params['minorEdit'],
+                       $this->params['oldid']
                );
                return true;
        }
index 6876495..94a7799 100644 (file)
@@ -222,8 +222,8 @@ class RecentChange
                }
 
                # E-mail notifications
-               global $wgUseEnotif, $wgUser;
-               if( $wgUseEnotif ) {
+               global $wgUseEnotif, $wgShowUpdatedMarker, $wgUser;
+               if( $wgUseEnotif || $wgShowUpdatedMarker ) {
                        // Users
                        if( $this->mAttribs['rc_user'] ) {
                                $editor = ($wgUser->getID() == $this->mAttribs['rc_user']) ? 
index cee1cc8..8e576bb 100644 (file)
@@ -284,6 +284,7 @@ class EmailNotification {
                if ($wgEnotifUseJobQ) {
                        $params = array(
                                "editor" => $editor->getName(),
+                               "editorID" => $editor->getID(),
                                "timestamp" => $timestamp,
                                "summary" => $summary,
                                "minorEdit" => $minorEdit,
@@ -352,13 +353,12 @@ class EmailNotification {
                                }
                        }
 
-
                        if ( $wgEnotifWatchlist ) {
                                // Send updates to watchers other than the current editor
-                               $userCondition = 'wl_user <> ' . intval( $editor->getId() );
+                               $userCondition = 'wl_user != ' . $editor->getID();
                                if ( $userTalkId !== false ) {
                                        // Already sent an email to this person
-                                       $userCondition .= ' AND wl_user <> ' . intval( $userTalkId );
+                                       $userCondition .= ' AND wl_user != ' . intval( $userTalkId );
                                }
                                $dbr = wfGetDB( DB_SLAVE );
 
@@ -395,8 +395,9 @@ class EmailNotification {
                $this->sendMails();
 
                if ( $wgShowUpdatedMarker || $wgEnotifWatchlist ) {
-                       # mark the changed watch-listed page with a timestamp, so that the page is
-                       # listed with an "updated since your last visit" icon in the watch list, ...
+                       # Mark the changed watch-listed page with a timestamp, so that the page is
+                       # listed with an "updated since your last visit" icon in the watch list. Do
+                       # not do this to users for their own edits.
                        $dbw = wfGetDB( DB_MASTER );
                        $dbw->update( 'watchlist',
                                array( /* SET */
@@ -404,7 +405,8 @@ class EmailNotification {
                                ), array( /* WHERE */
                                        'wl_title' => $title->getDBkey(),
                                        'wl_namespace' => $title->getNamespace(),
-                                       'wl_notificationtimestamp IS NULL'
+                                       'wl_notificationtimestamp IS NULL',
+                                       'wl_user != ' . $editor->getID()
                                ), __METHOD__
                        );
                }