Skip to content

Commit

Permalink
Add type check to prevent errors related to Hash::get()
Browse files Browse the repository at this point in the history
Fixes #3041
  • Loading branch information
markstory committed Jul 24, 2012
1 parent f926ae7 commit 66b2965
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Cake/View/Helper.php
Expand Up @@ -691,7 +691,7 @@ public function value($options = array(), $field = null, $key = 'value') {
$data = $this->request->data;

$entity = $this->entity();
if (!empty($data) && !empty($entity)) {
if (!empty($data) && is_array($data) && !empty($entity)) {
$result = Hash::get($data, implode('.', $entity));
}

Expand Down

3 comments on commit 66b2965

@lorenzo
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, this will break some plugins that are passing objects to represent models in the view :(

@markstory
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hash::get() already has more is_array() checks internally, and a type hint on array, so I don't think its ever worked with object results.

@lorenzo
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Set was able to, though. I'll look into that in future versions

Please sign in to comment.