From 8e7e22c656c7c08050d45c9e1b7375a9e03da728 Mon Sep 17 00:00:00 2001 From: dsoares Date: Mon, 27 Jun 2016 12:44:59 +0100 Subject: [PATCH] Avoid PHP fatal error After last change to file `rcube_ldap.php`, my roundcube instance was getting this error: ``` PHP Fatal error: Cannot use object of type Net_LDAP3_Result as array in ... ``` In ```php protected function extended_search($count = false) ``` `$result = $this->ldap->search()` returns a LDAP object (whatever package we use). If the search returns no results (and if `$is_extended_search` is false), then it gets to line 971 trying to do a `usort()` and then a `count()` on an object, instead of an array. --- program/lib/Roundcube/rcube_ldap.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/program/lib/Roundcube/rcube_ldap.php b/program/lib/Roundcube/rcube_ldap.php index 548f1b5ee..999bfee89 100644 --- a/program/lib/Roundcube/rcube_ldap.php +++ b/program/lib/Roundcube/rcube_ldap.php @@ -932,7 +932,7 @@ class rcube_ldap extends rcube_addressbook $result = $this->ldap->search($base_dn, $prop['filter'], $prop['scope'], $attrs, $prop, $count); // we have a search result resource, get all entries - if (!$count && $result && $result->count() > 0) { + if (!$count && $result) { $result = $result->entries(); unset($result['count']); }