From 943f2576c578d556ee6e5fa77bfef16ab8efb515 Mon Sep 17 00:00:00 2001 From: Daniel Kesselberg Date: Sat, 24 Nov 2018 22:06:45 +0100 Subject: [PATCH 1/2] Fix count on string Signed-off-by: Daniel Kesselberg --- apps/user_ldap/lib/Access.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/apps/user_ldap/lib/Access.php b/apps/user_ldap/lib/Access.php index fb2582e82662f..c5075a033b678 100644 --- a/apps/user_ldap/lib/Access.php +++ b/apps/user_ldap/lib/Access.php @@ -879,7 +879,7 @@ public function fetchListOfUsers($filter, $attr, $limit = null, $offset = null, }); } $this->batchApplyUserAttributes($recordsToUpdate); - return $this->fetchList($ldapRecords, count($attr) > 1); + return $this->fetchList($ldapRecords, $this->manyAttributes($attr)); } /** @@ -922,7 +922,7 @@ public function batchApplyUserAttributes(array $ldapRecords){ * @return array */ public function fetchListOfGroups($filter, $attr, $limit = null, $offset = null) { - return $this->fetchList($this->searchGroups($filter, $attr, $limit, $offset), count($attr) > 1); + return $this->fetchList($this->searchGroups($filter, $attr, $limit, $offset), $this->manyAttributes($attr)); } /** @@ -2011,4 +2011,17 @@ private function initPagedSearch($filter, $bases, $attr, $limit, $offset) { return $pagedSearchOK; } + /** + * Is more than one $attr used for search? + * + * @param string|string[]|null $attr + * @return bool + */ + private function manyAttributes($attr) { + if (\is_array($attr)) { + return \count($attr) > 1; + } + return false; + } + } From d0f341b355df7c8e54deb7c107082baffb93fa4f Mon Sep 17 00:00:00 2001 From: Daniel Kesselberg Date: Sun, 25 Nov 2018 12:30:54 +0100 Subject: [PATCH 2/2] Add return type Signed-off-by: Daniel Kesselberg --- apps/user_ldap/lib/Access.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/user_ldap/lib/Access.php b/apps/user_ldap/lib/Access.php index c5075a033b678..82947bd68687f 100644 --- a/apps/user_ldap/lib/Access.php +++ b/apps/user_ldap/lib/Access.php @@ -2017,7 +2017,7 @@ private function initPagedSearch($filter, $bases, $attr, $limit, $offset) { * @param string|string[]|null $attr * @return bool */ - private function manyAttributes($attr) { + private function manyAttributes($attr): bool { if (\is_array($attr)) { return \count($attr) > 1; }