Recursion limit problem

Created on 24 August 2012, over 12 years ago
Updated 5 September 2023, over 1 year ago

Found a problem when adapting the code for another use. The logic that limits recursion depth doesn't seem to be right. The if() should wrap the foreach(). Something like this:

    $query_result = db_query($sql, array(':mlid'=>$mlid) );
    $this_level = array(
      'nid' => $nid,
      'title' => $title,
    );
    $current_recusion_level++;
    if ( $current_recusion_level <= $max_recusion_level ){
      foreach ( $query_result as $child ) {
        $this_level['children'][] = _dolfinity_book_blocks_make_tree($child->mlid,$child->nid,$child->title,$current_recusion_level,$max_recusion_level);
      }
    }
    return $this_level;

(This is an English version that doesn't render, of course.)

💬 Support request
Status

Closed: outdated

Version

1.0

Component

Code

Created by

🇺🇸United States mathieso

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024