php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | |
Patch udate-in-imap-overview-r2 for *General Issues Bug #35638Patch version 2010-03-10 20:53 UTC Return to Bug #35638 | Download this patchThis patch renders other patches obsolete Obsolete patches: Patch Revisions:Developer: Charles_Duffy@dell.comdiff --git a/ext/imap/php_imap.c b/ext/imap/php_imap.c index 5e47510..5432d84 100644 --- a/ext/imap/php_imap.c +++ b/ext/imap/php_imap.c @@ -3420,6 +3420,7 @@ PHP_FUNCTION(imap_fetch_overview) 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); } } diff --git a/ext/imap/tests/imap_fetch_overview_basic.phpt b/ext/imap/tests/imap_fetch_overview_basic.phpt index 2b4623f..83fab12 100644 --- a/ext/imap/tests/imap_fetch_overview_basic.phpt +++ b/ext/imap/tests/imap_fetch_overview_basic.phpt @@ -23,28 +23,11 @@ $stream_id = setup_test_mailbox('', 2, $mailbox, 'notSimple'); $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 @@ $a = imap_fetch_overview($stream_id, '1:2') ; //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 @@ answered is 0 deleted is 0 seen is 0 draft is 0 +udate is OK -- Mandatory arguments -- @@ -104,6 +80,7 @@ answered is 0 deleted is 0 seen is 0 draft is 0 +udate is OK --> Object #2 size is %d @@ -115,4 +92,5 @@ answered is 0 deleted is 0 seen is 0 draft is 0 +udate is OK ===DONE=== diff --git a/ext/imap/tests/imap_fetch_overview_variation2.phpt b/ext/imap/tests/imap_fetch_overview_variation2.phpt index 8634cef..086885f 100644 --- a/ext/imap/tests/imap_fetch_overview_variation2.phpt +++ b/ext/imap/tests/imap_fetch_overview_variation2.phpt @@ -22,20 +22,6 @@ require_once(dirname(__FILE__).'/imap_include.inc'); // 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 @@ foreach($inputs as $input) { 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 @@ answered is 0 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 @@ answered is 0 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 @@ answered is 0 deleted is 0 seen is 0 draft is 0 +udate is OK -- Testing with second argument value: bool(false) Sequence out of range diff --git a/ext/imap/tests/imap_fetch_overview_variation5.phpt b/ext/imap/tests/imap_fetch_overview_variation5.phpt index d5bc888..5feeedb 100644 --- a/ext/imap/tests/imap_fetch_overview_variation5.phpt +++ b/ext/imap/tests/imap_fetch_overview_variation5.phpt @@ -22,19 +22,6 @@ require_once(dirname(__FILE__).'/imap_include.inc'); $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 @@ foreach($sequences as $msg_no) { } 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 @@ answered is 0 deleted is 0 seen is 0 draft is 0 +udate is OK -- $msg_no is 1,3 -- @@ -101,6 +85,7 @@ answered is 0 deleted is 0 seen is 0 draft is 0 +udate is OK size is %d uid is %d @@ -111,6 +96,7 @@ answered is 0 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 @@ answered is 0 deleted is 0 seen is 0 draft is 0 +udate is OK size is %d uid is %d @@ -136,6 +123,7 @@ answered is 0 deleted is 0 seen is 0 draft is 0 +udate is OK size is %d uid is %d @@ -146,4 +134,5 @@ answered is 0 deleted is 0 seen is 0 draft is 0 +udate is OK ===DONE=== diff --git a/ext/imap/tests/imap_fetch_overview_variation6.phpt b/ext/imap/tests/imap_fetch_overview_variation6.phpt index 6ee65f6..bdf0557 100644 --- a/ext/imap/tests/imap_fetch_overview_variation6.phpt +++ b/ext/imap/tests/imap_fetch_overview_variation6.phpt @@ -22,30 +22,13 @@ require_once(dirname(__FILE__).'/imap_include.inc'); $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 @@ answered is 0 deleted is 0 seen is 0 draft is 0 +udate is OK ===DONE=== diff --git a/ext/imap/tests/imap_include.inc b/ext/imap/tests/imap_include.inc index 3f98454..ed36239 100644 --- a/ext/imap/tests/imap_include.inc +++ b/ext/imap/tests/imap_include.inc @@ -9,10 +9,56 @@ $password = 'p4ssw0rd'; $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 |
Copyright © 2001-2024 The PHP Group All rights reserved. |
Last updated: Sat Nov 23 10:01:28 2024 UTC |