mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-19 05:01:12 +01:00
* Mail: on attachment/body retrieval BINARY retrieval may fail on certain servers; if so retry and fetch bodypart with BODY instead leaving the decoding to the library
This commit is contained in:
parent
282534a8b9
commit
2836c9c1b2
@ -4030,9 +4030,10 @@ class emailadmin_imapbase
|
|||||||
* @param boolean $_preserveSeen=false
|
* @param boolean $_preserveSeen=false
|
||||||
* @param boolean $_stream=false true return a stream, false return string
|
* @param boolean $_stream=false true return a stream, false return string
|
||||||
* @param string &$_encoding=null on return: transfer encoding of returned part
|
* @param string &$_encoding=null on return: transfer encoding of returned part
|
||||||
|
* @param boolean $_tryDecodingServerside=true; wether to try to fetch Data with BINARY instead of BODY
|
||||||
* @return string|resource
|
* @return string|resource
|
||||||
*/
|
*/
|
||||||
function getBodyPart($_uid, $_partID=null, $_folder=null, $_preserveSeen=false, $_stream=false, &$_encoding=null)
|
function getBodyPart($_uid, $_partID=null, $_folder=null, $_preserveSeen=false, $_stream=false, &$_encoding=null, $_tryDecodingServerside=true)
|
||||||
{
|
{
|
||||||
if (self::$debug) error_log( __METHOD__."($_uid, $_partID, $_folder, $_preserveSeen)");
|
if (self::$debug) error_log( __METHOD__."($_uid, $_partID, $_folder, $_preserveSeen)");
|
||||||
|
|
||||||
@ -4047,10 +4048,12 @@ class emailadmin_imapbase
|
|||||||
$uidsToFetch->add($_uid);
|
$uidsToFetch->add($_uid);
|
||||||
|
|
||||||
$fquery = new Horde_Imap_Client_Fetch_Query();
|
$fquery = new Horde_Imap_Client_Fetch_Query();
|
||||||
$fquery->bodyPart($_partID, array(
|
$fetchParams = array(
|
||||||
'peek' => $_preserveSeen,
|
'peek' => $_preserveSeen,
|
||||||
'decode' => true, // try decode on server, does NOT neccessary work
|
'decode' => true, // try decode on server, does NOT neccessary work
|
||||||
));
|
);
|
||||||
|
if ($_tryDecodingServerside===false) unset($fetchParams['decode']);
|
||||||
|
$fquery->bodyPart($_partID, $fetchParams);
|
||||||
|
|
||||||
$part = $this->icServer->fetch($_folder, $fquery, array(
|
$part = $this->icServer->fetch($_folder, $fquery, array(
|
||||||
'ids' => $uidsToFetch,
|
'ids' => $uidsToFetch,
|
||||||
@ -4059,8 +4062,15 @@ class emailadmin_imapbase
|
|||||||
if (!$part) return null;
|
if (!$part) return null;
|
||||||
|
|
||||||
$_encoding = $part->getBodyPartDecode($_partID);
|
$_encoding = $part->getBodyPartDecode($_partID);
|
||||||
|
$partToReturn = $part->getBodyPart($_partID, $_stream);
|
||||||
return $part->getBodyPart($_partID, $_stream);
|
// 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])
|
||||||
|
if (empty($partToReturn)&&$_tryDecodingServerside===true)
|
||||||
|
{
|
||||||
|
error_log(__METHOD__.__LINE__.' failed to fetch bodyPart in BINARY. Try BODY');
|
||||||
|
$partToReturn = $this->getBodyPart($_uid, $_partID, $_folder, $_preserveSeen, $_stream, $_encoding, false);
|
||||||
|
}
|
||||||
|
return $partToReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user