improved error handling for additional issues (getAttachment, getTextPart, getMessageRawHeaders,...), by testing on PEAR Errors before trying to process the data/pipe the data for handling in UI

This commit is contained in:
Klaus Leithoff 2010-11-05 13:59:52 +00:00
parent 9d171dd1a4
commit 61693f14dc
2 changed files with 29 additions and 1 deletions

View File

@ -1137,6 +1137,15 @@
$filename = self::getFileNameFromStructure($structure);
$attachment = $this->icServer->getBodyPart($_uid, $_partID, true);
if (PEAR::isError($attachment))
{
error_log(__METHOD__.__LINE__.' failed:'.$attachment->message);
return array('type' => 'text/plain',
'filename' => 'error.txt',
'attachment' =>__METHOD__.' failed:'.$attachment->message
);
}
switch ($structure->encoding) {
case 'BASE64':
// use imap_base64 to decode
@ -1200,6 +1209,15 @@
$filename = self::getFileNameFromStructure($structure);
$attachment = $this->icServer->getBodyPart($_uid, $partID, true);
if (PEAR::isError($attachment))
{
error_log(__METHOD__.__LINE__.' failed:'.$attachment->message);
return array('type' => 'text/plain',
'filename' => 'error.txt',
'attachment' =>__METHOD__.' failed:'.$attachment->message
);
}
switch ($structure->encoding) {
case 'BASE64':
// use imap_base64 to decode
@ -1825,6 +1843,11 @@
if (self::$debug) _debug_array(array($_structure,function_backtrace()));
$partID = $_structure->partID;
$mimePartBody = $this->icServer->getBodyPart($_uid, $partID, true);
if (PEAR::isError($mimePartBody))
{
error_log(__METHOD__.__LINE__.' failed:'.$mimePartBody->message);
return false;
}
//_debug_array($mimePartBody);
//_debug_array(preg_replace('/PropertyFile___$/','',$this->decodeMimePart($mimePartBody, $_structure->encoding)));
if($_structure->subType == 'HTML' && $_htmlMode != 'always_display' && $_htmlMode != 'only_if_no_text') {
@ -2554,6 +2577,11 @@
} else {
$body = $this->icServer->getBodyPart($_uid, $_partID, true);
}
if (PEAR::isError($body))
{
error_log(__METHOD__.__LINE__.' failed:'.$body->message);
return false;
}
return $body;
}

View File

@ -1206,7 +1206,7 @@
$body = '';
//error_log(__METHOD__.array2string($bodyParts)); //exit;
if (empty($bodyParts)) return "";
foreach((array)$bodyParts as $singleBodyPart) {
if (!isset($singleBodyPart['body'])) {
$singleBodyPart['body'] = $this->getdisplayableBody($singleBodyPart);