http://www.mediawiki.org/wiki/Special:Code/MediaWiki/99646
Revision: 99646
Author: reedy
Date: 2011-10-12 19:11:45 +0000 (Wed, 12 Oct 2011)
Log Message:
-----------
MFT r97810
Modified Paths:
--------------
branches/wmf/1.18wmf1/includes/UserMailer.php
branches/wmf/1.18wmf1/includes/job/EnotifNotifyJob.php
Property Changed:
----------------
branches/wmf/1.18wmf1/
branches/wmf/1.18wmf1/includes/
Property changes on: branches/wmf/1.18wmf1
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/REL1_15/phase3:51646
/branches/REL1_17/phase3:81445,81448
/branches/new-installer/phase3:43664-66004
/branches/sqlite:58211-58321
/trunk/phase3:92580,92634,92713,92762,92765,92791,92854,92884,92886-92887,92894,92898,92907,92932,92958,93141,93149,93151,93233-93234,93258,93266,93303,93516-93518,93520,93818-93822,93847,93858,93891,93935-93936,94058,94062,94068,94107,94155,94235,94277,94346,94372,94422,94425,94444,94448,94456,94498,94517,94601,94630,94728,94738,94825,94862,94995-94997,95023,95042,95072-95073,95155,95327,95332,95410,95422,95426,95442,95468,95601,95812,98578,98598,98656
+ /branches/REL1_15/phase3:51646
/branches/REL1_17/phase3:81445,81448
/branches/new-installer/phase3:43664-66004
/branches/sqlite:58211-58321
/trunk/phase3:92580,92634,92713,92762,92765,92791,92854,92884,92886-92887,92894,92898,92907,92932,92958,93141,93149,93151,93233-93234,93258,93266,93303,93516-93518,93520,93818-93822,93847,93858,93891,93935-93936,94058,94062,94068,94107,94155,94235,94277,94346,94372,94422,94425,94444,94448,94456,94498,94517,94601,94630,94728,94738,94825,94862,94995-94997,95023,95042,95072-95073,95155,95327,95332,95410,95422,95426,95442,95468,95601,95812,97810,98578,98598,98656
Property changes on: branches/wmf/1.18wmf1/includes
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/REL1_15/phase3/includes:51646
/branches/new-installer/phase3/includes:43664-66004
/branches/sqlite/includes:58211-58321
/branches/wmf-deployment/includes:53381
/trunk/phase3/includes:92580,92634,92713,92762,92765,92791,92854,92884,92886-92887,92894,92898,92907,92932,92958,93141,93149,93151,93233-93234,93258,93266,93303,93516-93518,93818-93822,93847,93858,93891,93935-93936,94058,94062,94068,94107,94155,94235,94277,94346,94372,94422,94425,94444,94448,94456,94498,94517,94601,94630,94728,94738,94825,94862,94995-94997,95023,95042,95072-95073,95155,95327,95332,95410,95422,95426,95442,95468,95601,95812,98578,98598,98656
+ /branches/REL1_15/phase3/includes:51646
/branches/new-installer/phase3/includes:43664-66004
/branches/sqlite/includes:58211-58321
/branches/wmf-deployment/includes:53381
/trunk/phase3/includes:92580,92634,92713,92762,92765,92791,92854,92884,92886-92887,92894,92898,92907,92932,92958,93141,93149,93151,93233-93234,93258,93266,93303,93516-93518,93818-93822,93847,93858,93891,93935-93936,94058,94062,94068,94107,94155,94235,94277,94346,94372,94422,94425,94444,94448,94456,94498,94517,94601,94630,94728,94738,94825,94862,94995-94997,95023,95042,95072-95073,95155,95327,95332,95410,95422,95426,95442,95468,95601,95812,97810,98578,98598,98656
Modified: branches/wmf/1.18wmf1/includes/UserMailer.php
===================================================================
--- branches/wmf/1.18wmf1/includes/UserMailer.php 2011-10-12 19:06:38 UTC
(rev 99645)
+++ branches/wmf/1.18wmf1/includes/UserMailer.php 2011-10-12 19:11:45 UTC
(rev 99646)
@@ -345,7 +345,8 @@
* @param $oldid (default: false)
*/
public function notifyOnPageChange( $editor, $title, $timestamp,
$summary, $minorEdit, $oldid = false ) {
- global $wgEnotifUseJobQ, $wgEnotifWatchlist,
$wgShowUpdatedMarker;
+ global $wgEnotifUseJobQ, $wgEnotifWatchlist,
$wgShowUpdatedMarker, $wgEnotifMinorEdits,
+ $wgUsersNotifiedOnAllChanges, $wgEnotifUserTalk;
if ( $title->getNamespace() < 0 ) {
return;
@@ -384,6 +385,24 @@
}
}
+ $sendEmail = true;
+ // If nobody is watching the page, and there are no users
notified on all changes
+ // don't bother creating a job/trying to send emails
+ // $watchers deals with $wgEnotifWatchlist
+ if ( !count( $watchers ) && !count(
$wgUsersNotifiedOnAllChanges ) ) {
+ $sendEmail = false;
+ // Only send notification for non minor edits, unless
$wgEnotifMinorEdits
+ if ( !$minorEdit || ( $wgEnotifMinorEdits &&
!$editor->isAllowed( 'nominornewtalk' ) ) ) {
+ $isUserTalkPage = ( $title->getNamespace() ==
NS_USER_TALK );
+ if ( $wgEnotifUserTalk && $isUserTalkPage &&
$this->canSendUserTalkEmail( $editor, $title, $minorEdit ) ) {
+ $sendEmail = true;
+ }
+ }
+ }
+
+ if ( !$sendEmail ) {
+ return;
+ }
if ( $wgEnotifUseJobQ ) {
$params = array(
"editor" => $editor->getName(),
@@ -398,7 +417,6 @@
} else {
$this->actuallyNotifyOnPageChange( $editor, $title,
$timestamp, $summary, $minorEdit, $oldid, $watchers );
}
-
}
/**
@@ -439,25 +457,11 @@
$userTalkId = false;
if ( !$minorEdit || ( $wgEnotifMinorEdits &&
!$editor->isAllowed( 'nominornewtalk' ) ) ) {
- if ( $wgEnotifUserTalk && $isUserTalkPage ) {
+
+ if ( $wgEnotifUserTalk && $isUserTalkPage &&
$this->canSendUserTalkEmail( $editor, $title, $minorEdit ) ) {
$targetUser = User::newFromName(
$title->getText() );
- if ( !$targetUser || $targetUser->isAnon() ) {
- wfDebug( __METHOD__ . ": user talk page
edited, but user does not exist\n" );
- } elseif ( $targetUser->getId() ==
$editor->getId() ) {
- wfDebug( __METHOD__ . ": user edited
their own talk page, no notification sent\n" );
- } elseif ( $targetUser->getOption(
'enotifusertalkpages' ) &&
- ( !$minorEdit ||
$targetUser->getOption( 'enotifminoredits' ) ) )
- {
- if ( $targetUser->isEmailConfirmed() ) {
- wfDebug( __METHOD__ . ":
sending talk page update notification\n" );
- $this->compose( $targetUser );
- $userTalkId =
$targetUser->getId();
- } else {
- wfDebug( __METHOD__ . ": talk
page owner doesn't have validated email\n" );
- }
- } else {
- wfDebug( __METHOD__ . ": talk page
owner doesn't want notifications\n" );
- }
+ $this->compose( $targetUser );
+ $userTalkId = $targetUser->getId();
}
if ( $wgEnotifWatchlist ) {
@@ -486,6 +490,39 @@
}
/**
+ * @param $editor User
+ * @param $title Title bool
+ * @param $minorEdit
+ * @return bool
+ */
+ private function canSendUserTalkEmail( $editor, $title, $minorEdit ) {
+ global $wgEnotifUserTalk;
+ $isUserTalkPage = ( $title->getNamespace() == NS_USER_TALK );
+
+ if ( $wgEnotifUserTalk && $isUserTalkPage ) {
+ $targetUser = User::newFromName( $title->getText() );
+
+ if ( !$targetUser || $targetUser->isAnon() ) {
+ wfDebug( __METHOD__ . ": user talk page edited,
but user does not exist\n" );
+ } elseif ( $targetUser->getId() == $editor->getId() ) {
+ wfDebug( __METHOD__ . ": user edited their own
talk page, no notification sent\n" );
+ } elseif ( $targetUser->getOption(
'enotifusertalkpages' ) &&
+ ( !$minorEdit || $targetUser->getOption(
'enotifminoredits' ) ) )
+ {
+ if ( $targetUser->isEmailConfirmed() ) {
+ wfDebug( __METHOD__ . ": sending talk
page update notification\n" );
+ return true;
+ } else {
+ wfDebug( __METHOD__ . ": talk page
owner doesn't have validated email\n" );
+ }
+ } else {
+ wfDebug( __METHOD__ . ": talk page owner
doesn't want notifications\n" );
+ }
+ }
+ return false;
+ }
+
+ /**
* Generate the generic "this page has been changed" e-mail text.
*/
private function composeCommonMailtext() {
Modified: branches/wmf/1.18wmf1/includes/job/EnotifNotifyJob.php
===================================================================
--- branches/wmf/1.18wmf1/includes/job/EnotifNotifyJob.php 2011-10-12
19:06:38 UTC (rev 99645)
+++ branches/wmf/1.18wmf1/includes/job/EnotifNotifyJob.php 2011-10-12
19:11:45 UTC (rev 99646)
@@ -20,7 +20,7 @@
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'] ) {
+ if( isset( $this->params['editorID'] ) &&
$this->params['editorID'] ) {
$editor = User::newFromId( $this->params['editorID'] );
// B/C, only the name might be given.
} else {
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs