Home » Networking » Net_LDAP » Bug #4589
Net_LDAP_Entry->delete() does not work with empty array type attributes
Details
| Submitted | 2005-06-14 13:29 UTC |
|---|---|
| From | pkremer at spurious dot biz |
| Assigned | jw |
| Status | Closed |
| Package | Net_LDAP |
| PHP Version | 4.3.10 |
| OS | Linux 2.4 |
| Roadmaps | (Not assigned) |
Comments
[2005-06-14 13:29 UTC] pkremer at spurious dot biz
Description:
------------
usually, when you want to delete all attributes without considering their value for an LDAP_Entry object, you will specify an empty array as attribute in native PHP ldap method ldap_mod_del().
However, the Net_LDAP_Entry::delete() method does not recognize the empty array as a valid option for saying "regardless of the value" and does not pass it on to the native PHP ldap methods. Instead, it will revert to the meaning "delete only specified values" and thus not enable the deletion of some attributes on some server implementations.
The patch is pretty straightforward an listed below.
Reproduce code:
---------------
--- Net/LDAP/Entry.php.orig 2005-06-14 14:38:47.000000000 +0200
+++ Net/LDAP/Entry.php 2005-06-14 15:19:45.000000000 +0200
@@ -416,9 +416,9 @@
if ($this->exists ($k)) {
// if v is a null, then remove the whole attribute, else only the value.
- if ($v == '') {
+ if ($v == '' || (is_array($v) && count($v) == 0 ) ) {
unset($this->_attrs[$k]);
- $this->_delAttrs[$k] = "";
+ $this->_delAttrs[$k] = $v;
// else we remove only the correct value.
} else {
for ($i = 0;$i< $this->_attrs[$k]['count'];$i++) {