From ebe335bd90f28e2d97e688869412eba05004b735 Mon Sep 17 00:00:00 2001
From: Ken West <ken.west@internode.on.net>
Date: Sat, 2 Nov 2013 21:30:38 +1100
Subject: [PATCH] Forum topic 30462 - set $_SERVER['HTTP_HOST'] from
 CIVICRM_UF_BASEURL

---
 bin/cli.class.php | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/bin/cli.class.php b/bin/cli.class.php
index cad7f6ce3c..73d2397817 100644
--- a/bin/cli.class.php
+++ b/bin/cli.class.php
@@ -204,6 +204,15 @@ class civicrm_cli {
     CRM_Core_ClassLoader::singleton()->register();
 
     $this->_config = CRM_Core_Config::singleton();
+    
+    // HTTP_HOST will be 'localhost' unless overwritten with the -s argument.
+    // Now we have a Config object, we can set it from the Base URL.
+    if ($_SERVER['HTTP_HOST'] == 'localhost') {
+        $_SERVER['HTTP_HOST'] = preg_replace(
+                '!^https?://([^/]+)/$!i', 
+                '$1',
+                $this->_config->userFrameworkBaseURL);
+    }
 
     $class = 'CRM_Utils_System_' . $this->_config->userFramework;
 
-- 
GitLab