Bug #79165 [Opn->Fbk]: trying to access ldap_get_entries array triggers: Trying to access array offset

From: Date: Fri, 24 Jan 2020 13:07:39 +0000
Subject: Bug #79165 [Opn->Fbk]: trying to access ldap_get_entries array triggers: Trying to access array offset
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-225096@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=79165&edit=1

 ID:                 79165
 Updated by:         cmb@php.net
 Reported by:        mbiebl at messageconcept dot com
 Summary:            trying to access ldap_get_entries array triggers:
                     Trying to access array offset
-Status:             Open
+Status:             Feedback
 Type:               Bug
 Package:            LDAP related
 PHP Version:        7.4.2
 Block user comment: N
 Private report:     N

 New Comment:

Could you please post the relevant code (and show the reported
line number)?


Previous Comments:
------------------------------------------------------------------------
[2020-01-24 12:28:07] mbiebl at messageconcept dot com

Hm, right. I guess I need to explicitly skip the "count" element now which is part of the
$result array.

foreach (array_slice($entries, 1) as $e) { .. }

appears to work. Not sure if this is the cleanest solution though. WDYT?

------------------------------------------------------------------------
[2020-01-24 12:05:41] nikic@php.net

foreach does not trigger this notice. Please check the reported line number carefully. It must
involve something like "$array[$offset]".

------------------------------------------------------------------------
[2020-01-24 11:55:25] mbiebl at messageconcept dot com

Description:
------------
I have the following code

$result = ldap_search($con, $dn, $filter, $justthese);
$entries = ldap_get_entries($con, $result);

and then the following code to iterate through the results

foreach ($entries as $e) { ... }

This code worked fine with 7.3 and now yields the following error with 7.4:
"Trying to access array offset on value of type resource"

ldap_get_entries() is supposed to return an array and var_dump($entries) prints
array(11) {
  ["count"]=>
  int(10)
  [0]=>
 ....
}

So something is at odds here. Why does PHP 7.4 think $entries is not an array?





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



--
Edit this bug report at https://bugs.php.net/bug.php?id=79165&edit=1


Thread (8 messages)

« previous php.bugs (#225096) next »