diff --git a/include/class.organization.php b/include/class.organization.php index 6a6fbcdb0c183d9833f861f98fa1a7b80887f943..6cd62cd9159842fe4f544fd888656cf391dceeb6 100644 --- a/include/class.organization.php +++ b/include/class.organization.php @@ -486,6 +486,9 @@ implements TemplateVariable, Searchable { if (!parent::delete()) return false; + // Clear organization from session to avoid refetch failure + unset($_SESSION[':Q:orgs'], $_SESSION[':O:tickets']); + // Remove users from this organization User::objects() ->filter(array('org' => $this)) diff --git a/include/class.orm.php b/include/class.orm.php index 34564f111873b22b62a10e087b3a2d3cf5a90d86..e0afb277be782f27dd60c43c6c1e2d49468f203d 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() {