From eb4bda84598061ad50608206706b63a1c8f3d905 Mon Sep 17 00:00:00 2001 From: JediKev <kevin@enhancesoft.com> Date: Wed, 30 Oct 2019 15:58:40 -0500 Subject: [PATCH] orm: Refetch Failure This addresses an ORM failure where upon refetching an object from the database that no longer exists the system crashes hard. We use the `one()` method which expects one result, if there is no result it throws a `DoesNotExist` exception. We are not catching the exception properly which crashes osTicket and forces you to clear the session via browser or database. --- include/class.orm.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/include/class.orm.php b/include/class.orm.php index 34564f111..e0afb277b 100644 --- a/include/class.orm.php +++ b/include/class.orm.php @@ -717,9 +717,11 @@ class VerySimpleModel { } private function refetch() { - $this->ht = - static::objects()->filter($this->getPk())->values()->one() - + $this->ht; + try { + $this->ht = + static::objects()->filter($this->getPk())->values()->one() + + $this->ht; + } catch (DoesNotExist $ex) {} } private function getPk() { -- GitLab