From 2cf12c973d967b7b46d711bf07ad502e81bdcb9b Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Sat, 17 May 2008 23:34:28 +0000 Subject: [PATCH] * Make enotif job use user ID rather than name for users. Fallback to name for anons and for old job rows (B/C). This makes it rename safe. * 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 | 19 +++++++++++++------ includes/RecentChange.php | 4 ++-- includes/UserMailer.php | 14 ++++++++------ 3 files changed, 23 insertions(+), 14 deletions(-) diff --git a/includes/EnotifNotifyJob.php b/includes/EnotifNotifyJob.php index 857cd40cb1..10a165f532 100644 --- a/includes/EnotifNotifyJob.php +++ b/includes/EnotifNotifyJob.php @@ -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; } diff --git a/includes/RecentChange.php b/includes/RecentChange.php index 68764951f0..94a7799444 100644 --- a/includes/RecentChange.php +++ b/includes/RecentChange.php @@ -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']) ? diff --git a/includes/UserMailer.php b/includes/UserMailer.php index cee1cc8f1a..8e576bb21b 100644 --- a/includes/UserMailer.php +++ b/includes/UserMailer.php @@ -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__ ); } -- 2.20.1