php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #45487 imap_getsubscribed clobbers attributes
Submitted: 2008-07-11 15:26 UTC Modified: 2008-07-15 13:08 UTC
From: sblackstone at gmail dot com Assigned:
Status: Not a bug Package: IMAP related
PHP Version: 5.2.6 OS: OSX Leopard
Private report: No CVE-ID: None
 [2008-07-11 15:26 UTC] sblackstone at gmail dot com
Description:
------------
The documentation for imap_getsubscribed notes the following:

Identical to imap_getmailboxes(), except that it only returns mailboxes that the user is subscribed to. 


However getsubscribed clobbers the attributes value and returns 0.

Reproduce code:
---------------
<?

$imap   = imap_open("{localhost:143/notls}","username","password");

$results_bad = imap_getSubscribed($imap, "{localhost:143/notls}", "*");

// Note: I just picked an arbitrary mailbox in the results items below
// You need to pick a value that has children or just print the whole
// array.

print_r($results_bad[1]);

$results_good = imap_getmailboxes($imap, "{localhost:143/notls}", "*");

print_r($results_good[1]);


?>



Expected result:
----------------
stdClass Object
(
    [name] => {localhost:143/notls}SOMEMAILBOX
    [attributes] => 64
    [delimiter] => .
)


Actual result:
--------------
stdClass Object
(
    [name] => {localhost:143/notls}SOMEMAILBOX
    [attributes] => 0
    [delimiter] => .
)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-07-15 02:11 UTC] jani@php.net
From sources:

 add_property_long(mboxob, "attributes", cur->attributes);

As you can see, PHP only adds whatever the UW imap c-client has set the attributes to. Not PHP bug -> bogus.
 [2008-07-15 13:08 UTC] sblackstone at gmail dot com
Thanks for looking at this.. I did a little more research and tracked it all the way through the client libraries.  According to RFC 3501

"
The returned untagged LSUB response MAY contain different mailbox
flags from a LIST untagged response.  If this should happen, the
flags in the untagged LIST are considered more authoritative.
"

And in fact, the case of my server it does not reply with attributes when using LSUB while it does with LIST.


The documentation for this on php.net currently reads "Identical to imap_getmailboxes(), except that it only returns mailboxes that the user is subscribed to." 

This leaves the impressions that this function just returns a subset of the output of the full list and hides this RFC nuance.


Since the RFC specifically states that the attributes in LIST are authoritative and thoose in LSUB are not, my suggestion is that we  make a second call to LIST (which by the RFC MUST be an extremely fast call) and populate the attributes of the LSUB return with the attributes from the LIST call.  This would make the function consistent with its documentation.

Barring that, I would suggest that the documentation be revised so that it does not use language like "identical" which leads to developer confusion.
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sun Nov 28 21:03:16 2021 UTC