From 7d27abf2b1bab1251d26e30342c99f0153403f8e Mon Sep 17 00:00:00 2001 From: Robbie Averill Date: Tue, 25 Jun 2019 16:05:38 +1200 Subject: [PATCH 1/3] Update expected json content type in unit test --- tests/php/SubsiteXHRControllerTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/php/SubsiteXHRControllerTest.php b/tests/php/SubsiteXHRControllerTest.php index ba6549d..671bb57 100644 --- a/tests/php/SubsiteXHRControllerTest.php +++ b/tests/php/SubsiteXHRControllerTest.php @@ -35,7 +35,7 @@ class SubsiteXHRControllerTest extends FunctionalTest ]); $this->assertEquals(200, $result->getStatusCode()); - $this->assertEquals('text/json', $result->getHeader('Content-Type')); + $this->assertEquals('application/json', $result->getHeader('Content-Type')); $body = $result->getBody(); $this->assertContains('Main site', $body); From 9a7cdbbe2d59518d83f04da726c821ced35ea663 Mon Sep 17 00:00:00 2001 From: Robbie Averill Date: Fri, 26 Jul 2019 09:53:54 +0200 Subject: [PATCH 2/3] FIX Prevent undefined index notice when trying to determine HTTP_HOST during dev/build --- src/Model/Subsite.php | 2 +- src/Model/SubsiteDomain.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Model/Subsite.php b/src/Model/Subsite.php index 229604d..d3190bc 100644 --- a/src/Model/Subsite.php +++ b/src/Model/Subsite.php @@ -870,7 +870,7 @@ class Subsite extends DataObject } // If there are no objects, default to the current hostname - return $_SERVER['HTTP_HOST']; + return isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'localhost'; } /** diff --git a/src/Model/SubsiteDomain.php b/src/Model/SubsiteDomain.php index 66432e9..a3aef03 100644 --- a/src/Model/SubsiteDomain.php +++ b/src/Model/SubsiteDomain.php @@ -185,7 +185,7 @@ class SubsiteDomain extends DataObject */ public function getSubstitutedDomain() { - $currentHost = $_SERVER['HTTP_HOST']; + $currentHost = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'localhost'; // If there are wildcards in the primary domain (not recommended), make some // educated guesses about what to replace them with: From 09abe2b2f2dc405fca8e876fd372399980d2f146 Mon Sep 17 00:00:00 2001 From: Robbie Averill Date: Mon, 29 Jul 2019 10:38:14 +0200 Subject: [PATCH 3/3] Use Director::host() over direct $_SERVER access --- src/Model/Subsite.php | 2 +- src/Model/SubsiteDomain.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Model/Subsite.php b/src/Model/Subsite.php index d3190bc..2bcdbff 100644 --- a/src/Model/Subsite.php +++ b/src/Model/Subsite.php @@ -870,7 +870,7 @@ class Subsite extends DataObject } // If there are no objects, default to the current hostname - return isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'localhost'; + return Director::host(); } /** diff --git a/src/Model/SubsiteDomain.php b/src/Model/SubsiteDomain.php index a3aef03..aed9750 100644 --- a/src/Model/SubsiteDomain.php +++ b/src/Model/SubsiteDomain.php @@ -185,7 +185,7 @@ class SubsiteDomain extends DataObject */ public function getSubstitutedDomain() { - $currentHost = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'localhost'; + $currentHost = Director::host(); // If there are wildcards in the primary domain (not recommended), make some // educated guesses about what to replace them with: