From c4df29afb0fcc2611b8d0b48b2d8b3994ee72d28 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Mon, 29 Oct 2018 13:21:02 +0100 Subject: [PATCH] remove unneeded empty search attribute values, fixes #12086 Signed-off-by: Arthur Schiwon --- apps/user_ldap/lib/User/Manager.php | 7 +++++++ apps/user_ldap/tests/User/ManagerTest.php | 7 ++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/apps/user_ldap/lib/User/Manager.php b/apps/user_ldap/lib/User/Manager.php index 4a770102a7..6352007257 100644 --- a/apps/user_ldap/lib/User/Manager.php +++ b/apps/user_ldap/lib/User/Manager.php @@ -197,6 +197,13 @@ class Manager { ); } + // remove possible empty attributes + $attributes = array_values( + array_filter($attributes, function ($attributeName) { + return !empty($attributeName); + }) + ); + return $attributes; } diff --git a/apps/user_ldap/tests/User/ManagerTest.php b/apps/user_ldap/tests/User/ManagerTest.php index 5399aa95a6..104a70ff70 100644 --- a/apps/user_ldap/tests/User/ManagerTest.php +++ b/apps/user_ldap/tests/User/ManagerTest.php @@ -256,12 +256,17 @@ class ManagerTest extends \Test\TestCase { $manager->setLdapAccess($access); $connection = $access->getConnection(); - $connection->setConfiguration(['ldapEmailAttribute' => 'mail', 'ldapUserAvatarRule' => 'default']); + $connection->setConfiguration([ + 'ldapEmailAttribute' => 'mail', + 'ldapUserAvatarRule' => 'default', + 'ldapQuotaAttribute' => '', + ]); $attributes = $manager->getAttributes($minimal); $this->assertTrue(in_array('dn', $attributes)); $this->assertTrue(in_array($access->getConnection()->ldapEmailAttribute, $attributes)); + $this->assertFalse(in_array('', $attributes)); $this->assertSame(!$minimal, in_array('jpegphoto', $attributes)); $this->assertSame(!$minimal, in_array('thumbnailphoto', $attributes)); }