diff options
author | Dries Buytaert <dries@buytaert.net> | 2009-04-17 19:59:51 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2009-04-17 19:59:51 +0000 |
commit | 669d112af565365862c4f5e5123bcc003a7f97a8 (patch) | |
tree | 32e7f74d07db2dd24a7b85dbc25de2d58c69e324 /modules | |
parent | 9179976227e4c5c6aaf2b92641b377c1de95b42a (diff) | |
download | brdo-669d112af565365862c4f5e5123bcc003a7f97a8.tar.gz brdo-669d112af565365862c4f5e5123bcc003a7f97a8.tar.bz2 |
- Patch #239945 by JeremyFrench: moved depth check out of loop.
Diffstat (limited to 'modules')
-rw-r--r-- | modules/taxonomy/taxonomy.module | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/modules/taxonomy/taxonomy.module b/modules/taxonomy/taxonomy.module index 5682d0e82..9df49b13f 100644 --- a/modules/taxonomy/taxonomy.module +++ b/modules/taxonomy/taxonomy.module @@ -983,19 +983,16 @@ function taxonomy_get_tree($vid, $parent = 0, $max_depth = NULL, $depth = -1) { $max_depth = (is_null($max_depth)) ? count($children[$vid]) : $max_depth; $tree = array(); - if (!empty($children[$vid][$parent])) { + if ($max_depth > $depth && !empty($children[$vid][$parent])) { foreach ($children[$vid][$parent] as $child) { - if ($max_depth > $depth) { - $term = clone $terms[$vid][$child]; - $term->depth = $depth; - // The "parent" attribute is not useful, as it would show one parent only. - unset($term->parent); - $term->parents = $parents[$vid][$child]; - $tree[] = $term; - - if (!empty($children[$vid][$child])) { - $tree = array_merge($tree, taxonomy_get_tree($vid, $child, $max_depth, $depth)); - } + $term = clone $terms[$vid][$child]; + $term->depth = $depth; + // The "parent" attribute is not useful, as it would show one parent only. + unset($term->parent); + $term->parents = $parents[$vid][$child]; + $tree[] = $term; + if (!empty($children[$vid][$child])) { + $tree = array_merge($tree, taxonomy_get_tree($vid, $child, $max_depth, $depth)); } } } |