From f6586c7cf76f2f5f6fed243f54e43ad2c08337b8 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Tue, 19 May 2020 07:57:35 +0200 Subject: [PATCH] Fix PHP warning: count(): Parameter must be an array or an object... in ID command handler (#7392) --- CHANGELOG | 1 + program/lib/Roundcube/rcube_imap_generic.php | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 47fb3abe2..7da0f8720 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -30,6 +30,7 @@ CHANGELOG Roundcube Webmail - Password: Fix issue with Modoboa driver (#7372) - Mailvelope: Use sender's address to find pubkeys to check signatures (#7348) - Mailvelope: Fix Encrypt button hidden in Elastic (#7353) +- Fix PHP warning: count(): Parameter must be an array or an object... in ID command handler (#7392) RELEASE 1.4.4 ------------- diff --git a/program/lib/Roundcube/rcube_imap_generic.php b/program/lib/Roundcube/rcube_imap_generic.php index 67131f1fc..84dc7b120 100644 --- a/program/lib/Roundcube/rcube_imap_generic.php +++ b/program/lib/Roundcube/rcube_imap_generic.php @@ -1743,7 +1743,7 @@ class rcube_imap_generic * * @param array $items Client identification information key/value hash * - * @return array Server identification information key/value hash + * @return array|false Server identification information key/value hash, False on error * @since 0.6 */ public function id($items = array()) @@ -1762,10 +1762,12 @@ class rcube_imap_generic if ($code == self::ERROR_OK && $response) { $response = substr($response, 5); // remove prefix "* ID " $items = $this->tokenizeResponse($response, 1); - $result = null; + $result = array(); - for ($i=0, $len=count($items); $i<$len; $i += 2) { - $result[$items[$i]] = $items[$i+1]; + if (is_array($items)) { + for ($i=0, $len=count($items); $i<$len; $i += 2) { + $result[$items[$i]] = $items[$i+1]; + } } return $result;