Commit 669d112a authored by Dries's avatar Dries

- Patch #239945 by JeremyFrench: moved depth check out of loop.

parent 91799762
...@@ -983,22 +983,19 @@ function taxonomy_get_tree($vid, $parent = 0, $max_depth = NULL, $depth = -1) { ...@@ -983,22 +983,19 @@ function taxonomy_get_tree($vid, $parent = 0, $max_depth = NULL, $depth = -1) {
$max_depth = (is_null($max_depth)) ? count($children[$vid]) : $max_depth; $max_depth = (is_null($max_depth)) ? count($children[$vid]) : $max_depth;
$tree = array(); $tree = array();
if (!empty($children[$vid][$parent])) { if ($max_depth > $depth && !empty($children[$vid][$parent])) {
foreach ($children[$vid][$parent] as $child) { foreach ($children[$vid][$parent] as $child) {
if ($max_depth > $depth) {
$term = clone $terms[$vid][$child]; $term = clone $terms[$vid][$child];
$term->depth = $depth; $term->depth = $depth;
// The "parent" attribute is not useful, as it would show one parent only. // The "parent" attribute is not useful, as it would show one parent only.
unset($term->parent); unset($term->parent);
$term->parents = $parents[$vid][$child]; $term->parents = $parents[$vid][$child];
$tree[] = $term; $tree[] = $term;
if (!empty($children[$vid][$child])) { if (!empty($children[$vid][$child])) {
$tree = array_merge($tree, taxonomy_get_tree($vid, $child, $max_depth, $depth)); $tree = array_merge($tree, taxonomy_get_tree($vid, $child, $max_depth, $depth));
} }
} }
} }
}
return $tree; return $tree;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment