From 9022b3a1eaa183ab959ffb35062418d184972abf Mon Sep 17 00:00:00 2001
From: Jared Hancock <jared@osticket.com>
Date: Fri, 15 May 2015 16:43:50 -0500
Subject: [PATCH] Fix crash logging out during upgrade

---
 scp/logout.php | 29 +++++++++++++++++------------
 1 file changed, 17 insertions(+), 12 deletions(-)

diff --git a/scp/logout.php b/scp/logout.php
index 0a7f6ee8e..02e7775aa 100644
--- a/scp/logout.php
+++ b/scp/logout.php
@@ -20,18 +20,23 @@ require('staff.inc.php');
 if(!$_GET['auth'] || !$ost->validateLinkToken($_GET['auth']))
     @header('Location: index.php');
 
-$thisstaff->logOut();
-
-//Clear any ticket locks the staff has.
-Lock::removeStaffLocks($thisstaff->getId());
-
-//Destroy session on logout.
-// TODO: Stop doing this starting with 1.9 - separate session data per
-// app/panel.
-session_unset();
-session_destroy();
-
-osTicketSession::destroyCookie();
+try {
+    $thisstaff->logOut();
+
+    //Destroy session on logout.
+    // TODO: Stop doing this starting with 1.9 - separate session data per
+    // app/panel.
+    session_unset();
+    session_destroy();
+
+    osTicketSession::destroyCookie();
+
+    //Clear any ticket locks the staff has.
+    Lock::removeStaffLocks($thisstaff->getId());
+}
+catch (Exception $x) {
+    // Lock::removeStaffLocks may throw InconsistentModel on upgrade
+}
 
 @header('Location: login.php');
 require('login.php');
-- 
GitLab