FAQ
Edit report at https://pear.php.net/bugs/bug.php?id=19506&edit=1

ID: 19506
Comment by: pear.php@feystorm.net
Reported By: pear dot php@feystorm.net
Summary: Net_LDAP2_Search shiftEntry() errors when no entries
were found
Status: Open
Type: Bug
Package: Net_LDAP2
Operating System: RHEL5
Package Version: 2.0.12
PHP Version: 5.2.14
Roadmap Versions:
New Comment:

Attached is a patch which fixes the issue with shiftEntry() and
entries()


Previous Comments:
------------------------------------------------------------------------

[2012-07-12 03:06:29] feystorm

Added #patch
bug:19506;patch:Net_LDAP2-shiftEntry.patch;revision:1342058789;.

------------------------------------------------------------------------

[2012-07-12 03:01:02] feystorm

Description:
------------
When Net_LDAP2_Search shiftEntry() is called, if there were
no entries returned as a result of the search a PEAR_Error
object is returned.
From looking at the source, its intended to return a `false`
when an error is encountered. However this is failing because
the error class is PEAR_Error instead of Net_LDAP2_Error.

Additionally shiftEntry() is called by
Net_LDAP2_Search::entries(). The entries function doesn't
properly check for a `false` return value from shiftEntry(), so
even if this were to work properly, entries() would return an
array with a single element of `false`.

Test script:
---------------
$search = $ldap->search('dc=example,dc=com',
'(objectClass=noSuchClass)');
print_r($search->entries());

Expected result:
----------------
Array
(
)

Actual result:
--------------
Array
(
[0] => PEAR_Error Object ........
)

------------------------------------------------------------------------

Search Discussions

  • Pear Php at Jul 12, 2012 at 1:17 am
    Edit report at https://pear.php.net/bugs/bug.php?id=19506&edit=1

    ID: 19506
    Comment by: pear.php@feystorm.net
    Reported By: pear dot php@feystorm.net
    Summary: Net_LDAP2_Search shiftEntry() errors when no entries
    were found
    Status: Open
    Type: Bug
    Package: Net_LDAP2
    Operating System: RHEL5
    Package Version: 2.0.12
    PHP Version: 5.2.14
    Roadmap Versions:
    New Comment:

    Previous patch was bad. Had an "I'm an idiot" moment. The behavior of
    the entries() function was correct since the while() loop would have
    never evaluated.

    Sorry :-)


    Previous Comments:
    ------------------------------------------------------------------------

    [2012-07-12 03:22:44] feystorm

    Added #patch
    bug:19506;patch:Net_LDAP2-shiftEntry.patch;revision:1342059764;.

    ------------------------------------------------------------------------

    [2012-07-12 03:07:02] feystorm

    Attached is a patch which fixes the issue with shiftEntry() and
    entries()

    ------------------------------------------------------------------------

    [2012-07-12 03:06:29] feystorm

    Added #patch
    bug:19506;patch:Net_LDAP2-shiftEntry.patch;revision:1342058789;.

    ------------------------------------------------------------------------

    [2012-07-12 03:01:02] feystorm

    Description:
    ------------
    When Net_LDAP2_Search shiftEntry() is called, if there were
    no entries returned as a result of the search a PEAR_Error
    object is returned.
    From looking at the source, its intended to return a `false`
    when an error is encountered. However this is failing because
    the error class is PEAR_Error instead of Net_LDAP2_Error.

    Additionally shiftEntry() is called by
    Net_LDAP2_Search::entries(). The entries function doesn't
    properly check for a `false` return value from shiftEntry(), so
    even if this were to work properly, entries() would return an
    array with a single element of `false`.

    Test script:
    ---------------
    $search = $ldap->search('dc=example,dc=com',
    '(objectClass=noSuchClass)');
    print_r($search->entries());

    Expected result:
    ----------------
    Array
    (
    )

    Actual result:
    --------------
    Array
    (
    [0] => PEAR_Error Object ........
    )

    ------------------------------------------------------------------------

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppear-bugs @
categoriesphp
postedJul 12, '12 at 1:00a
activeJul 12, '12 at 1:17a
posts2
users1
websitepear.php.net

1 user in discussion

Pear Php: 2 posts

People

Translate

site design / logo © 2022 Grokbase