Bug #19503 [Ver->Csd]: Net_LDAP2_Entry getValue returns empty string when no attributes present
| From: | beni@php.net | Date: | Thu, 03 Jan 2013 08:32:07 +0000 |
| Subject: | Bug #19503 [Ver->Csd]: Net_LDAP2_Entry getValue returns empty string when no attributes present | ||
| References: | 1 | Groups: | php.pear.bugs |
| Request: | Send a blank email to pear-bugs+get-9443@lists.php.net to get a copy of this message | ||
Edit report at https://pear.php.net/bugs/bug.php?id=19503&edit=1
ID: 19503
Updated by: beni@php.net
Reported By: pear dot php at feystorm dot net
Summary: Net_LDAP2_Entry getValue returns empty string when no
attributes present
-Status: Verified
+Status: Closed
Type: Bug
Package: Net_LDAP2
Package Version: 2.0.12
PHP Version: 5.2.14
-Assigned To:
+Assigned To: beni
-Roadmap Versions:
+Roadmap Versions: 2.1.0
New Comment:
-Status: Verified
+Status: Closed
-Assigned To:
+Assigned To: beni
-Roadmap Versions:
+Roadmap Versions: 2.1.0
This bug has been fixed in SVN.
If this was a documentation problem, the fix will appear on pear.php.net
by the end of next Sunday (CET).
If this was a problem with the pear.php.net website, the change should
be live shortly.
Otherwise, the fix will appear in the package's next release.
Thank you for the report and for helping us make PEAR better.
Previous Comments:
------------------------------------------------------------------------
[2013-01-03 08:12:41] beni
-Status: Open
+Status: Verified
Hello,
thank you for the contribution. Of course you are right and i will
incorporate your patch soon.
Thank you very much for providing code!
------------------------------------------------------------------------
[2012-07-12 02:25:07] feystorm
I've attached a patch which fixes the issue.
It also changes the behavior of the getValue() function to not shift the
value off the internal values array. This is just to make the behavior
consistent with perl's Net::LDAP as it doesn't do that. It's also
arguably good behavior as subsequent calls to getValue should return the
same data. It should be called
shiftValue if it's going to shift().
------------------------------------------------------------------------
[2012-07-12 02:21:52] feystorm
Added #patch
bug:19503;patch:Net_LDAP2-get_value.patch;revision:1342056112;.
------------------------------------------------------------------------
[2012-07-11 22:19:07] feystorm
Description:
------------
When performing getValue for an attribute which does not
exist, the return value is an empty string (in the case of
$option = 'single') or an array with a single element of an
empty string (in the case of $option = 'all').
This is bad behavior for a few reasons.
1) it complicates being able to do foreach loops over the
return value as now you have to test for an empty string
2) some LDAP servers can return an empty string as an
attribute value which makes it impossible to tell the difference
between no values, and an empty value (without having to call
the exists function)
3) Net_LDAP2 is supposed to be a port with similar behavior to
perl's Net::LDAP, this is not how Net::LDAP behaves
In the case of $option = 'all', it should either return an empty
array, false, or null
For $option = 'single' it should return false or null.
Expected result:
----------------
# for an entry which has no foo attribute:
$entry->getValue('foo', 'all') === array();
$entry->getValue('foo', 'single') === false;
Actual result:
--------------
# for an entry which has no foo attribute:
$entry->getValue('foo', 'all') === array("");
$entry->getValue('foo', 'single') === "";
------------------------------------------------------------------------
--
Edit this bug report at https://pear.php.net/bugs/bug.php?id=19503&edit=1