Ejegg has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/395566 )
Change subject: CRM-21521: read multipart-related inside report
......................................................................
CRM-21521: read multipart-related inside report
When a multipart-report email body's first part is
multipart-related, extract the text correctly instead of crashing.
Bug: T181934
Change-Id: I736acde96885aa6f6dde87af8770de5f812ea3ad
---
M CRM/Utils/Mail/EmailProcessor.php
1 file changed, 22 insertions(+), 8 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/crm/civicrm
refs/changes/66/395566/1
diff --git a/CRM/Utils/Mail/EmailProcessor.php
b/CRM/Utils/Mail/EmailProcessor.php
index b602649..ee48d4c 100644
--- a/CRM/Utils/Mail/EmailProcessor.php
+++ b/CRM/Utils/Mail/EmailProcessor.php
@@ -325,17 +325,15 @@
}
elseif (($part = $mail->body->getReadablePart()) != NULL) {
watchdog('EmailProcessor', "Part is not DeliveryStatus but
supposedly has ReadablePart: " . print_r($part, true), array(), WATCHDOG_DEBUG);
- $text = $part->text;
+ if (isset($part->text)) {
+ $text = $part->text;
+ } elseif ($part instanceof ezcMailMultipartRelated) {
+ $text = self::getTextFromRelated($part);
+ }
}
}
elseif ($mail->body instanceof ezcMailMultipartRelated) {
- foreach ($mail->body->getRelatedParts() as $part) {
- watchdog('EmailProcessor', "Looking at related part",
array(), WATCHDOG_DEBUG);
- if (isset($part->subType) and $part->subType == 'plain') {
- $text = $part->text;
- break;
- }
- }
+ $text = self::getTextFromRelated($mail->body);
}
else {
foreach ($mail->body->getParts() as $part) {
@@ -486,4 +484,20 @@
}
}
+ /**
+ * @param \ezcMailMultipartRelated $related
+ *
+ * @return array
+ */
+ protected static function getTextFromRelated($related) {
+ foreach ($related->getRelatedParts() as $part) {
+ watchdog('EmailProcessor', "Looking at related part", [],
WATCHDOG_DEBUG);
+ if (isset($part->subType) and $part->subType == 'plain') {
+ $text = $part->text;
+ return $text;
+ }
+ }
+ return null;
+ }
+
}
--
To view, visit https://gerrit.wikimedia.org/r/395566
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I736acde96885aa6f6dde87af8770de5f812ea3ad
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/fundraising/crm/civicrm
Gerrit-Branch: master
Gerrit-Owner: Ejegg <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits