Index: trunk/phase3/RELEASE-NOTES-1.19 |
— | — | @@ -96,6 +96,7 @@ |
97 | 97 | really small, and somewhat inconsistent with each other. |
98 | 98 | * Per page edit-notices now work in namespaces without subpages enabled. |
99 | 99 | * (bug 30245) Use the correct way to construct a log page title |
| 100 | +* (bug 31081) $wgEnotifUseJobQ causes many unnecessary jobs to be queued |
100 | 101 | |
101 | 102 | === API changes in 1.19 === |
102 | 103 | * (bug 19838) siprop=interwikimap can now use the interwiki cache. |
Index: trunk/phase3/includes/UserMailer.php |
— | — | @@ -364,7 +364,8 @@ |
365 | 365 | * @param $oldid (default: false) |
366 | 366 | */ |
367 | 367 | public function notifyOnPageChange( $editor, $title, $timestamp, $summary, $minorEdit, $oldid = false ) { |
368 | | - global $wgEnotifUseJobQ, $wgEnotifWatchlist, $wgShowUpdatedMarker; |
| 368 | + global $wgEnotifUseJobQ, $wgEnotifWatchlist, $wgShowUpdatedMarker, $wgEnotifMinorEdits, |
| 369 | + $wgUsersNotifiedOnAllChanges, $wgEnotifUserTalk; |
369 | 370 | |
370 | 371 | if ( $title->getNamespace() < 0 ) { |
371 | 372 | return; |
— | — | @@ -403,6 +404,24 @@ |
404 | 405 | } |
405 | 406 | } |
406 | 407 | |
| 408 | + $sendEmail = true; |
| 409 | + // If nobody is watching the page, and there are no users notified on all changes |
| 410 | + // don't bother creating a job/trying to send emails |
| 411 | + // $watchers deals with $wgEnotifWatchlist |
| 412 | + if ( !count( $watchers ) && !count( $wgUsersNotifiedOnAllChanges ) ) { |
| 413 | + $sendEmail = false; |
| 414 | + // Only send notification for non minor edits, unless $wgEnotifMinorEdits |
| 415 | + if ( !$minorEdit || ( $wgEnotifMinorEdits && !$editor->isAllowed( 'nominornewtalk' ) ) ) { |
| 416 | + $isUserTalkPage = ( $title->getNamespace() == NS_USER_TALK ); |
| 417 | + if ( $wgEnotifUserTalk && $isUserTalkPage && $this->canSendUserTalkEmail( $editor, $title, $minorEdit ) ) { |
| 418 | + $sendEmail = true; |
| 419 | + } |
| 420 | + } |
| 421 | + } |
| 422 | + |
| 423 | + if ( !$sendEmail ) { |
| 424 | + return; |
| 425 | + } |
407 | 426 | if ( $wgEnotifUseJobQ ) { |
408 | 427 | $params = array( |
409 | 428 | 'editor' => $editor->getName(), |
— | — | @@ -418,7 +437,6 @@ |
419 | 438 | } else { |
420 | 439 | $this->actuallyNotifyOnPageChange( $editor, $title, $timestamp, $summary, $minorEdit, $oldid, $watchers ); |
421 | 440 | } |
422 | | - |
423 | 441 | } |
424 | 442 | |
425 | 443 | /** |
— | — | @@ -459,25 +477,11 @@ |
460 | 478 | $userTalkId = false; |
461 | 479 | |
462 | 480 | if ( !$minorEdit || ( $wgEnotifMinorEdits && !$editor->isAllowed( 'nominornewtalk' ) ) ) { |
463 | | - if ( $wgEnotifUserTalk && $isUserTalkPage ) { |
| 481 | + |
| 482 | + if ( $wgEnotifUserTalk && $isUserTalkPage && $this->canSendUserTalkEmail( $editor, $title, $minorEdit ) ) { |
464 | 483 | $targetUser = User::newFromName( $title->getText() ); |
465 | | - if ( !$targetUser || $targetUser->isAnon() ) { |
466 | | - wfDebug( __METHOD__ . ": user talk page edited, but user does not exist\n" ); |
467 | | - } elseif ( $targetUser->getId() == $editor->getId() ) { |
468 | | - wfDebug( __METHOD__ . ": user edited their own talk page, no notification sent\n" ); |
469 | | - } elseif ( $targetUser->getOption( 'enotifusertalkpages' ) && |
470 | | - ( !$minorEdit || $targetUser->getOption( 'enotifminoredits' ) ) ) |
471 | | - { |
472 | | - if ( $targetUser->isEmailConfirmed() ) { |
473 | | - wfDebug( __METHOD__ . ": sending talk page update notification\n" ); |
474 | | - $this->compose( $targetUser ); |
475 | | - $userTalkId = $targetUser->getId(); |
476 | | - } else { |
477 | | - wfDebug( __METHOD__ . ": talk page owner doesn't have validated email\n" ); |
478 | | - } |
479 | | - } else { |
480 | | - wfDebug( __METHOD__ . ": talk page owner doesn't want notifications\n" ); |
481 | | - } |
| 484 | + $this->compose( $targetUser ); |
| 485 | + $userTalkId = $targetUser->getId(); |
482 | 486 | } |
483 | 487 | |
484 | 488 | if ( $wgEnotifWatchlist ) { |
— | — | @@ -506,6 +510,39 @@ |
507 | 511 | } |
508 | 512 | |
509 | 513 | /** |
| 514 | + * @param $editor User |
| 515 | + * @param $title Title bool |
| 516 | + * @param $minorEdit |
| 517 | + * @return bool |
| 518 | + */ |
| 519 | + private function canSendUserTalkEmail( $editor, $title, $minorEdit ) { |
| 520 | + global $wgEnotifUserTalk; |
| 521 | + $isUserTalkPage = ( $title->getNamespace() == NS_USER_TALK ); |
| 522 | + |
| 523 | + if ( $wgEnotifUserTalk && $isUserTalkPage ) { |
| 524 | + $targetUser = User::newFromName( $title->getText() ); |
| 525 | + |
| 526 | + if ( !$targetUser || $targetUser->isAnon() ) { |
| 527 | + wfDebug( __METHOD__ . ": user talk page edited, but user does not exist\n" ); |
| 528 | + } elseif ( $targetUser->getId() == $editor->getId() ) { |
| 529 | + wfDebug( __METHOD__ . ": user edited their own talk page, no notification sent\n" ); |
| 530 | + } elseif ( $targetUser->getOption( 'enotifusertalkpages' ) && |
| 531 | + ( !$minorEdit || $targetUser->getOption( 'enotifminoredits' ) ) ) |
| 532 | + { |
| 533 | + if ( $targetUser->isEmailConfirmed() ) { |
| 534 | + wfDebug( __METHOD__ . ": sending talk page update notification\n" ); |
| 535 | + return true; |
| 536 | + } else { |
| 537 | + wfDebug( __METHOD__ . ": talk page owner doesn't have validated email\n" ); |
| 538 | + } |
| 539 | + } else { |
| 540 | + wfDebug( __METHOD__ . ": talk page owner doesn't want notifications\n" ); |
| 541 | + } |
| 542 | + } |
| 543 | + return false; |
| 544 | + } |
| 545 | + |
| 546 | + /** |
510 | 547 | * Generate the generic "this page has been changed" e-mail text. |
511 | 548 | */ |
512 | 549 | private function composeCommonMailtext() { |
Index: trunk/phase3/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 { |