Skip to content

Commit

Permalink
[jan] Consistently return a stream from the getBodypart() methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
yunosh committed Mar 24, 2014
1 parent 96381af commit 54ab31f
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 24 deletions.
Expand Up @@ -328,7 +328,7 @@ public function fetchStructure($mailbox, $uids)
* @param array $uid The message UID.
* @param array $id The mime part ID.
*
* @return resource The body part, in a stream resource.
* @return resource The body part, as a stream resource.
*/
public function fetchBodypart($mailbox, $uid, $id)
{
Expand Down
Expand Up @@ -663,7 +663,7 @@ public function fetchStructure($folder, $uids)
* @param array $uid The message UID.
* @param array $id The mime part ID.
*
* @return resource|string The body part, as a stream resource or string.
* @return resource The body part, as a stream resource.
*/
public function fetchBodypart($folder, $uid, $id)
{
Expand All @@ -685,7 +685,7 @@ public function fetchBodypart($folder, $uid, $id)
)
);
}
return $result;
return Horde_Stream_Wrapper_String::getStream($result);
}

/**
Expand Down
Expand Up @@ -381,7 +381,7 @@ public function fetchStructure($folder, $uids)
* @param array $uid The message UID.
* @param array $id The mime part ID.
*
* @return resource|string The body part, as a stream resource or string.
* @return resource The body part, as a stream resource.
*/
public function fetchBodypart($folder, $uid, $id)
{
Expand Down
Expand Up @@ -508,7 +508,7 @@ public function fetchStructure($folder, $uids)
* @param array $uid The message UID.
* @param array $id The mime part ID.
*
* @return resource|string The body part, as a stream resource or string.
* @return resource The body part, as a stream resource.
*/
public function fetchBodypart($folder, $uid, $id)
{
Expand Down
Expand Up @@ -646,7 +646,7 @@ public function fetchComplete($folder, $uid)
* @param array $uid The message UID.
* @param array $id The mime part ID.
*
* @return resource|string The body part, as a stream resource or string.
* @return resource The body part, as a stream resource.
*/
public function fetchBodypart($folder, $uid, $id)
{
Expand Down
Expand Up @@ -337,7 +337,7 @@ public function fetchStructure($folder, $uids)
* @param array $uid The message UID.
* @param array $id The mime part ID.
*
* @return resource|string The body part, as a stream resource or string.
* @return resource The body part, as a stream resource.
*/
public function fetchBodypart($folder, $uid, $id)
{
Expand All @@ -349,21 +349,22 @@ public function fetchBodypart($folder, $uid, $id)
'r'
);
}
} else if (isset($this->_selected['mails'][$uid]['stream'])) {
} elseif (isset($this->_selected['mails'][$uid]['stream'])) {
rewind($this->_selected['mails'][$uid]['stream']);
return Horde_Mime_Part::parseMessage(
stream_get_contents($this->_selected['mails'][$uid]['stream'])
)->getPart($id)->getContents();
} else {
throw new Horde_Kolab_Storage_Exception(
sprintf(
'No such part %s for message uid %s in folder %s!',
$id,
$uid,
$folder
)
);
)
->getPart($id)
->getContents(array('stream' => true));
}
throw new Horde_Kolab_Storage_Exception(
sprintf(
'No such part %s for message uid %s in folder %s!',
$id,
$uid,
$folder
)
);
}

/**
Expand Down
Expand Up @@ -400,13 +400,15 @@ public function fetchStructure($folder, $uids)
* @param array $uid The message UID.
* @param array $id The mime part ID.
*
* @return resource|string The body part, as a stream resource or string.
* @return resource The body part, as a stream resource.
*/
public function fetchBodypart($folder, $uid, $id)
{
$this->select($folder);
return Horde_Kolab_Storage_Exception_Pear::catchError(
$this->getBackend()->getBodyPart($uid, $id, true)
return Horde_Stream_Wrapper_String::getStream(
Horde_Kolab_Storage_Exception_Pear::catchError(
$this->getBackend()->getBodyPart($uid, $id, true)
)
);
}

Expand Down
Expand Up @@ -585,7 +585,7 @@ public function fetchStructure($folder, $uids)
* @param array $uid The message UID.
* @param array $id The mime part ID.
*
* @return resource|string The body part, as a stream resource or string.
* @return resource The body part, as a stream resource.
*/
public function fetchBodypart($folder, $uid, $id)
{
Expand Down
2 changes: 2 additions & 0 deletions framework/Kolab_Storage/package.xml
Expand Up @@ -22,6 +22,7 @@
</stability>
<license uri="http://www.horde.org/licenses/lgpl21">LGPL-2.1</license>
<notes>
* [jan] Consistently return a stream from the getBodypart() methods.
* [jan] Add Horde_Kolab_Storage_Object#getBackendId().
* [jan] Implement saving and loading of attachments to Kolab objects (backward compatibility break in Horde_Kolab_Storage_Data#getAttachment()!).
* [mms] Fix grabbing annotation list from IMAP server.
Expand Down Expand Up @@ -1332,6 +1333,7 @@
<date>2014-02-20</date>
<license uri="http://www.horde.org/licenses/lgpl21">LGPL-2.1</license>
<notes>
* [jan] Consistently return a stream from the getBodypart() methods.
* [jan] Add Horde_Kolab_Storage_Object#getBackendId().
* [jan] Implement saving and loading of attachments to Kolab objects (backward compatibility break in Horde_Kolab_Storage_Data#getAttachment()!).
* [mms] Fix grabbing annotation list from IMAP server.
Expand Down
Expand Up @@ -356,12 +356,12 @@ public function fetchStructure($folder, $uids)
* @param array $uid The message UID.
* @param array $id The mime part ID.
*
* @return resource|string The body part, as a stream resource or string.
* @return resource The body part, as a stream resource.
*/
public function fetchBodypart($folder, $uid, $id)
{
$message = Horde_Mime_Part::parseMessage($this->messages[$folder][$uid]);
return $message->getPart($id)->getContents();
return $message->getPart($id)->getContents(array('stream' => true));
}


Expand Down

0 comments on commit 54ab31f

Please sign in to comment.