jenkins-bot has submitted this change and it was merged.
Change subject: Don't send empty emails
......................................................................
Don't send empty emails
If no notification can be rendered,
don't send an email at all.
Bug: T137012
Change-Id: I57944e7af275ddecdffc82de8c050d8baa357660
---
M includes/EmailBatch.php
M includes/Notifier.php
M includes/formatters/EchoEventDigestFormatter.php
3 files changed, 9 insertions(+), 1 deletion(-)
Approvals:
Catrope: Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/EmailBatch.php b/includes/EmailBatch.php
index e5eb963..509ae4c 100644
--- a/includes/EmailBatch.php
+++ b/includes/EmailBatch.php
@@ -258,6 +258,11 @@
$textEmailDigestFormatter = new
EchoPlainTextDigestEmailFormatter( $this->mUser, $this->language, $frequency );
$content = $textEmailDigestFormatter->format( $this->events,
'email' );
+ if ( !$content ) {
+ // no event could be formatted
+ return;
+ }
+
$format = MWEchoNotifUser::newFromUser( $this->mUser
)->getEmailFormat();
if ( $format == EchoEmailFormat::HTML ) {
diff --git a/includes/Notifier.php b/includes/Notifier.php
index de62755..5f8b950 100644
--- a/includes/Notifier.php
+++ b/includes/Notifier.php
@@ -111,6 +111,9 @@
$lang = wfGetLangObj( $user->getOption( 'language' ) );
$formatter = new EchoPlainTextEmailFormatter( $user, $lang );
$content = $formatter->format( $event );
+ if ( !$content ) {
+ return false;
+ }
if ( $emailFormat === EchoEmailFormat::HTML ) {
$htmlEmailFormatter = new EchoHtmlEmailFormatter(
$user, $lang );
diff --git a/includes/formatters/EchoEventDigestFormatter.php
b/includes/formatters/EchoEventDigestFormatter.php
index e7ffd16..3c3e412 100644
--- a/includes/formatters/EchoEventDigestFormatter.php
+++ b/includes/formatters/EchoEventDigestFormatter.php
@@ -42,7 +42,7 @@
}
}
- return $this->formatModels( $models );
+ return $models ? $this->formatModels( $models ) : false;
}
/**
--
To view, visit https://gerrit.wikimedia.org/r/296394
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I57944e7af275ddecdffc82de8c050d8baa357660
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Echo
Gerrit-Branch: master
Gerrit-Owner: Sbisson <[email protected]>
Gerrit-Reviewer: Catrope <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits