From ee0bc22a7ec852344a6d771f4db426fab99a3b03 Mon Sep 17 00:00:00 2001
From: Jared Hancock <jared@osticket.com>
Date: Wed, 22 Oct 2014 13:04:05 -0500
Subject: [PATCH] Fix a few possible errors and warnings

---
 include/class.dynamic_forms.php | 2 +-
 include/class.mailfetch.php     | 2 +-
 include/class.topic.php         | 2 +-
 logout.php                      | 9 ++++-----
 4 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/include/class.dynamic_forms.php b/include/class.dynamic_forms.php
index 1b31e882d..11318d436 100644
--- a/include/class.dynamic_forms.php
+++ b/include/class.dynamic_forms.php
@@ -690,7 +690,7 @@ class DynamicFormEntry extends VerySimpleModel {
     function getForm() {
         if (!isset($this->_form)) {
             $this->_form = DynamicForm::lookup($this->get('form_id'));
-            if (isset($this->id))
+            if ($this->_form && isset($this->id))
                 $this->_form->data($this);
         }
         return $this->_form;
diff --git a/include/class.mailfetch.php b/include/class.mailfetch.php
index 4e6546549..1210bffa3 100644
--- a/include/class.mailfetch.php
+++ b/include/class.mailfetch.php
@@ -138,7 +138,7 @@ class MailFetcher {
             $args += array(NULL, 0, array(
                 'DISABLE_AUTHENTICATOR' => array('GSSAPI', 'NTLM')));
 
-        $this->mbox = call_user_func_array('imap_open', $args);
+        $this->mbox = @call_user_func_array('imap_open', $args);
 
         return $this->mbox;
     }
diff --git a/include/class.topic.php b/include/class.topic.php
index 1dd6d0b48..9139f9e6d 100644
--- a/include/class.topic.php
+++ b/include/class.topic.php
@@ -256,7 +256,7 @@ class Topic {
 
     static function getHelpTopics($publicOnly=false, $disabled=false) {
         global $cfg;
-        static $topics, $names;
+        static $topics, $names = array();
 
         if (!$names) {
             $sql = 'SELECT topic_id, topic_pid, ispublic, isactive, topic FROM '.TOPIC_TABLE
diff --git a/logout.php b/logout.php
index 4b9ea91b1..74d73cc37 100644
--- a/logout.php
+++ b/logout.php
@@ -16,10 +16,9 @@
 
 require('client.inc.php');
 //Check token: Make sure the user actually clicked on the link to logout.
-if(!$thisclient || !$_GET['auth'] || !$ost->validateLinkToken($_GET['auth']))
-   @header('Location: index.php');
+if ($thisclient && $_GET['auth'] && $ost->validateLinkToken($_GET['auth']))
+   $thisclient->logOut();
 
-$thisclient->logOut();
-header('Location: index.php');
-require('index.php');
+
+Http::redirect('index.php');
 ?>
-- 
GitLab