Skip to content

Commit

Permalink
MINOR: Add workaround for hitting XDebugs fairly conservative nesting…
Browse files Browse the repository at this point in the history
… level limit
  • Loading branch information
Hamish Friedlander committed Mar 5, 2012
1 parent e4675d7 commit 407913f
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions core/Core.php
Expand Up @@ -195,6 +195,11 @@ function array_fill_keys($keys,$value) {
*/
increase_memory_limit_to('64M');

/**
* Ensure we don't run into xdebug's fairly conservative infinite recursion protection limit
*/
increase_xdebug_nesting_level_to(200);

/**
* Set default encoding
*/
Expand Down Expand Up @@ -433,6 +438,19 @@ function get_increase_memory_limit_max() {
return $_increase_memory_limit_max;
}

/**
* Increases the XDebug parameter max_nesting_level, which limits how deep recursion can go.
* Only does anything if (a) xdebug is installed and (b) the new limit is higher than the existing limit
*
* @param int $limit - The new limit to increase to
*/
function increase_xdebug_nesting_level_to($limit) {
if (function_exists('xdebug_enable')) {
$current = ini_get('xdebug.max_nesting_level');
if ((int)$current < $limit) ini_set('xdebug.max_nesting_level', $limit);
}
}

/**
* Turn a memory string, such as 512M into an actual number of bytes.
*
Expand Down

0 comments on commit 407913f

Please sign in to comment.