Fatal error maximum function nesting level of 100 reached aborting in

I have made a function that finds all the URLs within an html file and repeats the same process for each html content linked to the discovered URLs. The function is recursive and can go on endlessly.

I have made a function that finds all the URLs within an html file and repeats the same process for each html content linked to the discovered URLs. The function is recursive and can go on endlessly. However, I have put a limit on the recursion by setting a global variable which causes the recursion to stop after 100 recursions.

However, php returns this error:

Fatal error: Maximum function nesting level of ‘100’ reached,
aborting! in
D:wampwwwcrawler1simplehtmldom_1_5simple_html_dom.php on line
1355

ERROR

I found a solution here: Increasing nesting function calls limit but this is not working in my case.

I am quoting one of the answers from the link mentioned above. Please do consider it.

«Do you have Zend, IonCube, or xDebug installed? If so, that is probably where you are getting this error from.

I ran into this a few years ago, and it ended up being Zend putting that limit there, not PHP. Of course removing it will let >you go past the 100 iterations, but you will eventually hit the memory limits.»

Is there a way to increase the maximum function nesting level in PHP

Community's user avatar

asked Dec 28, 2011 at 12:46

Rafay's user avatar

6

Increase the value of xdebug.max_nesting_level in your php.ini

Mohammad's user avatar

Mohammad

20.8k15 gold badges53 silver badges82 bronze badges

answered May 9, 2012 at 8:08

Maxence's user avatar

MaxenceMaxence

12.8k5 gold badges56 silver badges68 bronze badges

7

A simple solution solved my problem. I just commented this line:

zend_extension = "d:/wamp/bin/php/php5.3.8/zend_ext/php_xdebug-2.1.2-5.3-vc9.dll

in my php.ini file. This extension was limiting the stack to 100 so I disabled it. The recursive function is now working as anticipated.

Bram's user avatar

Bram

2,4656 gold badges38 silver badges57 bronze badges

answered Dec 29, 2011 at 11:41

Rafay's user avatar

RafayRafay

6,04811 gold badges50 silver badges70 bronze badges

8

Another solution is to add xdebug.max_nesting_level = 200 in your php.ini

answered Jun 25, 2013 at 11:50

bacar ndiaye's user avatar

4

Rather than going for a recursive function calls, work with a queue model to flatten the structure.

$queue = array('http://example.com/first/url');
while (count($queue)) {
    $url = array_shift($queue);

    $queue = array_merge($queue, find_urls($url));
}

function find_urls($url)
{
    $urls = array();

    // Some logic filling the variable

    return $urls;
}

There are different ways to handle it. You can keep track of more information if you need some insight about the origin or paths traversed. There are also distributed queues that can work off a similar model.

answered Dec 28, 2011 at 13:18

Louis-Philippe Huberdeau's user avatar

3

Rather than disabling the xdebug, you can set the higher limit like

xdebug.max_nesting_level=500

answered Mar 13, 2014 at 15:59

shahinam's user avatar

shahinamshahinam

6805 silver badges6 bronze badges

2

It’s also possible to fix this directly in php, for example in the config file of your project.

ini_set('xdebug.max_nesting_level', 200);

answered Oct 19, 2015 at 15:08

svassr's user avatar

svassrsvassr

5,4585 gold badges44 silver badges63 bronze badges

2

Go into your php.ini configuration file and change the following line:

xdebug.max_nesting_level=100

to something like:

xdebug.max_nesting_level=200

answered Nov 23, 2015 at 15:11

Yasssine ELALAOUI's user avatar

on Ubuntu using PHP 5.59 :
got to `:

/etc/php5/cli/conf.d

and find your xdebug.ini in that dir, in my case is 20-xdebug.ini

and add this line `

xdebug.max_nesting_level = 200

or this

xdebug.max_nesting_level = -1

set it to -1 and you dont have to worry change the value of the nesting level.

