Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.8.8

Request #15913 Attachments Memory Optimization
Submitted: 2009-02-18 14:45 UTC Modified: 2009-12-18 14:49 UTC
From: erika Assigned: alec
Status: Closed Package: Mail_Mime
PHP Version: 5.2.4 OS: Linux
Roadmaps: 1.5.3    
Subscription  



Patch mimePart.php.patch Revisions
Revision 2009-07-26 10:47 UTC
Developer erika
 
Download patch

This patch renders other patches obsolete

Obsolete patches:

--- old/mimePart.php	2009-07-26 11:27:08.000000000 +0200
+++ new/mimePart.php	2009-07-26 11:44:42.000000000 +0200
@@ -243,19 +243,26 @@
             $boundary = '=_' . md5(rand() . microtime());
             $this->_headers['Content-Type'] .= ';' . MAIL_MIMEPART_CRLF . "\t" . 'boundary="' . $boundary . '"';
 
-            // Add body parts to $subparts
+            $encoded['body'] = '' ;
+
             for ($i = 0; $i < count($this->_subparts); $i++) {
                 $headers = array();
                 $tmp = $this->_subparts[$i]->encode();
                 foreach ($tmp['headers'] as $key => $value) {
                     $headers[] = $key . ': ' . $value;
                 }
-                $subparts[] = implode(MAIL_MIMEPART_CRLF, $headers) . MAIL_MIMEPART_CRLF . MAIL_MIMEPART_CRLF . $tmp['body'] . MAIL_MIMEPART_CRLF;
+
+                $encoded['body'] .= '--' . $boundary . MAIL_MIMEPART_CRLF .
+                                    implode(MAIL_MIMEPART_CRLF, $headers) . MAIL_MIMEPART_CRLF . MAIL_MIMEPART_CRLF . $tmp['body'] . MAIL_MIMEPART_CRLF;
             }
 
-            $encoded['body'] = '--' . $boundary . MAIL_MIMEPART_CRLF . 
-                               rtrim(implode('--' . $boundary . MAIL_MIMEPART_CRLF , $subparts), MAIL_MIMEPART_CRLF) . MAIL_MIMEPART_CRLF . 
-                               '--' . $boundary.'--' . MAIL_MIMEPART_CRLF;
+            if ($encoded['body'] == '') {
+                $encoded['body'] = '--' . $boundary . MAIL_MIMEPART_CRLF .
+                                   '--' . $boundary . '--' . MAIL_MIMEPART_CRLF;
+
+            } else {
+                $encoded['body'] = rtrim($encoded['body'], MAIL_MIMEPART_CRLF) . MAIL_MIMEPART_CRLF . '--' . $boundary . '--' . MAIL_MIMEPART_CRLF;
+            }
 
         } else {
             $encoded['body'] = $this->_getEncodedData($this->_body, $this->_encoding);