From 2bf468f06919a275840478bbf068dfbc8f2e388b Mon Sep 17 00:00:00 2001
From: Jared Hancock <jared@osticket.com>
Date: Thu, 16 Jan 2014 08:43:42 -0600
Subject: [PATCH] Ensure a ROOT_PATH is defined for CLI apps

---
 include/class.osticket.php | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/include/class.osticket.php b/include/class.osticket.php
index dce94a8fe..f27efe4a9 100644
--- a/include/class.osticket.php
+++ b/include/class.osticket.php
@@ -397,7 +397,10 @@ class osTicket {
         $file = str_replace('\\','/', $frame['file']);
         $path = substr($file, strlen(ROOT_DIR));
         if($path && ($pos=strpos($_SERVER['SCRIPT_NAME'], $path))!==false)
-            return substr($_SERVER['SCRIPT_NAME'], 0, $pos);
+            return ($pos) ? substr($_SERVER['SCRIPT_NAME'], 0, $pos) : '/';
+
+        if (self::is_cli())
+            return '/';
 
         return null;
     }
-- 
GitLab