Permalink
Browse files

Fix errors with illegal string offsets.

If $_list becomes a string notice errors are triggered when trying
to do offsets in PHP 5.4
  • Loading branch information...
markstory committed Dec 28, 2011
1 parent 2cc38b5 commit e9813d7a978475d5d2d264e9c8cf5526cdfbab27
Showing with 4 additions and 1 deletion.
  1. +4 −1 lib/Cake/Utility/Set.php
View
@@ -671,14 +671,17 @@ public static function insert($list, $path, $data = null) {
if (is_numeric($key) && intval($key) > 0 || $key === '0') {
$key = intval($key);
}
- if ($i === $count - 1) {
+ if ($i === $count - 1 && is_array($_list)) {
$_list[$key] = $data;
} else {
if (!isset($_list[$key])) {
$_list[$key] = array();
}
$_list =& $_list[$key];
}
+ if (!is_array($_list)) {
+ return array();
+ }
}
return $list;
}

0 comments on commit e9813d7

Please sign in to comment.