-
Notifications
You must be signed in to change notification settings - Fork 3
Description
Hi,
I've been having a problem where my development environment on PHP 5.3 had some errors using this behavior whereas my local environment on PHP 5.5 did not.
It seems to have to do with the following difference documented by PHP:
$str='abc';var_dump(isset($str['x'])); // false for PHP 5.4 or later, but true for 5.3 or less
which has influence on line 93 of the behaviour:
if (isset($result[$field])) {
$result[$field] = $this->_unserialize($Model->alias, $result[$field]);
} elseif....
In this case, when going through properties of an object searching for a field to unserialize, say 'foo', we get at a certain point for example that $result is the string 'some value of an object' and the isset($result['foo']) will return true. Then the behavior will try to unserialize 's' at which it fails because this is not a deserializable string.
I fixed this by adding a check if the $result variable is not a string:
if (isset($result[$field]) && !is_string($result)) {
$result[$field] = $this->_unserialize($Model->alias, $result[$field]);
} elseif....
I am not sure if you want to support PHP 5.3 or if this is an unwanted fix, therefore reported it as an issue instead of a pull request. Maybe others will have some benefit to this fix as well.