Skip to content
Permalink
Browse files

Closes ticket #3080 in CakePHP Lighthouse (http://cakephp.lighthousea…

…pp.com/projects/42648/tickets/3080-hashflatten-endless-loop-on-single-0-int-keys).

Hash::flatten has a bug which causes an endless loop when try to flatten an integer key.
Probably the $data array pointer won't reset itself when doing:

$data = $element

and

list($data, $path) = array_pop($stack)

The solution is to reset the pointer after the assignments.
  • Loading branch information...
marcotisi committed Jan 8, 2013
1 parent 3f21d09 commit 8af76a566286d2b88eaa87a3f6aa372a164f4943
Showing with 2 additions and 0 deletions.
  1. +2 −0 lib/Cake/Utility/Hash.php
@@ -532,13 +532,15 @@ public static function flatten(array $data, $separator = '.') {
$stack[] = array($data, $path);
}
$data = $element;
reset($data);
$path .= $key . $separator;
} else {
$result[$path . $key] = $element;
}
if (empty($data) && !empty($stack)) {
list($data, $path) = array_pop($stack);
reset($data);
}
}
return $result;

0 comments on commit 8af76a5

Please sign in to comment.
You can’t perform that action at this time.