BUGFIX Don't try to use HTTP_HOST environment variable if its not set in Director::protocolAndHost(). Throw a warning, then return false - before if script execution was not set to stop on WARNING, you'll get a NOTICE as well.

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@63291 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2008-09-29 12:52:23 +00:00
parent 21944a2e06
commit 6afad36c39

View File

@ -284,6 +284,8 @@ class Director {
/**
* Returns the part of the URL, 'http://www.mysite.com'.
*
* @return boolean|string The domain from the PHP enviroment. Returns FALSE is this environment variable isn't set.
*/
static function protocolAndHost() {
if(self::$alternateBaseURL) {
@ -294,11 +296,13 @@ class Director {
$s = (isset($_SERVER['SSL']) || isset($_SERVER['HTTPS'])) ? 's' : '';
if(!isset($_SERVER['HTTP_HOST'])) {
if(isset($_SERVER['HTTP_HOST'])) {
return "http$s://" . $_SERVER['HTTP_HOST'];
} else {
user_error("Director::protocolAndHost() lacks sufficient information - HTTP_HOST not set.", E_USER_WARNING);
return false;
}
return "http$s://" . $_SERVER['HTTP_HOST'];
}