6.0.0-alpha14
7/2/25

[#14097] PHP WARNING in Horde_Imap_Client_Socket::listMailbox
Summary PHP WARNING in Horde_Imap_Client_Socket::listMailbox
Queue Horde Framework Packages
Type Bug
State Resolved
Priority 1. Low
Owners mrubinsk (at) horde (dot) org
Requester nicolas.vanheu (at) gmail (dot) com
Created 09/01/2015 (3592 days ago)
Due
Updated 09/02/2015 (3591 days ago)
Assigned
Resolved 09/02/2015 (3591 days ago)
Github Issue Link
Github Pull Request
Milestone
Patch No

History
09/02/2015 08:10:21 PM Michael Rubinsky Assigned to Michael Rubinsky
State ⇒ Resolved
Priority ⇒ 1. Low
 
09/02/2015 08:08:52 PM Git Commit Comment #3 Reply to this comment
Changes have been made in Git (master):

commit 865fd1dc815d02e1fe9c933f10421dad08420307
Author: Michael J Rubinsky <mrubinsk@horde.org>
Date:   Wed Sep 2 16:08:02 2015 -0400

     Bug: 14097 - This is only needed if we have LIST-STATUS as well.

  .../Imap_Client/lib/Horde/Imap/Client/Socket.php   |    2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)

http://github.com/horde/horde/commit/865fd1dc815d02e1fe9c933f10421dad08420307
09/01/2015 06:54:26 PM nicolas (dot) vanheu (at) gmail (dot) com Comment #2 Reply to this comment
Stacktrace :

HP   7. Horde_Imap_Client_Base->listMailboxes() 
/srv/kronos/crm/modules/Mail/Tool/DeliverMail.inc.php:368
PHP   8. Horde_Imap_Client_Socket->_listMailboxes() 
/srv/kronos/crm/vendor/pear-pear.horde.org/Horde_Imap_Client/Horde/Imap/Client/Base.php:1404
PHP   9. Horde_Imap_Client_Socket->_getMailboxList() 
/srv/kronos/crm/vendor/pear-pear.horde.org/Horde_Imap_Client/Horde/Imap/Client/Socket.php:1375
PHP  10. Horde_Imap_Client_Socket->_prepareStatusResponse() 
/srv/kronos/crm/vendor/pear-pear.horde.org/Horde_Imap_Client/Horde/Imap/Client/Socket.php:1542))
   msg 17/17 (718 bytes), delivery error (command tool 16042 error (1, 
ERROR Error during HTTP deliver mail : PHP Warning:  Invalid argument 
supplied for foreach() in 
/srv/kronos/crm/vendor/pear-pear.horde.org/Horde_Imap_Client/Horde/Imap/Client/Socket.php on line 
1793

[Show Quoted Text - 42 lines]
09/01/2015 06:53:25 PM nicolas (dot) vanheu (at) gmail (dot) com Comment #1
Priority ⇒ 2. Medium
Patch ⇒ No
Milestone ⇒
Queue ⇒ Horde Framework Packages
Summary ⇒ PHP WARNING in Horde_Imap_Client_Socket::listMailbox
Type ⇒ Bug
State ⇒ Unconfirmed
Reply to this comment
Calling Horde_Imap_Client_Socket::listMailboxes($dest_mailbox, 
Horde_Imap_Client::MBOX_ALL, ['status' => 
Horde_Imap_Client::STATUS_MESSAGES | Horde_Imap_Client::STATUS_UNSEEN 
| Horde_Imap_Client::STATUS_UIDNEXT]); when the imap server does not 
have the capability LIST-STATUS ($this->_capability('LIST-STATUS') 
returns false) raise a php warning.

Simple fix would be to initialize $status_opts = array(); before the if.

Revelant piece of code :
/* LIST-STATUS does NOT depend on LIST-EXTENDED. */
         if (!empty($options['status']) &&
             $this->_capability('LIST-STATUS')) {
             $available_status = array(
                 Horde_Imap_Client::STATUS_MESSAGES,
                 Horde_Imap_Client::STATUS_RECENT,
                 Horde_Imap_Client::STATUS_UIDNEXT,
                 Horde_Imap_Client::STATUS_UIDVALIDITY,
                 Horde_Imap_Client::STATUS_UNSEEN,
                 Horde_Imap_Client::STATUS_HIGHESTMODSEQ
             );

             $status_opts = array();
             foreach (array_intersect($this->_statusFields, 
$available_status) as $key => $val) {
                 if ($options['status'] & $val) {
                     $status_opts[] = $key;
                 }
             }

             if (count($status_opts)) {
                 $return_opts->add(array(
                     'STATUS',
                     new Horde_Imap_Client_Data_Format_List(
                         array_map('Horde_String::upper', $status_opts)
                     )
                 ));
             }
         }

Tested with courier-imap.

Saved Queries