jenkins-bot has submitted this change and it was merged.
Change subject: Add emailsubject as a distribution type
......................................................................
Add emailsubject as a distribution type
so that we could skip parameters escaping when formatting email
subject. This is not a great solution but works for now.
Probably should re-think all the use case of echo formatting and
refactor the formatter
Change-Id: Ic1f6aa0f72d637558466db5cb2ee8d36038dd0b2
---
M formatters/BasicFormatter.php
M formatters/NotificationFormatter.php
2 files changed, 15 insertions(+), 6 deletions(-)
Approvals:
EBernhardson: Looks good to me, approved
jenkins-bot: Verified
diff --git a/formatters/BasicFormatter.php b/formatters/BasicFormatter.php
index b9235cf..761c274 100644
--- a/formatters/BasicFormatter.php
+++ b/formatters/BasicFormatter.php
@@ -282,12 +282,19 @@
// Echo single email
$emailSingle = new EchoEmailSingle( $this, $event, $user );
-
$textEmailFormatter = new EchoTextEmailFormatter( $emailSingle
);
+ // Update the distribution type to emailsubject when formatting
+ // email subject
+ // @FIXME - Find a better way to do this
+ $distributionType = $this->distributionType;
+ $this->setDistributionType( 'emailsubject' );
+ $subject = $this->formatFragment( $this->email['subject'],
$event, $user )->text();
+ $this->setDistributionType( $distributionType );
+
$content = array(
// Single email subject, there is no need to to escape
it for either html
// or text email since it's always treated as plain
text by mail client
- 'subject' => $this->formatFragment(
$this->email['subject'], $event, $user )->text(),
+ 'subject' => $subject,
// Single email text body
'body' => $textEmailFormatter->formatEmail(),
);
@@ -660,13 +667,15 @@
}
/**
- * Process a param that should be escaped
+ * Process a parameter that should be escaped for display except for use
+ * cases like plain text email and email subject
+ *
* @param $message Message
* @param $paramContent string
*/
protected function processParamEscaped( $message, $paramContent ) {
- // Plain text email does not need escape
- if ( $this->outputFormat !== 'email' ) {
+ // Plain text email and email subject do not need to be escaped
+ if ( $this->outputFormat !== 'email' && $this->distributionType
!== 'emailsubject' ) {
$paramContent = htmlspecialchars( $paramContent );
}
diff --git a/formatters/NotificationFormatter.php
b/formatters/NotificationFormatter.php
index 9ca8e05..2604ea3 100644
--- a/formatters/NotificationFormatter.php
+++ b/formatters/NotificationFormatter.php
@@ -17,7 +17,7 @@
/**
* List of valid distribution type
*/
- protected $validDistributionType = array( 'web', 'email', 'emaildigest'
);
+ protected $validDistributionType = array( 'web', 'email',
'emaildigest', 'emailsubject' );
/**
* Current output format, default is 'text'
--
To view, visit https://gerrit.wikimedia.org/r/159840
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ic1f6aa0f72d637558466db5cb2ee8d36038dd0b2
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Echo
Gerrit-Branch: master
Gerrit-Owner: Bsitu <[email protected]>
Gerrit-Reviewer: EBernhardson <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits