Skip to content

Commit 5859c58

Browse files
phasdevfabpot
authored andcommitted
Fix exception thrown during LDAP_MODIFY_BATCH_REMOVE_ALL batch operations
1 parent f18f4d2 commit 5859c58

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

Adapter/ExtLdap/UpdateOperation.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,15 @@ public function __construct(int $operationType, string $attribute, ?array $value
4848

4949
public function toArray(): array
5050
{
51-
return [
51+
$op = [
5252
'attrib' => $this->attribute,
5353
'modtype' => $this->operationType,
54-
'values' => $this->values,
5554
];
55+
56+
if (\LDAP_MODIFY_BATCH_REMOVE_ALL !== $this->operationType) {
57+
$op['values'] = $this->values;
58+
}
59+
60+
return $op;
5661
}
5762
}

Tests/Adapter/ExtLdap/LdapManagerTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,23 @@ public function testLdapAddAttributeValuesError()
266266
$entryManager->addAttributeValues($entry, 'mail', $entry->getAttribute('mail'));
267267
}
268268

269+
public function testLdapApplyOperationsRemoveAll()
270+
{
271+
$entryManager = $this->adapter->getEntryManager();
272+
273+
$result = $this->executeSearchQuery(1);
274+
$entry = $result[0];
275+
276+
$entryManager->applyOperations($entry->getDn(), [new UpdateOperation(\LDAP_MODIFY_BATCH_REMOVE_ALL, 'mail', null)]);
277+
278+
$result = $this->executeSearchQuery(1);
279+
$entry = $result[0];
280+
281+
$this->assertNull($entry->getAttribute('mail'));
282+
283+
$entryManager->addAttributeValues($entry, 'mail', ['fabpot@symfony.com', 'fabien@potencier.com']);
284+
}
285+
269286
public function testLdapApplyOperationsRemoveAllWithArrayError()
270287
{
271288
$entryManager = $this->adapter->getEntryManager();

0 commit comments

Comments
 (0)