diff options
| author | Moritz Strohm <strohm@data-quest.de> | 2022-09-28 12:32:56 +0000 |
|---|---|---|
| committer | Moritz Strohm <strohm@data-quest.de> | 2022-09-28 12:32:56 +0000 |
| commit | 9e13d2f5fa4726b54efe8ad046d0b53aadb543bf (patch) | |
| tree | b8fc0583b685de64575feca2cd4efe2663586d74 /lib/classes/TreeAbstract.class.php | |
| parent | 0d56653e17a283d918c6e4cb41468de1990e0331 (diff) | |
fix for BIESt #1104
Merge request studip/studip!674
Diffstat (limited to 'lib/classes/TreeAbstract.class.php')
| -rw-r--r-- | lib/classes/TreeAbstract.class.php | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/classes/TreeAbstract.class.php b/lib/classes/TreeAbstract.class.php index b06cbcd..dc96820 100644 --- a/lib/classes/TreeAbstract.class.php +++ b/lib/classes/TreeAbstract.class.php @@ -112,7 +112,7 @@ class TreeAbstract { } else { $class_hash = $class_name; } - if (!is_object($tree_instance[$class_hash]) || $invalidate_cache){ + if (empty($tree_instance[$class_hash]) || $invalidate_cache){ $tree_instance[$class_hash] = new $class_name($args); } @@ -162,7 +162,10 @@ class TreeAbstract { $this->tree_data[$item_id]["priority"] = $priority; $this->tree_data[$item_id]["name"] = $name; $this->tree_childs[$parent_id][] = $item_id; - ++$this->tree_num_childs[$parent_id]; + if (empty($this->tree_num_childs[$parent_id])) { + $this->tree_num_childs[$parent_id] = 0; + } + $this->tree_num_childs[$parent_id]++; return; } @@ -213,7 +216,7 @@ class TreeAbstract { public function getNumKids($item_id) { if(!isset($this->tree_num_childs[$item_id])){ - $this->tree_num_childs[$item_id] = (is_array($this->tree_childs[$item_id])) ? count($this->tree_childs[$item_id]) : 0; + $this->tree_num_childs[$item_id] = (!empty($this->tree_childs[$item_id]) && is_array($this->tree_childs[$item_id])) ? count($this->tree_childs[$item_id]) : 0; } return $this->tree_num_childs[$item_id]; } |
