diff --git a/include/class.osticket.php b/include/class.osticket.php
index 284eebff2dc7d692e3f2df86e4d65a7582486b26..b30647742f667956e1f53160e2e19b5841eae3c0 100644
--- a/include/class.osticket.php
+++ b/include/class.osticket.php
@@ -305,6 +305,8 @@ class osTicket {
                 $level=3; //Debug
         }
 
+        $loglevel=array(1=>'Error','Warning','Debug');
+
         $info = array(
             'title' => &$title,
             'level' => $loglevel[$level],
@@ -322,7 +324,6 @@ class osTicket {
             $this->alertAdmin($title, $message);
 
         //Save log based on system log level settings.
-        $loglevel=array(1=>'Error','Warning','Debug');
         $sql='INSERT INTO '.SYSLOG_TABLE.' SET created=NOW(), updated=NOW() '
             .',title='.db_input(Format::sanitize($title, true))
             .',log_type='.db_input($loglevel[$level])
diff --git a/setup/test/tests/stubs.php b/setup/test/tests/stubs.php
index 326a7dbf0f66d37636edadbdf0742d8667e1977a..e41ac16d32d35c48b21b11b77ac0ac2fc4af6ff3 100644
--- a/setup/test/tests/stubs.php
+++ b/setup/test/tests/stubs.php
@@ -26,6 +26,11 @@ class mysqli_stmt {
     function free() {}
 }
 
+class mysqli_result {
+    function free() {}
+    function free_result() {}
+}
+
 class ReflectionClass {
     function getMethods() {}
     function getConstants() {}