diff --git a/app/Models/Device.php b/app/Models/Device.php index 38ca180499..f197ce620f 100644 --- a/app/Models/Device.php +++ b/app/Models/Device.php @@ -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;