pajoye Wed, 14 Apr 2010 09:45:37 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=297983
Log: - #35638, add udate to imap_fetch_overview Bug: http://bugs.php.net/35638 (Open) Adding udate to imap_fetch_overview results? Changed paths: U php/php-src/branches/PHP_5_3/NEWS U php/php-src/branches/PHP_5_3/ext/imap/php_imap.c U php/php-src/branches/PHP_5_3/ext/imap/tests/imap_fetch_overview_basic.phpt U php/php-src/branches/PHP_5_3/ext/imap/tests/imap_fetch_overview_variation2.phpt U php/php-src/branches/PHP_5_3/ext/imap/tests/imap_fetch_overview_variation5.phpt U php/php-src/branches/PHP_5_3/ext/imap/tests/imap_fetch_overview_variation6.phpt U php/php-src/branches/PHP_5_3/ext/imap/tests/imap_include.inc U php/php-src/trunk/ext/imap/php_imap.c U php/php-src/trunk/ext/imap/tests/imap_fetch_overview_basic.phpt U php/php-src/trunk/ext/imap/tests/imap_fetch_overview_variation2.phpt U php/php-src/trunk/ext/imap/tests/imap_fetch_overview_variation5.phpt U php/php-src/trunk/ext/imap/tests/imap_fetch_overview_variation6.phpt U php/php-src/trunk/ext/imap/tests/imap_include.inc
Modified: php/php-src/branches/PHP_5_3/NEWS =================================================================== --- php/php-src/branches/PHP_5_3/NEWS 2010-04-14 07:17:56 UTC (rev 297982) +++ php/php-src/branches/PHP_5_3/NEWS 2010-04-14 09:45:37 UTC (rev 297983) @@ -68,7 +68,10 @@ - Fixed bug #48902 (Timezone database fallback map is outdated). (Derick) - Fixed bug #46111 (Some timezone identifiers can not be parsed). (Derick) - Fixed bug #35673 (formatOutput does not work with saveHTML). (Rob) +- Implement feature request #35638 (Adding udate to imap_fetch_overview results). + (Charles_Duffy at dell dot com ) + ?? ??? 20??, PHP 5.3.2 - Upgraded bundled sqlite to version 3.6.22. (Ilia) - Upgraded bundled libmagic to version 5.03. (Mikko) Modified: php/php-src/branches/PHP_5_3/ext/imap/php_imap.c =================================================================== --- php/php-src/branches/PHP_5_3/ext/imap/php_imap.c 2010-04-14 07:17:56 UTC (rev 297982) +++ php/php-src/branches/PHP_5_3/ext/imap/php_imap.c 2010-04-14 09:45:37 UTC (rev 297983) @@ -3420,6 +3420,7 @@ add_property_long(myoverview, "deleted", elt->deleted); add_property_long(myoverview, "seen", elt->seen); add_property_long(myoverview, "draft", elt->draft); + add_property_long(myoverview, "udate", mail_longdate(elt)); add_next_index_object(return_value, myoverview TSRMLS_CC); } } Modified: php/php-src/branches/PHP_5_3/ext/imap/tests/imap_fetch_overview_basic.phpt =================================================================== --- php/php-src/branches/PHP_5_3/ext/imap/tests/imap_fetch_overview_basic.phpt 2010-04-14 07:17:56 UTC (rev 297982) +++ php/php-src/branches/PHP_5_3/ext/imap/tests/imap_fetch_overview_basic.phpt 2010-04-14 09:45:37 UTC (rev 297983) @@ -23,28 +23,11 @@ $msg_no = imap_uid($stream_id, 1); $options = FT_UID; -//Set mandatory response fields -$mandatoryFields = array( - 'size', - 'uid', - 'msgno', - 'recent', - 'flagged', - 'answered', - 'deleted', - 'seen', - 'draft', - ); - // Calling imap_fetch_overview() with all possible arguments echo "\n-- All possible arguments --\n"; $a = imap_fetch_overview($stream_id, "$msg_no", $options) ; echo "\n--> Object #1\n"; -foreach ($mandatoryFields as $mf) -{ - $z = $a[0]->$mf; - echo "$mf is $z\n"; -} +displayOverviewFields($a[0]); // Calling imap_fetch_overview() with mandatory arguments echo "\n-- Mandatory arguments --\n"; @@ -52,19 +35,11 @@ //first object in array echo "\n--> Object #1\n"; -foreach ($mandatoryFields as $mf) -{ - $z = $a[0]->$mf; - echo "$mf is $z\n"; -} +displayOverviewFields($a[0]); //Second object in array echo "\n--> Object #2\n"; -foreach ($mandatoryFields as $mf) -{ - $z = $a[1]->$mf; - echo "$mf is $z\n"; -} +displayOverviewFields($a[1]); imap_close($stream_id); @@ -91,6 +66,7 @@ deleted is 0 seen is 0 draft is 0 +udate is OK -- Mandatory arguments -- @@ -104,6 +80,7 @@ deleted is 0 seen is 0 draft is 0 +udate is OK --> Object #2 size is %d @@ -115,4 +92,5 @@ deleted is 0 seen is 0 draft is 0 +udate is OK ===DONE=== Modified: php/php-src/branches/PHP_5_3/ext/imap/tests/imap_fetch_overview_variation2.phpt =================================================================== --- php/php-src/branches/PHP_5_3/ext/imap/tests/imap_fetch_overview_variation2.phpt 2010-04-14 07:17:56 UTC (rev 297982) +++ php/php-src/branches/PHP_5_3/ext/imap/tests/imap_fetch_overview_variation2.phpt 2010-04-14 09:45:37 UTC (rev 297983) @@ -22,20 +22,6 @@ // Initialise function arguments not being substituted $stream_id = setup_test_mailbox('', 1, $mailbox, 'notSimple'); // set up temp mailbox with 1 msg -//Set mandatory response fields -$mandatoryFields = array( - 'size', - 'uid', - 'msgno', - 'recent', - 'flagged', - 'answered', - 'deleted', - 'seen', - 'draft', - ); - - //get an unset variable $unset_var = 10; unset ($unset_var); @@ -114,11 +100,7 @@ if (!$overview) { echo imap_last_error() . "\n"; } else { - foreach ($mandatoryFields as $mf) - { - $z = $overview[0]->$mf; - echo "$mf is $z\n"; - } + displayOverviewFields($overview[0]); } $iterator++; }; @@ -151,6 +133,7 @@ deleted is 0 seen is 0 draft is 0 +udate is OK -- Testing with second argument value: int(12345) Sequence out of range @@ -189,6 +172,7 @@ deleted is 0 seen is 0 draft is 0 +udate is OK -- Testing with second argument value: bool(false) Sequence out of range @@ -203,6 +187,7 @@ deleted is 0 seen is 0 draft is 0 +udate is OK -- Testing with second argument value: bool(false) Sequence out of range Modified: php/php-src/branches/PHP_5_3/ext/imap/tests/imap_fetch_overview_variation5.phpt =================================================================== --- php/php-src/branches/PHP_5_3/ext/imap/tests/imap_fetch_overview_variation5.phpt 2010-04-14 07:17:56 UTC (rev 297982) +++ php/php-src/branches/PHP_5_3/ext/imap/tests/imap_fetch_overview_variation5.phpt 2010-04-14 09:45:37 UTC (rev 297983) @@ -22,19 +22,6 @@ $stream_id = setup_test_mailbox('', 3, $mailbox, 'notSimple'); // set up temp mailbox with 3 msgs -//Set mandatory response fields -$mandatoryFields = array( - 'size', - 'uid', - 'msgno', - 'recent', - 'flagged', - 'answered', - 'deleted', - 'seen', - 'draft', - ); - $sequences = array (0, 4, '4', // out of range '2', '1,3', '1, 2', '1:3'); // pass uid without setting FT_UID option @@ -47,11 +34,7 @@ } else { foreach($overview as $ov) { echo "\n"; - foreach ($mandatoryFields as $mf) - { - $z = $ov->$mf; - echo "$mf is $z\n"; - } + displayOverviewFields($ov); } } } @@ -89,6 +72,7 @@ deleted is 0 seen is 0 draft is 0 +udate is OK -- $msg_no is 1,3 -- @@ -101,6 +85,7 @@ deleted is 0 seen is 0 draft is 0 +udate is OK size is %d uid is %d @@ -111,6 +96,7 @@ deleted is 0 seen is 0 draft is 0 +udate is OK -- $msg_no is 1, 2 -- Syntax error in sequence @@ -126,6 +112,7 @@ deleted is 0 seen is 0 draft is 0 +udate is OK size is %d uid is %d @@ -136,6 +123,7 @@ deleted is 0 seen is 0 draft is 0 +udate is OK size is %d uid is %d @@ -146,4 +134,5 @@ deleted is 0 seen is 0 draft is 0 +udate is OK ===DONE=== Modified: php/php-src/branches/PHP_5_3/ext/imap/tests/imap_fetch_overview_variation6.phpt =================================================================== --- php/php-src/branches/PHP_5_3/ext/imap/tests/imap_fetch_overview_variation6.phpt 2010-04-14 07:17:56 UTC (rev 297982) +++ php/php-src/branches/PHP_5_3/ext/imap/tests/imap_fetch_overview_variation6.phpt 2010-04-14 09:45:37 UTC (rev 297983) @@ -22,30 +22,13 @@ $stream_id = setup_test_mailbox('', 0, $mailbox); // setup temp mailbox create_multipart_message($stream_id, $mailbox); -//Set mandatory response fields -$mandatoryFields = array( - 'size', - 'uid', - 'msgno', - 'recent', - 'flagged', - 'answered', - 'deleted', - 'seen', - 'draft', - ); - // refresh msg numbers imap_check($stream_id); $msg_no = 1; $a = imap_fetch_overview($stream_id, $msg_no); echo "\n--> Object #1\n"; -foreach ($mandatoryFields as $mf) -{ - $z = $a[0]->$mf; - echo "$mf is $z\n"; -} +displayOverviewFields($a[0]); @@ -122,4 +105,5 @@ deleted is 0 seen is 0 draft is 0 +udate is OK ===DONE=== Modified: php/php-src/branches/PHP_5_3/ext/imap/tests/imap_include.inc =================================================================== --- php/php-src/branches/PHP_5_3/ext/imap/tests/imap_include.inc 2010-04-14 07:17:56 UTC (rev 297982) +++ php/php-src/branches/PHP_5_3/ext/imap/tests/imap_include.inc 2010-04-14 09:45:37 UTC (rev 297983) @@ -9,10 +9,56 @@ $users = array("webmaster", "info", "admin", "foo"); // tests require 4 valid userids $mailbox_prefix = "phpttest"; // name used for test mailbox +// record test start time (used by displayOverviewFields()) +$start_time = time(); + +// list of fields to expect +$mandatory_overview_fields = array( + 'size', + 'uid', + 'msgno', + 'recent', + 'flagged', + 'answered', + 'deleted', + 'seen', + 'draft', + 'udate', + ); + /** + * Display all fields in an element from an imap_fetch_overview() response + * + * Special handling for 'udate', which will vary run-to-run; assumes an IMAP + * server with its clock synced to the current system, which is consistent with + * setup instructions in ext/imap/tests/README + * + * @param array resp element from the return value of imap_fetch_overview() + */ +function displayOverviewFields($resp, $fields=null) { + global $mandatory_overview_fields; + global $start_time; + + foreach ($fields ? $fields : $mandatory_overview_fields as $mf) + { + $z = $resp->$mf; + if ($mf == 'udate') { + if (($z >= $start_time) && ($z <= time())) { + echo "$mf is OK\n"; + } else { + echo "$mf is BAD ($z)\n"; + } + } else { + echo "$mf is $z\n"; + } + } +} + + +/** * Create a test mailbox and populate with msgs * - * @para, string mailbox_suffix Suffix used to uniquely identify mailboxes + * @param string mailbox_suffix Suffix used to uniquely identify mailboxes * @param int message_count number of test msgs to be written to new mailbox * * @return IMAP stream to new mailbox on sucesss; FALSE on failure Modified: php/php-src/trunk/ext/imap/php_imap.c =================================================================== --- php/php-src/trunk/ext/imap/php_imap.c 2010-04-14 07:17:56 UTC (rev 297982) +++ php/php-src/trunk/ext/imap/php_imap.c 2010-04-14 09:45:37 UTC (rev 297983) @@ -3420,6 +3420,7 @@ add_property_long(myoverview, "deleted", elt->deleted); add_property_long(myoverview, "seen", elt->seen); add_property_long(myoverview, "draft", elt->draft); + add_property_long(myoverview, "udate", mail_longdate(elt)); add_next_index_object(return_value, myoverview TSRMLS_CC); } } Modified: php/php-src/trunk/ext/imap/tests/imap_fetch_overview_basic.phpt =================================================================== --- php/php-src/trunk/ext/imap/tests/imap_fetch_overview_basic.phpt 2010-04-14 07:17:56 UTC (rev 297982) +++ php/php-src/trunk/ext/imap/tests/imap_fetch_overview_basic.phpt 2010-04-14 09:45:37 UTC (rev 297983) @@ -23,28 +23,11 @@ $msg_no = imap_uid($stream_id, 1); $options = FT_UID; -//Set mandatory response fields -$mandatoryFields = array( - 'size', - 'uid', - 'msgno', - 'recent', - 'flagged', - 'answered', - 'deleted', - 'seen', - 'draft', - ); - // Calling imap_fetch_overview() with all possible arguments echo "\n-- All possible arguments --\n"; $a = imap_fetch_overview($stream_id, "$msg_no", $options) ; echo "\n--> Object #1\n"; -foreach ($mandatoryFields as $mf) -{ - $z = $a[0]->$mf; - echo "$mf is $z\n"; -} +displayOverviewFields($a[0]); // Calling imap_fetch_overview() with mandatory arguments echo "\n-- Mandatory arguments --\n"; @@ -52,19 +35,11 @@ //first object in array echo "\n--> Object #1\n"; -foreach ($mandatoryFields as $mf) -{ - $z = $a[0]->$mf; - echo "$mf is $z\n"; -} +displayOverviewFields($a[0]); //Second object in array echo "\n--> Object #2\n"; -foreach ($mandatoryFields as $mf) -{ - $z = $a[1]->$mf; - echo "$mf is $z\n"; -} +displayOverviewFields($a[1]); imap_close($stream_id); @@ -91,6 +66,7 @@ deleted is 0 seen is 0 draft is 0 +udate is OK -- Mandatory arguments -- @@ -104,6 +80,7 @@ deleted is 0 seen is 0 draft is 0 +udate is OK --> Object #2 size is %d @@ -115,4 +92,5 @@ deleted is 0 seen is 0 draft is 0 +udate is OK ===DONE=== Modified: php/php-src/trunk/ext/imap/tests/imap_fetch_overview_variation2.phpt =================================================================== --- php/php-src/trunk/ext/imap/tests/imap_fetch_overview_variation2.phpt 2010-04-14 07:17:56 UTC (rev 297982) +++ php/php-src/trunk/ext/imap/tests/imap_fetch_overview_variation2.phpt 2010-04-14 09:45:37 UTC (rev 297983) @@ -22,20 +22,6 @@ // Initialise function arguments not being substituted $stream_id = setup_test_mailbox('', 1, $mailbox, 'notSimple'); // set up temp mailbox with 1 msg -//Set mandatory response fields -$mandatoryFields = array( - 'size', - 'uid', - 'msgno', - 'recent', - 'flagged', - 'answered', - 'deleted', - 'seen', - 'draft', - ); - - //get an unset variable $unset_var = 10; unset ($unset_var); @@ -114,11 +100,7 @@ if (!$overview) { echo imap_last_error() . "\n"; } else { - foreach ($mandatoryFields as $mf) - { - $z = $overview[0]->$mf; - echo "$mf is $z\n"; - } + displayOverviewFields($overview[0]); } $iterator++; }; @@ -151,6 +133,7 @@ deleted is 0 seen is 0 draft is 0 +udate is OK -- Testing with second argument value: int(12345) Sequence out of range @@ -189,6 +172,7 @@ deleted is 0 seen is 0 draft is 0 +udate is OK -- Testing with second argument value: bool(false) Sequence out of range @@ -203,6 +187,7 @@ deleted is 0 seen is 0 draft is 0 +udate is OK -- Testing with second argument value: bool(false) Sequence out of range Modified: php/php-src/trunk/ext/imap/tests/imap_fetch_overview_variation5.phpt =================================================================== --- php/php-src/trunk/ext/imap/tests/imap_fetch_overview_variation5.phpt 2010-04-14 07:17:56 UTC (rev 297982) +++ php/php-src/trunk/ext/imap/tests/imap_fetch_overview_variation5.phpt 2010-04-14 09:45:37 UTC (rev 297983) @@ -22,19 +22,6 @@ $stream_id = setup_test_mailbox('', 3, $mailbox, 'notSimple'); // set up temp mailbox with 3 msgs -//Set mandatory response fields -$mandatoryFields = array( - 'size', - 'uid', - 'msgno', - 'recent', - 'flagged', - 'answered', - 'deleted', - 'seen', - 'draft', - ); - $sequences = array (0, 4, '4', // out of range '2', '1,3', '1, 2', '1:3'); // pass uid without setting FT_UID option @@ -47,11 +34,7 @@ } else { foreach($overview as $ov) { echo "\n"; - foreach ($mandatoryFields as $mf) - { - $z = $ov->$mf; - echo "$mf is $z\n"; - } + displayOverviewFields($ov); } } } @@ -89,6 +72,7 @@ deleted is 0 seen is 0 draft is 0 +udate is OK -- $msg_no is 1,3 -- @@ -101,6 +85,7 @@ deleted is 0 seen is 0 draft is 0 +udate is OK size is %d uid is %d @@ -111,6 +96,7 @@ deleted is 0 seen is 0 draft is 0 +udate is OK -- $msg_no is 1, 2 -- Syntax error in sequence @@ -126,6 +112,7 @@ deleted is 0 seen is 0 draft is 0 +udate is OK size is %d uid is %d @@ -136,6 +123,7 @@ deleted is 0 seen is 0 draft is 0 +udate is OK size is %d uid is %d @@ -146,4 +134,5 @@ deleted is 0 seen is 0 draft is 0 +udate is OK ===DONE=== Modified: php/php-src/trunk/ext/imap/tests/imap_fetch_overview_variation6.phpt =================================================================== --- php/php-src/trunk/ext/imap/tests/imap_fetch_overview_variation6.phpt 2010-04-14 07:17:56 UTC (rev 297982) +++ php/php-src/trunk/ext/imap/tests/imap_fetch_overview_variation6.phpt 2010-04-14 09:45:37 UTC (rev 297983) @@ -22,30 +22,13 @@ $stream_id = setup_test_mailbox('', 0, $mailbox); // setup temp mailbox create_multipart_message($stream_id, $mailbox); -//Set mandatory response fields -$mandatoryFields = array( - 'size', - 'uid', - 'msgno', - 'recent', - 'flagged', - 'answered', - 'deleted', - 'seen', - 'draft', - ); - // refresh msg numbers imap_check($stream_id); $msg_no = 1; $a = imap_fetch_overview($stream_id, $msg_no); echo "\n--> Object #1\n"; -foreach ($mandatoryFields as $mf) -{ - $z = $a[0]->$mf; - echo "$mf is $z\n"; -} +displayOverviewFields($a[0]); @@ -122,4 +105,5 @@ deleted is 0 seen is 0 draft is 0 +udate is OK ===DONE=== Modified: php/php-src/trunk/ext/imap/tests/imap_include.inc =================================================================== --- php/php-src/trunk/ext/imap/tests/imap_include.inc 2010-04-14 07:17:56 UTC (rev 297982) +++ php/php-src/trunk/ext/imap/tests/imap_include.inc 2010-04-14 09:45:37 UTC (rev 297983) @@ -9,10 +9,56 @@ $users = array("webmaster", "info", "admin", "foo"); // tests require 4 valid userids $mailbox_prefix = "phpttest"; // name used for test mailbox +// record test start time (used by displayOverviewFields()) +$start_time = time(); + +// list of fields to expect +$mandatory_overview_fields = array( + 'size', + 'uid', + 'msgno', + 'recent', + 'flagged', + 'answered', + 'deleted', + 'seen', + 'draft', + 'udate', + ); + /** + * Display all fields in an element from an imap_fetch_overview() response + * + * Special handling for 'udate', which will vary run-to-run; assumes an IMAP + * server with its clock synced to the current system, which is consistent with + * setup instructions in ext/imap/tests/README + * + * @param array resp element from the return value of imap_fetch_overview() + */ +function displayOverviewFields($resp, $fields=null) { + global $mandatory_overview_fields; + global $start_time; + + foreach ($fields ? $fields : $mandatory_overview_fields as $mf) + { + $z = $resp->$mf; + if ($mf == 'udate') { + if (($z >= $start_time) && ($z <= time())) { + echo "$mf is OK\n"; + } else { + echo "$mf is BAD ($z)\n"; + } + } else { + echo "$mf is $z\n"; + } + } +} + + +/** * Create a test mailbox and populate with msgs * - * @para, string mailbox_suffix Suffix used to uniquely identify mailboxes + * @param string mailbox_suffix Suffix used to uniquely identify mailboxes * @param int message_count number of test msgs to be written to new mailbox * * @return IMAP stream to new mailbox on sucesss; FALSE on failure
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php