LSsearchEntry : Fix 'unknwon property error' on accessing undefined attribute

This commit is contained in:
Benjamin Renard 2019-04-18 15:43:01 +02:00
parent 059b72958b
commit 59943dc3ee
2 changed files with 18 additions and 3 deletions

View file

@ -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
*

View file

@ -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])) {