From 59943dc3ee86a5693a30c75c40c802d8964604e5 Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Thu, 18 Apr 2019 15:43:01 +0200 Subject: [PATCH] LSsearchEntry : Fix 'unknwon property error' on accessing undefined attribute --- public_html/includes/class/class.LSsearch.php | 13 ++++++++++++- public_html/includes/class/class.LSsearchEntry.php | 8 ++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/public_html/includes/class/class.LSsearch.php b/public_html/includes/class/class.LSsearch.php index 85b7e0b7..d429ba90 100644 --- a/public_html/includes/class/class.LSsearch.php +++ b/public_html/includes/class/class.LSsearch.php @@ -835,7 +835,18 @@ class LSsearch { $this -> _searchParams = $retval; } - + + /** + * Get search attributes + * + * @retval array The attributes asked in this search + **/ + public function getAttributes() { + if (!$this -> _searchParams) + $this -> generateSearchParams(); + return $this -> _searchParams['attributes']; + } + /** * Run the search * diff --git a/public_html/includes/class/class.LSsearchEntry.php b/public_html/includes/class/class.LSsearchEntry.php index fed80c6a..92801c8a 100644 --- a/public_html/includes/class/class.LSsearchEntry.php +++ b/public_html/includes/class/class.LSsearchEntry.php @@ -42,6 +42,9 @@ class LSsearchEntry { // The hash of the search parameters private $hash = NULL; + // The attributes list + private $attrs_list=array(); + // The attributes values private $attrs=array(); @@ -69,6 +72,7 @@ class LSsearchEntry { $this -> params = $params; $this -> id = $id; $this -> dn =& $result[$id]['dn']; + $this -> attrs_list = $LSsearch -> getAttributes(); $this -> attrs =& $result[$id]['attrs']; $this -> cache =& $result[$id]['cache']; } @@ -227,8 +231,8 @@ class LSsearchEntry { $this -> cache[$key] = $ret; return $ret; } - elseif (in_array($key,array_keys($this -> attrs))) { - return $this -> attrs[$key]; + elseif (in_array($key,array_keys($this -> attrs_list))) { + return (isset($this -> attrs[$key])?$this -> attrs[$key]:null); } elseif (array_key_exists($key,$this->params['customInfos'])) { if(isset($this -> cache['customInfos'][$key])) {