mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
Adding a check to the object before use
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.
This commit is contained in:
parent
1fe791353f
commit
6f3e6c10a1
1 changed files with 1 additions and 1 deletions
|
@ -146,7 +146,7 @@ class FormHelper extends AppHelper {
|
|||
));
|
||||
} 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 {
|
||||
|
|
Loading…
Add table
Reference in a new issue