Fix FatalThrowableError in forgetAttrib() (#11064)
* From a device's SNMP edit form, when attempting to remove previously set Max Repeaters or Max OIDs values, a fatal error was being thrown. * Fix Call to a member function delete() on null {"userId":2,"exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalThrowableError(code: 0): Call to a member function delete() on null at /opt/librenms/app/Models/Device.php:406) * This patch corrects the ability to use the device's SNMP edit form to remove device attributes that had been previously set. The values of Max Repeaters or MaxOIDs can now be deleted from the database.
This commit is contained in:
parent
6931df8990
commit
68419b1130
|
@ -401,8 +401,11 @@ class Device extends BaseModel
|
|||
});
|
||||
|
||||
if ($attrib_index !== false) {
|
||||
$deleted=(bool)$this->attribs->get($attrib_index)->delete();
|
||||
// only forget the attrib_index after delete, otherwise delete() will fail fatally with:
|
||||
// Symfony\\Component\\Debug\Exception\\FatalThrowableError(code: 0): Call to a member function delete() on null
|
||||
$this->attribs->forget($attrib_index);
|
||||
return (bool)$this->attribs->get($attrib_index)->delete();
|
||||
return $deleted;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
Loading…
Reference in New Issue