繁体   English   中英

达到最大功能嵌套级别“ 415”,正在中止

[英]Maximum function nesting level of '415' reached, aborting

当我将嵌套级别设置为超过415时,它给出错误页面不起作用并将其设置为400,然后给出错误达到“ 415”的最大功能嵌套级别,正在中止!

function actionIndex(){
    $limit = 1000;
    ini_set('xdebug.max_nesting_level', $limit);
    $queryTopics = "SELECT tr.id,tr.`parent_id`, tr.`child_id`, tr.`order_by`, tr.`level`, tr.`child_id` AS `tid`, t.`name`,t.`seo_name`
                    FROM `topic_relations` tr
                    LEFT JOIN `topics` t ON tr.`child_id` = t.`id`
                    WHERE t.`status` = 1";
    $topicss = \Yii::$app->db->createCommand($queryTopics)->queryAll();
    $topics = array();
    foreach ($topicss as $key => $value) {
        $parentIdCombination = $this->findAllParent($value['id']);
        $combination = array_reverse($parentIdCombination);
        $combinations = implode($combination, ' ');
        $topics['parent_combination'] = $combinations;
        unset($combination);
        $topics[] = $value;
    }
    $data['topicsParentChildArr'] = $this->buildTopicsTree($topics);
    echo '<pre>';
    print_r($topics);
    return $this->render('index',['data'=>$data]);
}

该函数递归调用

function findAllParent($id) {
    global $combination;
    $parentTopicQuery =  "SELECT * FROM `topic_relations` where id=".$id;
    $topic_row = \Yii::$app->db->createCommand($parentTopicQuery)->queryOne();

    if($topic_row['level']>0) {
        $combination[] = $topic_row['child_id'];
        $parentTopicQuery1 =  "SELECT * FROM `topic_relations` where child_id=".$topic_row['parent_id'];
        $topic_row1 = \Yii::$app->db->createCommand($parentTopicQuery)->queryOne();
        $this->findAllParent($topic_row1['id']);
    }else {
        $combination[] = $topic_row['child_id'];
    }
    //var_dump($combination);
    return $combination;
}

PHP中没有这样的限制。 最大函数嵌套级别是xdebug扩展的限制。

如果您希望/需要增加它,只需更改php.ini设置xdebug.max_nesting_level 即您可以使用2000

xdebug.max_nesting_level = 2000

我不得不提到,这仅适用于您的开发服务器。 在生产环境中,永远不要安装xdebug扩展。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM