trigger to fetch attachments as BODY instead of BINARY on failed BINARY was not called caused by an early exit from function

This commit is contained in:
Klaus Leithoff 2015-08-18 14:32:50 +00:00
parent 7efaea763d
commit 2b6ddcd127

View File

@ -2625,7 +2625,7 @@ class emailadmin_imapbase
if (self::$debugTimes) self::logRunTimes($starttime,null,function_backtrace(),__METHOD__.' ('.__LINE__.') '); if (self::$debugTimes) self::logRunTimes($starttime,null,function_backtrace(),__METHOD__.' ('.__LINE__.') ');
return $folders2return[$this->icServer->ImapServerId]; return $folders2return[$this->icServer->ImapServerId];
} }
/** /**
* Get IMAP folders for a mailbox * Get IMAP folders for a mailbox
* *
@ -2649,27 +2649,27 @@ class emailadmin_imapbase
{ {
// delimiter // delimiter
$delimiter = $this->getHierarchyDelimiter(); $delimiter = $this->getHierarchyDelimiter();
$folders = array(); $folders = array();
if ($_onlyTopLevel) // top level leaves if ($_onlyTopLevel) // top level leaves
{ {
// Get top mailboxes of icServer // Get top mailboxes of icServer
$topFolders = $this->icServer->getMailboxes("", 2, true); $topFolders = $this->icServer->getMailboxes("", 2, true);
foreach ($topFolders as &$node) foreach ($topFolders as &$node)
{ {
$pattern = "/\\".$delimiter."/"; $pattern = "/\\".$delimiter."/";
$reference = preg_replace($pattern, '', $node['MAILBOX']); $reference = preg_replace($pattern, '', $node['MAILBOX']);
$mainFolder = $subFolders = array(); $mainFolder = $subFolders = array();
// Get special use folders // Get special use folders
if (!isset(self::$specialUseFolders)) $this->getSpecialUseFolders (); // Set self::$sepecialUseFolders if (!isset(self::$specialUseFolders)) $this->getSpecialUseFolders (); // Set self::$sepecialUseFolders
// Create autofolders if they all not created yet // Create autofolders if they all not created yet
if (count(self::$autoFolders) > count(self::$specialUseFolders)) $this->check_create_autofolders(self::$specialUseFolders); if (count(self::$autoFolders) > count(self::$specialUseFolders)) $this->check_create_autofolders(self::$specialUseFolders);
// Merge of all auto folders and specialusefolders // Merge of all auto folders and specialusefolders
$autoFoldersTmp = array_unique((array_merge(self::$autoFolders, array_values(self::$specialUseFolders)))); $autoFoldersTmp = array_unique((array_merge(self::$autoFolders, array_values(self::$specialUseFolders))));
if ($_subscribedOnly) if ($_subscribedOnly)
{ {
$mainFolder = $this->icServer->listSubscribedMailboxes($reference, 1, true); $mainFolder = $this->icServer->listSubscribedMailboxes($reference, 1, true);
@ -2734,7 +2734,7 @@ class emailadmin_imapbase
{ {
$folders = $this->icServer->getMailboxes($path, $_search, true); $folders = $this->icServer->getMailboxes($path, $_search, true);
} }
ksort($folders); ksort($folders);
} }
elseif(!$_nodePath) // all elseif(!$_nodePath) // all
@ -2748,7 +2748,7 @@ class emailadmin_imapbase
$folders = $this->icServer->getMailboxes('', 0, true); $folders = $this->icServer->getMailboxes('', 0, true);
} }
} }
// Get counter information and add them to each fetched folders array // Get counter information and add them to each fetched folders array
if ($_getCounter) if ($_getCounter)
{ {
@ -2759,8 +2759,8 @@ class emailadmin_imapbase
} }
return $folders; return $folders;
} }
/** /**
* Check if all automatic folders exist and create them if not * Check if all automatic folders exist and create them if not
* *
@ -2799,7 +2799,7 @@ class emailadmin_imapbase
} }
return $rv; return $rv;
} }
/** /**
* sortByName * sortByName
* *
@ -2815,7 +2815,7 @@ class emailadmin_imapbase
// 0, 1 und -1 // 0, 1 und -1
return strcasecmp($a['name'],$b['name']); return strcasecmp($a['name'],$b['name']);
} }
/** /**
* sortByAutoFolderPos * sortByAutoFolderPos
* *
@ -2834,7 +2834,7 @@ class emailadmin_imapbase
if ($pos1 == $pos2) return 0; if ($pos1 == $pos2) return 0;
return ($pos1 < $pos2) ? -1 : 1; return ($pos1 < $pos2) ? -1 : 1;
} }
/** /**
* sortByDisplayName * sortByDisplayName
* *
@ -4261,11 +4261,12 @@ class emailadmin_imapbase
$part = $this->icServer->fetch($_folder, $fquery, array( $part = $this->icServer->fetch($_folder, $fquery, array(
'ids' => $uidsToFetch, 'ids' => $uidsToFetch,
))->first(); ))->first();
$partToReturn = null;
if (!$part) return null; if ($part)
{
$_encoding = $part->getBodyPartDecode($_partID); $_encoding = $part->getBodyPartDecode($_partID);
$partToReturn = $part->getBodyPart($_partID, $_stream); $partToReturn = $part->getBodyPart($_partID, $_stream);
}
// if we get an empty result, server may have trouble fetching data with UID FETCH $_uid (BINARY.PEEK[$_partID]) // if we get an empty result, server may have trouble fetching data with UID FETCH $_uid (BINARY.PEEK[$_partID])
// thus we trigger a second go with UID FETCH $_uid (BODY.PEEK[$_partID]) // thus we trigger a second go with UID FETCH $_uid (BODY.PEEK[$_partID])
if (empty($partToReturn)&&$_tryDecodingServerside===true) if (empty($partToReturn)&&$_tryDecodingServerside===true)
@ -4273,7 +4274,7 @@ class emailadmin_imapbase
error_log(__METHOD__.__LINE__.' failed to fetch bodyPart in BINARY. Try BODY'); error_log(__METHOD__.__LINE__.' failed to fetch bodyPart in BINARY. Try BODY');
$partToReturn = $this->getBodyPart($_uid, $_partID, $_folder, $_preserveSeen, $_stream, $_encoding, false); $partToReturn = $this->getBodyPart($_uid, $_partID, $_folder, $_preserveSeen, $_stream, $_encoding, false);
} }
return $partToReturn; return ($partToReturn?$partToReturn:null);
} }
/** /**