Skip to content

Commit 3231e9e

Browse files
committed
1.0.4 - $_SERVER['REQUEST_SCHEME'] not available for Apache 2.2 or LiteSpeed #1
1 parent 350f918 commit 3231e9e

File tree

3 files changed

+27
-8
lines changed

3 files changed

+27
-8
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 1.0.4 - 2019-06-13
4+
### Fixed
5+
- Define REQUEST_SCHEME not by $_SERVER to support Apache 2.2, LightSpeed and IIS
6+
37
## 1.0.3 - 2019-01-16
48
### Fixed
59
- Fixed Undefined index Exception

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "bitboxde/error-notifier",
33
"description": "Sending an email if an error occurred.",
44
"type": "craft-plugin",
5-
"version": "1.0.3",
5+
"version": "1.0.4",
66
"keywords": [
77
"craft",
88
"cms",

src/services/HandleException.php

+22-7
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function handleException($exception)
2828
{
2929
$recievers = $this->getRecievers();
3030

31-
if($recievers !== false && $this->pluginSettings->enabled && $this->checkEnvironment() && $this->checkNotFound($exception)) {
31+
if ($recievers !== false && $this->pluginSettings->enabled && $this->checkEnvironment() && $this->checkNotFound($exception)) {
3232
$view = Craft::$app->getView();
3333
$oldTemplatesPath = $view->getTemplatesPath();
3434
$view->setTemplatesPath(ErrorNotifier::getInstance()->getBasePath());
@@ -45,11 +45,11 @@ public function handleException($exception)
4545
);
4646
$view->setTemplatesPath($oldTemplatesPath);
4747

48-
if(array_key_exists('fromName', $this->settings)) {
48+
if (array_key_exists('fromName', $this->settings)) {
4949
$message = new Message();
5050
$message->setFrom([$this->pluginSettings->sender => $this->settings['fromName']]);
5151
$message->setTo($recievers);
52-
$message->setSubject($this->pluginSettings->emailPrefix .' - ' . $this->settings['fromName'] . ' - ' . $this->getExceptionName($exception));
52+
$message->setSubject($this->pluginSettings->emailPrefix . ' - ' . $this->settings['fromName'] . ' - ' . $this->getExceptionName($exception));
5353
$message->setHtmlBody($body);
5454

5555
Craft::$app->mailer->send($message);
@@ -59,7 +59,7 @@ public function handleException($exception)
5959

6060
protected function getRecievers()
6161
{
62-
if($this->pluginSettings->recievers !== '') {
62+
if ($this->pluginSettings->recievers !== '') {
6363
return array_map('trim', explode(',', $this->pluginSettings->recievers));
6464
}
6565

@@ -68,7 +68,7 @@ protected function getRecievers()
6868

6969
protected function checkEnvironment()
7070
{
71-
if(in_array($this->environment, $this->pluginEnvironments, true)) {
71+
if (in_array($this->environment, $this->pluginEnvironments, true)) {
7272
return true;
7373
}
7474

@@ -77,7 +77,7 @@ protected function checkEnvironment()
7777

7878
protected function checkNotFound($exception)
7979
{
80-
if($this->pluginSettings->notFound !== '1' && $this->getExceptionName($exception) === 'Not Found') {
80+
if ($this->pluginSettings->notFound !== '1' && $this->getExceptionName($exception) === 'Not Found') {
8181
return false;
8282
}
8383

@@ -95,12 +95,27 @@ protected function getServerVars()
9595
{
9696
$serverVars = $_SERVER;
9797

98+
$serverVars['REQUEST_SCHEME'] = $this->getRequestScheme();
99+
98100
// clean some fields
99101
unset($serverVars['DB_PASSWORD'], $serverVars['HTTP_COOKIE']);
100102

101103
return $serverVars;
102104
}
103105

106+
protected function getRequestScheme()
107+
{
108+
if (isset($_SERVER['HTTPS']) && ('on' === strtolower($_SERVER['HTTPS']) || '1' == $_SERVER['HTTPS'])) {
109+
return 'https';
110+
}
111+
112+
if (isset($_SERVER['SERVER_PORT']) && ('443' == $_SERVER['SERVER_PORT'])) {
113+
return 'https';
114+
}
115+
116+
return 'http';
117+
}
118+
104119
protected function getUserVars()
105120
{
106121
return print_r(Craft::$app->getUser(), true);
@@ -119,4 +134,4 @@ protected function getCookieVars()
119134
{
120135
return print_r($_COOKIE, true);
121136
}
122-
}
137+
}

0 commit comments

Comments
 (0)