`

answered Apr 6, 2016 at 1:45

Gujarat Santana's user avatar

Gujarat SantanaGujarat Santana

9,58917 gold badges51 silver badges74 bronze badges

probably happened because of xdebug.

Try commenting the following line in your «php.ini» and restart your server to reload PHP.

  ";xdebug.max_nesting_level"

e-sushi's user avatar

e-sushi

13.5k10 gold badges36 silver badges57 bronze badges

answered Jul 25, 2013 at 1:32

vandersondf's user avatar

vandersondfvandersondf

7791 gold badge7 silver badges8 bronze badges

3

Try looking in /etc/php5/conf.d/ to see if there is a file called xdebug.ini

max_nesting_level is 100 by default

If it is not set in that file add:

xdebug.max_nesting_level=300

to the end of the list so it looks like this

xdebug.remote_enable=on
xdebug.remote_handler=dbgp
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.profiler_enable=0
xdebug.profiler_enable_trigger=1
xdebug.profiler_output_dir=/home/drupalpro/websites/logs/profiler
xdebug.max_nesting_level=300

you can then use @Andrey’s test before and after making this change to see if worked.

php -r 'function foo() { static $x = 1; echo "foo ", $x++, "n"; foo(); } foo();'

Community's user avatar

answered Mar 6, 2014 at 17:35

Lee Woodman's user avatar

Lee WoodmanLee Woodman

1,3192 gold badges16 silver badges30 bronze badges

1

php.ini:

xdebug.max_nesting_level = -1

I’m not entirely sure if the value will ever overflow and reach -1, but it’ll either never reach -1, or it’ll set the max_nesting_level pretty high.

answered Aug 17, 2015 at 15:43

Martyn Shutt's user avatar

Martyn ShuttMartyn Shutt

1,66318 silver badges25 bronze badges

1

You could convert your recursive code into an iterative code, which simulates the recursion. This means that you have to push the current status (url, document, position in document etc.) into an array, when you reach a link, and pop it out of the array, when this link has finished.

answered Dec 28, 2011 at 12:53

Yogu's user avatar

YoguYogu

8,9754 gold badges34 silver badges56 bronze badges

Check recursion from command line:

php -r 'function foo() { static $x = 1; echo "foo ", $x++, "n"; foo(); } foo();'

if result > 100 THEN check memory limit;

Christian Giupponi's user avatar

answered Aug 22, 2013 at 13:45

Andrey's user avatar

AndreyAndrey

2974 silver badges5 bronze badges

You could try to wiggle down the nesting by implementing parallel workers (like in cluster computing) instead of increasing the number of nesting function calls.

For example: you define a limited number of slots (eg. 100) and monitor the number of «workers» assigned to each/some of them. If any slots become free, you put the waiting workers «in them».

answered Dec 28, 2011 at 12:52

tamasgal's user avatar

tamasgaltamasgal

24.1k18 gold badges94 silver badges134 bronze badges

1

<?php
ini_set('xdebug.max_nesting_level', 9999);
... your code ...

P.S. Change 9999 to any number you want.

answered May 1, 2018 at 8:16

cofirazak's user avatar

cofirazakcofirazak

5096 silver badges14 bronze badges

Stumbled upon this bug as well during development.

However, in my case it was caused by an underlying loop of functions calling eachother — as a result of continuous iterations during development.

For future reference by search engines — the exact error my logs provided me with was:

Exception: Maximum function nesting level of '256' reached, aborting!

If, like in my case, the given answers do not solve your problem, make sure you’re not accidentally doing something along the lines of the following simplified situation:

function foo(){
    // Do something
    bar();
}

function bar(){
    // Do something else
    foo();
}

In this case, even if you set ini_set('xdebug.max_nesting_level', 9999); it will still print out the same error message in your logs.

answered Dec 31, 2020 at 10:40

Kay Angevare's user avatar

If you’re using Laravel, do

composer update

This should be work.

answered Apr 12, 2016 at 7:20

Putri Dewi Purnamasari's user avatar

2

In your case it’s definitely the crawler instance is having more Xdebug limit to trace error and debug info.

But, in other cases also errors like on PHP or core files like CodeIgniter libraries will create such a case and if you even increase the x-debug level setting it would not vanish.

So, look into your code carefully :) .

Here was the issue in my case.

I had a service class which is library in CodeIgniter. Having a function inside like this.

 class PaymentService {

    private $CI;

    public function __construct() {

        $this->CI =& get_instance();

   }

  public function process(){
   //lots of Ci referencing here...
   }

My controller as follow:

$this->load->library('PaymentService');
$this->process_(); // see I got this wrong instead  it shoud be like 

Function call on last line was wrong because of the typo, instead it should have been like below:

$this->Payment_service->process(); //the library class name

Then I was keeping getting the exceed error message. But I disabled XDebug but non helped. Any way please check you class name or your code for proper function calling.

A.L's user avatar

A.L

9,9099 gold badges62 silver badges96 bronze badges

answered Feb 25, 2015 at 11:30

Nickromancer's user avatar

NickromancerNickromancer

7,4937 gold badges55 silver badges75 bronze badges

2

I had a error when i was installing many plugins So the error 100 showed including the location of the last plugin that i installed C:wampwwwmysitewp-contentplugins»…» so i deleted this plugin folder on the C: drive then everything was back to normal.I think i have to limit the amount of plug-in i install or have activated .good luck i hope it helps

answered Dec 6, 2015 at 0:17

CalvinMD's user avatar

I had this issue with WordPress on cloud9. It turns out it was the W3 Caching plugin. I disabled the plugin and it worked fine.

answered Jan 30, 2017 at 15:01

sobeit's user avatar

Another solution if you are running php script in CLI(cmd)

The php.ini file that needs edit is different in this case. In my WAMP installation the php.ini file that is loaded in command line is:

wampbinphpphp5.5.12php.ini

instead of wampbinapacheapache2.4.9binphp.ini which loads when php is run from browser

Community's user avatar

answered Jan 30, 2017 at 16:37

Binod Kalathil's user avatar

Binod KalathilBinod Kalathil

1,9391 gold badge30 silver badges43 bronze badges

You can also modify the {debug} function in modifier.debug_print_var.php, in order to limit its recursion into objects.

Around line 45, before :

$results .= '<br>' . str_repeat('&nbsp;', $depth * 2)
  . '<b> -&gt;' . strtr($curr_key, $_replace) . '</b> = '
  . smarty_modifier_debug_print_var($curr_val, ++$depth, $length);

After :

$max_depth = 10;
$results .= '<br>' . str_repeat('&nbsp;', $depth * 2)
  . '<b> -&gt;' . strtr($curr_key, $_replace) . '</b> = '
  . ($depth > $max_depth ? 'Max recursion depth:'.(++$depth) : smarty_modifier_debug_print_var($curr_val, ++$depth, $length));

This way, Xdebug will still behave normally: limit recursion depth in var_dump and so on.
As this is a smarty problem, not a Xdebug one!

answered Jul 27, 2014 at 19:36

theredled's user avatar

theredledtheredled

9788 silver badges20 bronze badges

I had the same problem and I resolved it like this:

  • Open MySQL my.ini file
  • In [mysqld] section, add the following line: innodb_force_recovery =
    1
  • Save the file and try starting MySQL
  • Remove that line which you just added and Save

Kay Angevare's user avatar

answered Jan 1, 2020 at 16:47

Yassine ECHCHARAFI's user avatar

Fatal error: Maximum function nesting level of ‘100’ reached, aborting! in …projectdb.php on line 2

My db.php code

$db = mysql_connect ("localhost","db_user","password");
mysql_select_db("db_name",$db);

What’s wrong?

asked Jul 5, 2013 at 12:04

oboshto's user avatar

oboshtooboshto

3,4084 gold badges23 silver badges24 bronze badges

1

Increase the value of xdebug.max_nesting_level in your php.ini, INFO
There is a question here

Community's user avatar

answered Jul 5, 2013 at 12:08

mirkobrankovic's user avatar

mirkobrankovicmirkobrankovic

2,3591 gold badge20 silver badges24 bronze badges

4

Go into your php.ini configuration file and change the following line:

xdebug.max_nesting_level=100

to something like:

xdebug.max_nesting_level=200

answered Jul 5, 2013 at 12:10

Wayne Whitty's user avatar

Wayne WhittyWayne Whitty

19.3k5 gold badges44 silver badges65 bronze badges

2

mysql_connect will return a boolean therefor :

<?php
$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
if (!$link) {
    die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_select_db("databaseName");
?>

answered Jul 5, 2013 at 12:08

DarkBee's user avatar

DarkBeeDarkBee

16.4k5 gold badges48 silver badges58 bronze badges

1 Answer

You can still use xdebug in Magento 2, but it will require modifying the default max_nesting_level value of 100 that xdebug uses.

Open up the php.ini file being used by your server and update or add the following config, depending on if it already exists in your file:

xdebug.max_nesting_level = 200

This works for me, but if you still see the error you can try doubling the value again.

answered Aug 3, 2014 at 13:13

Chris O'Toole's user avatar

Chris O’TooleChris O’Toole

4,4053 gold badges21 silver badges15 bronze badges

5

  • Yes, it worked for me too, Have configured the same in PHP.ini and it worked.

    Jul 5, 2016 at 10:44

  • Hey, i updated from 200 to 300, xdebug.max_nesting_level = 300 . but still i get the same error

    Jul 20, 2016 at 10:28

  • Hey, i updated from 200 to 300, xdebug.max_nesting_level = 300 . but still i get the same error

    Mar 2, 2017 at 5:44

  • Would suggest keep doubling and see if it goes away (200, 400, 800, 1600). If not then open an issue with full trace to the Magento GitHub

    Mar 2, 2017 at 13:50

  • it helped …….put value 1000

    Aug 4, 2020 at 16:11

Страницы 1

Чтобы отправить ответ, вы должны войти или зарегистрироваться

1 29-06-2012 04:53:48

  • nepster
  • nepster
  • начал пользоваться ImageCMS
  • Неактивен
  • Зарегистрирован: 29-06-2012
  • Сообщений: 15

Тема: Ошибка Maximum function nesting level of ‘100’ reached, aborting!

Всем привет, решил попробовать данную цмс, поставил ее, сложностей при установки не было. Начал удалять категории, что бы поставить своим,  удалил штуки 3 — 4 и словил:

A PHP Error was encountered
Severity: Warning
Message: Invalid argument supplied for foreach()
Filename: libraries/lib_category.php
Line Number: 260

Fatal error: Maximum function nesting level of '100' reached, aborting! in S:hometcm.ruwwwapplicationlibrariescache.php on line 368

все сайт лежит. Тестирую на денвере. Ранее с такой ошибкой не сталкивался, подскажите пожалуйста в  чем может быть проблема ?

Thumbs up Thumbs down

2 Ответ от blud 29-06-2012 09:48:46

  • blud
  • эксперт по ImageCMS
  • Неактивен
  • Зарегистрирован: 01-02-2011
  • Сообщений: 202
  • User Karma: 10

Re: Ошибка Maximum function nesting level of ‘100’ reached, aborting!

Ошибка в системе, уже много раз про это писал, но разработчики никак не отреагировали, дело в том что когда удаляешь все категории массив который обрабатывается с помощью foreach пустой и foreach дает ошибку.
Разработчики исправте уже наконец!!!

Thumbs up Thumbs down

3 Ответ от blud 29-06-2012 10:12:09

  • blud
  • эксперт по ImageCMS
  • Неактивен
  • Зарегистрирован: 01-02-2011
  • Сообщений: 202
  • User Karma: 10

Re: Ошибка Maximum function nesting level of ‘100’ reached, aborting!

Попробуйте в файле application/libraries/lib_category.php
найдите строку 260
и замените:

foreach($this->categories as $cats)
        {
            if($cats['id'] == $cat_id)
            {
                //array_push($this->path,$cats['url']);
                $this->path[ $cats['id'] ] = $cats['url'];
                //var_dump($cats);
                $this->_PathToCat($cats['parent_id']);
            }
        }

на

if(count($this->categories) <= 1){
     $cats = $this->categories;
     if($cats['id'] == $cat_id)
            {
                //array_push($this->path,$cats['url']);
                $this->path[ $cats['id'] ] = $cats['url'];
                //var_dump($cats);
                $this->_PathToCat($cats['parent_id']);
            }
    }else{
        foreach($this->categories as $cats)
        {
            if($cats['id'] == $cat_id)
            {
                //array_push($this->path,$cats['url']);
                $this->path[ $cats['id'] ] = $cats['url'];
                //var_dump($cats);
                $this->_PathToCat($cats['parent_id']);
            }
        }
    }

Писал на коленке. Сам не тестировал

Thumbs up Thumbs down

4 Ответ от Kaero 29-06-2012 13:32:48

  • Kaero
  • Kaero
  • эксперт по ImageCMS
  • Неактивен
  • Откуда: Львов
  • Зарегистрирован: 22-03-2012
  • Сообщений: 314
  • User Karma: 37

Re: Ошибка Maximum function nesting level of ‘100’ reached, aborting!

Это base версия (3.0.6.20)?  Хочу повторить баг — не получается. При удаленин последней категории пишет «Ошибка удаления категории.»

Thumbs up Thumbs down

5 Ответ от nepster 29-06-2012 16:51:01

  • nepster
  • nepster
  • начал пользоваться ImageCMS
  • Неактивен
  • Зарегистрирован: 29-06-2012
  • Сообщений: 15

Re: Ошибка Maximum function nesting level of ‘100’ reached, aborting!

blud,

при вашем коде:

Fatal error: Maximum function nesting level of ‘100’ reached, aborting! in S:hometcm.ruwwwapplicationlibrarieslib_category.php on line 260

но я ошибку эту в первые вищу, по ходу дела фореч не должен обижаться, если в него ничего не попадает.

так же попробовал:

define('ENVIRONMENT', 'development');

заменить на

define('ENVIRONMENT', 'production');

в данном случае просто белый экран.

Сам релиз: Текущая версия: 3.0.6.20 (2012-06-19)

Thumbs up Thumbs down

6 Ответ от nepster 29-06-2012 17:11:19

  • nepster
  • nepster
  • начал пользоваться ImageCMS
  • Неактивен
  • Зарегистрирован: 29-06-2012
  • Сообщений: 15

Re: Ошибка Maximum function nesting level of ‘100’ reached, aborting!

копался, копался и получается такое:

вот у нас проблемный код:

        foreach($this->categories as $cats)
        {
            if($cats['id'] == $cat_id)
            {
                //array_push($this->path,$cats['url']);
                $this->path[ $cats['id'] ] = $cats['url'];
                //var_dump($cats);
                $this->_PathToCat($cats['parent_id']);
            }
    }

пытаюсь вскрыть $this->categories, не получается.

окей, ищем определение этой переменной:

    function _build()
    {
       
        $this->categories = $this->CI->cms_base->get_categories();
        $this->create_path();

        $new_cats = array();
                             ....

ради интереса заменил строку

$this->categories = $this->CI->cms_base->get_categories();

на

$this->categories = array();

появился сайт вот с такой ошибкой:

Fatal error: Maximum function nesting level of ‘100’ reached, aborting! in S:hometcm.ruwwwsystemcoreConfig.php on line 214

изменил обратно

$this->categories = array();

на

$this->categories = $this->CI->cms_base->get_categories();

без изменений. Сайт работает но на главной ошибка торчик, админка работает.

Окей идем в админку, удаляем оставшиеся категории. Их осталось 2 как оказалось. Ловлю сообщение — нельзя удалить главную категорию.

Внутренние страницы работают, на главной все так же ошибка.

Прикола вообще не понял, может система закешировола чевось ?))

Thumbs up Thumbs down

7 Ответ от bestxp 01-07-2012 22:57:16

  • bestxp
  • начал пользоваться ImageCMS
  • Неактивен
  • Зарегистрирован: 16-06-2012
  • Сообщений: 10

Re: Ошибка Maximum function nesting level of ‘100’ reached, aborting!

Возможно меню ругается, удалите из меню лишнее и проверьте виджеты что на главной

Thumbs up Thumbs down

8 Ответ от nepster 01-07-2012 23:00:06

  • nepster
  • nepster
  • начал пользоваться ImageCMS
  • Неактивен
  • Зарегистрирован: 29-06-2012
  • Сообщений: 15

Re: Ошибка Maximum function nesting level of ‘100’ reached, aborting!

щас планирую заказ доделать и засесть поразгребать cms. А то пользуюсь очень давно codeigniter и очень хорошо, что он в основе. 

А всякие там джумлы, вордпресы и тд., авторы которых даже не знают, что такое шаблонизаторы, даже не конкуренты ))

Thumbs up Thumbs down

9 Ответ от bozercov 09-01-2013 16:44:32

  • bozercov
  • знакомлюсь с ImageCMS
  • Неактивен
  • Зарегистрирован: 09-01-2013
  • Сообщений: 1

Re: Ошибка Maximum function nesting level of ‘100’ reached, aborting!

nepster пишет:

Всем привет, решил попробовать данную цмс, поставил ее, сложностей при установки не было. Начал удалять категории, что бы поставить своим,  удалил штуки 3 — 4 и словил:

A PHP Error was encountered
Severity: Warning
Message: Invalid argument supplied for foreach()
Filename: libraries/lib_category.php
Line Number: 260

Fatal error: Maximum function nesting level of '100' reached, aborting! in S:hometcm.ruwwwapplicationlibrariescache.php on line 368

все сайт лежит. Тестирую на денвере. Ранее с такой ошибкой не сталкивался, подскажите пожалуйста в  чем может быть проблема ?

Это ошибка из-за xdebug. Надо поправить значение xdebug.max_nesting_level   установить, например 200. в php.ini

Thumbs up Thumbs down

10 Ответ от MrTolyan 23-05-2013 13:10:38

  • MrTolyan
  • знакомлюсь с ImageCMS
  • Неактивен
  • Зарегистрирован: 23-05-2013
  • Сообщений: 1

Re: Ошибка Maximum function nesting level of ‘100’ reached, aborting!

У меня лично подобную ошибку выдал из-за того, что я удалил страницу из «Содержимого», а пункт меню, ссылающийся на эту страницу, остался. То есть была менюшка без ссылки на страницу. Только удалил глюченый пункт — все заработало. Может, поможет кому smile

Thumbs up Thumbs down

Страницы 1

Чтобы отправить ответ, вы должны войти или зарегистрироваться

Понравилась статья? Поделить с друзьями:

Читайте также:

  • Fatal error math h no such file or directory
  • Fatal error mapping iso please check if file is present and defragmented
  • Fatal error mapiexceptionshutoffquotaexceeded has occurred
  • Fatal error malloc h file not found
  • Fatal error lua h no such file or directory

  • 0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest

    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии