From e289e4231fd9d989f2cacf52251d1a4b1b9a445a Mon Sep 17 00:00:00 2001 From: Andrew Garrett Date: Tue, 17 Jul 2012 12:58:53 -0700 Subject: [PATCH] Allow extensions to abort (and replace) email notifications Change-Id: I769ad24fcd6f3e3c03fb67122eab25a8472047b6 --- docs/hooks.txt | 4 ++++ includes/RecentChange.php | 16 +++++++++------- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/docs/hooks.txt b/docs/hooks.txt index 47654ce9df..5a836ae401 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -245,6 +245,10 @@ $block: The block from which the autoblock is coming. 'AbortDiffCache': Can be used to cancel the caching of a diff &$diffEngine: DifferenceEngine object +'AbortEmailNotification': Can be used to cancel email notifications for an edit. +$editor: The User who made the change. +$title: The Title of the page that was edited. + 'AbortLogin': Return false to cancel account login. $user: the User object being authenticated against $password: the password being submitted, not yet checked for validity diff --git a/includes/RecentChange.php b/includes/RecentChange.php index fb8e0224e2..20e7909a2a 100644 --- a/includes/RecentChange.php +++ b/includes/RecentChange.php @@ -231,13 +231,15 @@ class RecentChange { } $title = Title::makeTitle( $this->mAttribs['rc_namespace'], $this->mAttribs['rc_title'] ); - # @todo FIXME: This would be better as an extension hook - $enotif = new EmailNotification(); - $status = $enotif->notifyOnPageChange( $editor, $title, - $this->mAttribs['rc_timestamp'], - $this->mAttribs['rc_comment'], - $this->mAttribs['rc_minor'], - $this->mAttribs['rc_last_oldid'] ); + if ( wfRunHooks( 'AbortEmailNotification', array($editor, $title) ) ) { + # @todo FIXME: This would be better as an extension hook + $enotif = new EmailNotification(); + $status = $enotif->notifyOnPageChange( $editor, $title, + $this->mAttribs['rc_timestamp'], + $this->mAttribs['rc_comment'], + $this->mAttribs['rc_minor'], + $this->mAttribs['rc_last_oldid'] ); + } } } -- 2.20.1