From 0c996dfa116b8c2adeb274adf7f218149b87e3ff Mon Sep 17 00:00:00 2001
From: valleet01 <thibaut.vallee@unicaen.fr>
Date: Thu, 21 Mar 2024 11:36:51 +0100
Subject: [PATCH] fixe pour php>=8.1 : ldap_get_attibutes ne prend plus une
 ressources mais une LDAP\Connection

---
 src/UnicaenLdap/Service/AbstractService.php | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/UnicaenLdap/Service/AbstractService.php b/src/UnicaenLdap/Service/AbstractService.php
index 55eb49d..d46c820 100644
--- a/src/UnicaenLdap/Service/AbstractService.php
+++ b/src/UnicaenLdap/Service/AbstractService.php
@@ -323,21 +323,20 @@ abstract class AbstractService implements
 
     /**
      * Retourne un tableau d'attributs
-     *
-     * @param resource $resource
+     * @param resource|\Ldap\Connection $resource
      * @param resource $entry
      * @return null|array
-     */
+     * @desc depuis php 8.1 $resource est de type Ldap\Connection
+ */
     private function __getEntryAttributes($resource, $entry)
     {
-        if (!is_resource($resource)) {
-            return null;
-        }
 
-        $berIdentifier = null;
+        if (!is_resource($resource) && !$resource instanceof \Ldap\Connection) {
+        return null;
+        }
 
         $name = ldap_first_attribute(
-            $resource, $entry//, $berIdentifier
+            $resource, $entry
         );
 
         $attributes = array();
@@ -359,7 +358,7 @@ abstract class AbstractService implements
             $attributes[$attrName] = $data;
 
             $name = ldap_next_attribute(
-                $resource, $entry//, $berIdentifier
+                $resource, $entry
             );
         }
         ksort($attributes, SORT_LOCALE_STRING);
-- 
GitLab