From 47dc4c5238fd2900f312ae5a17b80c4893746517 Mon Sep 17 00:00:00 2001
From: Jared Hancock <jared@osticket.com>
Date: Mon, 13 Jul 2015 21:13:01 -0500
Subject: [PATCH] deploy: Fix incorrectly deployed INCLUDE_DIR define

---
 include/cli/modules/unpack.php | 31 ++++++++++++++++---------------
 1 file changed, 16 insertions(+), 15 deletions(-)

diff --git a/include/cli/modules/unpack.php b/include/cli/modules/unpack.php
index 5635a03c9..72f5fae82 100644
--- a/include/cli/modules/unpack.php
+++ b/include/cli/modules/unpack.php
@@ -197,21 +197,22 @@ class Unpacker extends Module {
         if (isset($location))
             return $location;
 
-        $bootstrap_php = $this->destination . '/bootstrap.php';
-        if (!is_file($bootstrap_php))
-            return @$this->include_path ?: '';
-
-        $lines = preg_grep("/define\s*\(\s*'INCLUDE_DIR'/",
-            explode("\n", file_get_contents($bootstrap_php)));
-
-        // NOTE: that this won't work for crafty folks who have a define or some
-        //       variable in the value of their include path
-        if (!defined('ROOT_DIR'))
-            define('ROOT_DIR', rtrim($this->destination, '/').'/');
-        foreach ($lines as $line)
-            @eval($line);
-
-        return $location = rtrim(INCLUDE_DIR, '/').'/';
+        $pipes = array();
+        $php = proc_open('php', array(
+            0 => array('pipe', 'r'),
+            1 => array('pipe', 'w'),
+        ), $pipes);
+
+        fwrite($pipes[0], "<?php
+        include '{$this->destination}/bootstrap.php';
+        print INCLUDE_DIR;
+        ");
+        fclose($pipes[0]);
+
+        $INCLUDE_DIR = fread($pipes[1], 8192);
+        proc_close($php);
+
+        return $location = rtrim($INCLUDE_DIR, '/').'/';
     }
 
     function run($args, $options) {
-- 
GitLab