Don't attempt to grab MIME bodypart 0 (it doesn't exist on the IMAP server)
authorMichael M Slusarz <slusarz@curecanti.org>
Mon, 8 Jun 2009 22:15:52 +0000 (16:15 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Mon, 8 Jun 2009 22:15:52 +0000 (16:15 -0600)
imp/lib/Contents.php

index e31c1a7..67e13cd 100644 (file)
@@ -186,6 +186,10 @@ class IMP_Contents
      */
     public function getBodyPart($id, $options = array())
     {
+        if (empty($id)) {
+            return '';
+        }
+
         if (is_null($this->_mailbox)) {
             // TODO: Include MIME headers?
             $ob = $this->getMIMEPart($id, array('nocontents' => true));
@@ -292,7 +296,11 @@ class IMP_Contents
 
         $part = $this->_message->getPart($id);
 
-        if (!is_null($part) &&
+        /* Don't download contents of entire body if ID == 0 (indicating the
+         * body of the main multipart message).  I'm pretty sure we never
+         * want to download the body of that part here. */
+        if (!empty($id) &&
+            !is_null($part) &&
             empty($options['nocontents']) &&
             !is_null($this->_mailbox) &&
             !$part->getContents()) {