These changes don't (although I realize you shouldn't just take my word for it) break the functionality of imap_headerinfo(). It just is a streamlined way of doing it.
The function as it stands does a mail_fetchheader_full(), takes the result of that, and turns it into an envelope object. Afterwards, it has to free that object. The c-client provides a way to get just the envelope with mail_fetchenvelope(). It is beneficial to use this for a few reasons: 1. As you can see it makes the code much simpler 2. It is faster. For each message you don't have to fetch full headers and turn them into an envelope object. You can simply just get the envelope object. 3. Simpler for the IMAP server. Instead of making it do a BODY.PEEK, it just has to fetch the envelope (which some IMAP servers cache). Adam On Wed, 2002-04-24 at 14:33, Jani Taskinen wrote: > > What was this patch supposed to do again? > At first glance it looks like it's modifying the > imap_headerinfo() function quite dramatically and > propably breaks it too.. > > Have you compared the output of this function without > this patch and with it and does it return the same kind > of object? (and send patches as attachements..) > > --Jani
Index: php_imap.c =================================================================== RCS file: /repository/php4/ext/imap/php_imap.c,v retrieving revision 1.113 diff -u -r1.113 php_imap.c --- php_imap.c 24 Apr 2002 15:29:52 -0000 1.113 +++ php_imap.c 24 Apr 2002 19:06:04 -0000 @@ -1567,10 +1567,9 @@ { zval **streamind, **msgno, **fromlength, **subjectlength, **defaulthost; pils *imap_le_struct; - unsigned long length; MESSAGECACHE *cache; ENVELOPE *en; - char *mystring, dummy[2000], fulladdress[MAILTMPLEN]; + char dummy[2000], fulladdress[MAILTMPLEN]; int myargc = ZEND_NUM_ARGS(); if (myargc < 2 || myargc > 5 || zend_get_parameters_ex(myargc, &streamind, &msgno, &fromlength, &subjectlength, &defaulthost) == FAILURE) { @@ -1605,13 +1604,8 @@ RETURN_FALSE; } - mystring = mail_fetchheader_full(imap_le_struct->imap_stream, Z_LVAL_PP(msgno), NIL, &length, NIL); - if (myargc == 5) { - rfc822_parse_msg(&en, NULL, mystring, length, NULL, Z_STRVAL_PP(defaulthost), NIL); - } else { - rfc822_parse_msg(&en, NULL, mystring, length, NULL, "UNKNOWN", NIL); - } - + en = mail_fetchenvelope(imap_le_struct->imap_stream, Z_LVAL_PP(msgno)); + /* call a function to parse all the text, so that we can use the same function to parse text from other sources */ _php_make_header_object(return_value, en TSRMLS_CC); @@ -1646,7 +1640,6 @@ mail_fetchsubject(fulladdress, imap_le_struct->imap_stream, Z_LVAL_PP(msgno), Z_LVAL_PP(subjectlength)); add_property_string(return_value, "fetchsubject", fulladdress, 1); } - mail_free_envelope(&en); } /* }}} */
-- PHP Development Mailing List <http://www.php.net/> To unsubscribe, visit: http://www.php.net/unsub.php