Fix rewind of stream
authorMichael M Slusarz <slusarz@curecanti.org>
Mon, 6 Jul 2009 05:17:22 +0000 (23:17 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Mon, 6 Jul 2009 05:17:22 +0000 (23:17 -0600)
framework/Imap_Client/lib/Horde/Imap/Client/Socket/Pop3.php

index 76de749..b241b74 100644 (file)
@@ -896,12 +896,11 @@ class Horde_Imap_Client_Socket_Pop3 extends Horde_Imap_Client_Base
 
             case Horde_Imap_Client::FETCH_STRUCTURE:
                 foreach ($seq_ids as $id) {
-                    if ($tmp = $this->_pop3Cache('msg', $id)) {
+                    $tmp = false;
+                    if ($ptr = $this->_pop3Cache('msg', $id)) {
                         try {
-                            $tmp = Horde_Mime_Part::parseMessage(stream_get_contents($tmp), array('structure' => empty($c_val['parse'])));
-                        } catch (Horde_Exception $e) {
-                            $tmp = false;
-                        }
+                            $tmp = Horde_Mime_Part::parseMessage(stream_get_contents($ptr), array('structure' => empty($c_val['parse'])));
+                        } catch (Horde_Exception $e) {}
                     }
                     $ret[$id]['structure'] = $tmp;
                 }
@@ -989,6 +988,9 @@ class Horde_Imap_Client_Socket_Pop3 extends Horde_Imap_Client_Base
     protected function _pop3Cache($type, $index = null, $data = null)
     {
         if (isset($this->_temp['pop3cache'][$index][$type])) {
+            if ($type == 'msg') {
+                rewind($this->_temp['pop3cache'][$index][$type]);
+            }
             return $this->_temp['pop3cache'][$index][$type];
         }