From bbd0c25524f553e9440ea9e6845120cd298b86d0 Mon Sep 17 00:00:00 2001
From: JediKev <kevin@enhancesoft.com>
Date: Fri, 15 Feb 2019 11:13:01 -0600
Subject: [PATCH] issue: Delete Org Session Failure

This addresses an issue on the Forum where deleting an Organization causes
the session to fail. This is due to the Organization QuerySet being stored
in the session and not being cleared out when deleted from the system. This
causes the system to try to refetch the object from the database which it's
not there as it's been deleted and therefore causes the session to crash.
---
 include/class.organization.php | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/include/class.organization.php b/include/class.organization.php
index 6a6fbcdb0..6cd62cd91 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))
-- 
GitLab