Skip to content

Commit

Permalink
bug #10195 [Debug] Fixed recursion level incrementing in FlattenExcep…
Browse files Browse the repository at this point in the history
…tion::flattenArgs(). (sun)

This PR was submitted for the 2.3-dev branch but it was merged into the 2.3 branch instead (closes #10195).

Discussion
----------

[Debug] Fixed recursion level incrementing in FlattenException::flattenArgs().

The internal `$level` variable for tracking the recursion level is pre-incremented on the parent level of the recursion already.

This causes later array elements in an array that has more than 10 elements to get obscured by `'*DEEP NESTED ARRAY*'`, even though the elements are on the first/top level of the array.

The incremented `$level` value needs to be passed to the recursive call to `FlattenException::flattenArgs()` only.

Discovered in debugging exceptions in Drupal (which happens to use very large multi-dimensional arrays for legacy reasons).

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

Commits
-------

1b1501b Fixed recursion level incrementing in FlattenException::flattenArgs().
  • Loading branch information
fabpot committed Feb 4, 2014
2 parents d22a1ee + de32b8e commit 7a11908
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Symfony/Component/Debug/Exception/FlattenException.php
Expand Up @@ -249,7 +249,7 @@ private function flattenArgs($args, $level = 0)
if ($level > 10) {
$result[$key] = array('array', '*DEEP NESTED ARRAY*');
} else {
$result[$key] = array('array', $this->flattenArgs($value, ++$level));
$result[$key] = array('array', $this->flattenArgs($value, $level + 1));
}
} elseif (null === $value) {
$result[$key] = array('null', null);
Expand Down

0 comments on commit 7a11908

Please sign in to comment.