Skip to content

Commit

Permalink
Adding a check to the object before use
Browse files Browse the repository at this point in the history
For some reason that I have not been able to figure out yet the object is
returned as null.  This is causing some exceptions when trying to access
properties that dont exist.

FatalErrorException: "Call to a member function getAssociated() on a non-object"

Test still pass with the added check.
  • Loading branch information
dogmatic69 committed Sep 14, 2012
1 parent 1fe7913 commit 6f3e6c1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Cake/View/Helper/FormHelper.php
Expand Up @@ -146,7 +146,7 @@ protected function _getModel($model) {
));
} elseif (ClassRegistry::isKeySet($this->defaultModel)) {
$defaultObject = ClassRegistry::getObject($this->defaultModel);
if (in_array($model, array_keys($defaultObject->getAssociated()), true) && isset($defaultObject->{$model})) {
if ($defaultObject && in_array($model, array_keys($defaultObject->getAssociated()), true) && isset($defaultObject->{$model})) {
$object = $defaultObject->{$model};
}
} else {
Expand Down

0 comments on commit 6f3e6c1

Please sign in to comment.