Index: branches/wmf/1.18wmf1/includes/UserMailer.php |
— | — | @@ -345,7 +345,8 @@ |
346 | 346 | * @param $oldid (default: false) |
347 | 347 | */ |
348 | 348 | public function notifyOnPageChange( $editor, $title, $timestamp, $summary, $minorEdit, $oldid = false ) { |
349 | | - global $wgEnotifUseJobQ, $wgEnotifWatchlist, $wgShowUpdatedMarker; |
| 349 | + global $wgEnotifUseJobQ, $wgEnotifWatchlist, $wgShowUpdatedMarker, $wgEnotifMinorEdits, |
| 350 | + $wgUsersNotifiedOnAllChanges, $wgEnotifUserTalk; |
350 | 351 | |
351 | 352 | if ( $title->getNamespace() < 0 ) { |
352 | 353 | return; |
— | — | @@ -384,6 +385,24 @@ |
385 | 386 | } |
386 | 387 | } |
387 | 388 | |
| 389 | + $sendEmail = true; |
| 390 | + // If nobody is watching the page, and there are no users notified on all changes |
| 391 | + // don't bother creating a job/trying to send emails |
| 392 | + // $watchers deals with $wgEnotifWatchlist |
| 393 | + if ( !count( $watchers ) && !count( $wgUsersNotifiedOnAllChanges ) ) { |
| 394 | + $sendEmail = false; |
| 395 | + // Only send notification for non minor edits, unless $wgEnotifMinorEdits |
| 396 | + if ( !$minorEdit || ( $wgEnotifMinorEdits && !$editor->isAllowed( 'nominornewtalk' ) ) ) { |
| 397 | + $isUserTalkPage = ( $title->getNamespace() == NS_USER_TALK ); |
| 398 | + if ( $wgEnotifUserTalk && $isUserTalkPage && $this->canSendUserTalkEmail( $editor, $title, $minorEdit ) ) { |
| 399 | + $sendEmail = true; |
| 400 | + } |
| 401 | + } |
| 402 | + } |
| 403 | + |
| 404 | + if ( !$sendEmail ) { |
| 405 | + return; |
| 406 | + } |
388 | 407 | if ( $wgEnotifUseJobQ ) { |
389 | 408 | $params = array( |
390 | 409 | "editor" => $editor->getName(), |
— | — | @@ -398,7 +417,6 @@ |
399 | 418 | } else { |
400 | 419 | $this->actuallyNotifyOnPageChange( $editor, $title, $timestamp, $summary, $minorEdit, $oldid, $watchers ); |
401 | 420 | } |
402 | | - |
403 | 421 | } |
404 | 422 | |
405 | 423 | /** |
— | — | @@ -439,25 +457,11 @@ |
440 | 458 | $userTalkId = false; |
441 | 459 | |
442 | 460 | if ( !$minorEdit || ( $wgEnotifMinorEdits && !$editor->isAllowed( 'nominornewtalk' ) ) ) { |
443 | | - if ( $wgEnotifUserTalk && $isUserTalkPage ) { |
| 461 | + |
| 462 | + if ( $wgEnotifUserTalk && $isUserTalkPage && $this->canSendUserTalkEmail( $editor, $title, $minorEdit ) ) { |
444 | 463 | $targetUser = User::newFromName( $title->getText() ); |
445 | | - if ( !$targetUser || $targetUser->isAnon() ) { |
446 | | - wfDebug( __METHOD__ . ": user talk page edited, but user does not exist\n" ); |
447 | | - } elseif ( $targetUser->getId() == $editor->getId() ) { |
448 | | - wfDebug( __METHOD__ . ": user edited their own talk page, no notification sent\n" ); |
449 | | - } elseif ( $targetUser->getOption( 'enotifusertalkpages' ) && |
450 | | - ( !$minorEdit || $targetUser->getOption( 'enotifminoredits' ) ) ) |
451 | | - { |
452 | | - if ( $targetUser->isEmailConfirmed() ) { |
453 | | - wfDebug( __METHOD__ . ": sending talk page update notification\n" ); |
454 | | - $this->compose( $targetUser ); |
455 | | - $userTalkId = $targetUser->getId(); |
456 | | - } else { |
457 | | - wfDebug( __METHOD__ . ": talk page owner doesn't have validated email\n" ); |
458 | | - } |
459 | | - } else { |
460 | | - wfDebug( __METHOD__ . ": talk page owner doesn't want notifications\n" ); |
461 | | - } |
| 464 | + $this->compose( $targetUser ); |
| 465 | + $userTalkId = $targetUser->getId(); |
462 | 466 | } |
463 | 467 | |
464 | 468 | if ( $wgEnotifWatchlist ) { |
— | — | @@ -486,6 +490,39 @@ |
487 | 491 | } |
488 | 492 | |
489 | 493 | /** |
| 494 | + * @param $editor User |
| 495 | + * @param $title Title bool |
| 496 | + * @param $minorEdit |
| 497 | + * @return bool |
| 498 | + */ |
| 499 | + private function canSendUserTalkEmail( $editor, $title, $minorEdit ) { |
| 500 | + global $wgEnotifUserTalk; |
| 501 | + $isUserTalkPage = ( $title->getNamespace() == NS_USER_TALK ); |
| 502 | + |
| 503 | + if ( $wgEnotifUserTalk && $isUserTalkPage ) { |
| 504 | + $targetUser = User::newFromName( $title->getText() ); |
| 505 | + |
| 506 | + if ( !$targetUser || $targetUser->isAnon() ) { |
| 507 | + wfDebug( __METHOD__ . ": user talk page edited, but user does not exist\n" ); |
| 508 | + } elseif ( $targetUser->getId() == $editor->getId() ) { |
| 509 | + wfDebug( __METHOD__ . ": user edited their own talk page, no notification sent\n" ); |
| 510 | + } elseif ( $targetUser->getOption( 'enotifusertalkpages' ) && |
| 511 | + ( !$minorEdit || $targetUser->getOption( 'enotifminoredits' ) ) ) |
| 512 | + { |
| 513 | + if ( $targetUser->isEmailConfirmed() ) { |
| 514 | + wfDebug( __METHOD__ . ": sending talk page update notification\n" ); |
| 515 | + return true; |
| 516 | + } else { |
| 517 | + wfDebug( __METHOD__ . ": talk page owner doesn't have validated email\n" ); |
| 518 | + } |
| 519 | + } else { |
| 520 | + wfDebug( __METHOD__ . ": talk page owner doesn't want notifications\n" ); |
| 521 | + } |
| 522 | + } |
| 523 | + return false; |
| 524 | + } |
| 525 | + |
| 526 | + /** |
490 | 527 | * Generate the generic "this page has been changed" e-mail text. |
491 | 528 | */ |
492 | 529 | private function composeCommonMailtext() { |
Index: branches/wmf/1.18wmf1/includes/job/EnotifNotifyJob.php |
— | — | @@ -20,7 +20,7 @@ |
21 | 21 | function run() { |
22 | 22 | $enotif = new EmailNotification(); |
23 | 23 | // Get the user from ID (rename safe). Anons are 0, so defer to name. |
24 | | - if( isset($this->params['editorID']) && $this->params['editorID'] ) { |
| 24 | + if( isset( $this->params['editorID'] ) && $this->params['editorID'] ) { |
25 | 25 | $editor = User::newFromId( $this->params['editorID'] ); |
26 | 26 | // B/C, only the name might be given. |
27 | 27 | } else { |
Property changes on: branches/wmf/1.18wmf1/includes |
___________________________________________________________________ |
Modified: svn:mergeinfo |
28 | 28 | Merged /trunk/phase3/includes:r97810 |
Property changes on: branches/wmf/1.18wmf1 |
___________________________________________________________________ |
Modified: svn:mergeinfo |
29 | 29 | Merged /trunk/phase3:r97810 |