CRM-13695 set $_SERVER[HTTP_HOST] from CIVICRM_UF_BASEURL
authorKen West <ken.west@internode.on.net>
Mon, 18 Nov 2013 04:44:35 +0000 (15:44 +1100)
committerKen West <ken.west@internode.on.net>
Mon, 18 Nov 2013 04:44:35 +0000 (15:44 +1100)
----------------------------------------
* CRM-13695: cli - set $_SERVER['HTTP_HOST'] from CIVICRM_UF_BASEURL
  http://issues.civicrm.org/jira/browse/CRM-13695

bin/cli.class.php

index ec420a6c53bd78402f6348d7fa3743b1972097ee..1e44a962a72798329ab906fe021bd9d0d8ceb2a6 100644 (file)
@@ -205,6 +205,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;