|  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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: sblackstone at gmail dot com
New email:
PHP Version: OS:


 [2008-07-11 15:26 UTC] sblackstone at gmail dot com
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.


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



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

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


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2008-07-15 02:11 UTC]
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 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: Mon Nov 29 01:03:14 2021 UTC