From 8ac181831fe8323c270bd8ad91604798cb92bd3f Mon Sep 17 00:00:00 2001 From: PHAS Developer <110562019+phasdev@users.noreply.github.com> Date: Sat, 4 May 2024 06:25:40 +0000 Subject: [PATCH] Fix exception thrown during `LDAP_MODIFY_BATCH_REMOVE_ALL` batch operations --- .../Ldap/Adapter/ExtLdap/UpdateOperation.php | 9 +++++++-- .../Tests/Adapter/ExtLdap/LdapManagerTest.php | 17 +++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Ldap/Adapter/ExtLdap/UpdateOperation.php b/src/Symfony/Component/Ldap/Adapter/ExtLdap/UpdateOperation.php index cb57c1d6296ea..dc98896ab82e6 100644 --- a/src/Symfony/Component/Ldap/Adapter/ExtLdap/UpdateOperation.php +++ b/src/Symfony/Component/Ldap/Adapter/ExtLdap/UpdateOperation.php @@ -48,10 +48,15 @@ public function __construct(int $operationType, string $attribute, ?array $value public function toArray(): array { - return [ + $op = [ 'attrib' => $this->attribute, 'modtype' => $this->operationType, - 'values' => $this->values, ]; + + if (\LDAP_MODIFY_BATCH_REMOVE_ALL !== $this->operationType) { + $op['values'] = $this->values; + } + + return $op; } } diff --git a/src/Symfony/Component/Ldap/Tests/Adapter/ExtLdap/LdapManagerTest.php b/src/Symfony/Component/Ldap/Tests/Adapter/ExtLdap/LdapManagerTest.php index f849b4bf25f23..21737afda3c2a 100644 --- a/src/Symfony/Component/Ldap/Tests/Adapter/ExtLdap/LdapManagerTest.php +++ b/src/Symfony/Component/Ldap/Tests/Adapter/ExtLdap/LdapManagerTest.php @@ -266,6 +266,23 @@ public function testLdapAddAttributeValuesError() $entryManager->addAttributeValues($entry, 'mail', $entry->getAttribute('mail')); } + public function testLdapApplyOperationsRemoveAll() + { + $entryManager = $this->adapter->getEntryManager(); + + $result = $this->executeSearchQuery(1); + $entry = $result[0]; + + $entryManager->applyOperations($entry->getDn(), [new UpdateOperation(\LDAP_MODIFY_BATCH_REMOVE_ALL, 'mail', null)]); + + $result = $this->executeSearchQuery(1); + $entry = $result[0]; + + $this->assertNull($entry->getAttribute('mail')); + + $entryManager->addAttributeValues($entry, 'mail', ['fabpot@symfony.com', 'fabien@potencier.com']); + } + public function testLdapApplyOperationsRemoveAllWithArrayError() { $entryManager = $this->adapter->getEntryManager(); pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy