Skip to content

Commit 555420b

Browse files
authored
Merge pull request ILIAS-eLearning#11218 from mjansenDatabay/hotfix/10/46399
[FIX] Logging: Fix access to undefined array key `HTTP_ACCEPT`
2 parents 65aeea4 + 197fc91 commit 555420b

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

components/ILIAS/Logging/classes/public/class.ilLoggerFactory.php

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<?php
22

3-
declare(strict_types=1);
4-
53
/**
64
* This file is part of ILIAS, a powerful learning management system
75
* published by ILIAS open source e-Learning e.V.
@@ -18,6 +16,7 @@
1816
*
1917
*********************************************************************/
2018

19+
declare(strict_types=1);
2120

2221
use Monolog\Logger;
2322
use Monolog\Handler\StreamHandler;
@@ -127,31 +126,31 @@ public function initUser(string $a_login): void
127126
*/
128127
protected function isConsoleAvailable(): bool
129128
{
130-
if (ilContext::getType() != ilContext::CONTEXT_WEB) {
129+
if (ilContext::getType() !== ilContext::CONTEXT_WEB) {
131130
return false;
132131
}
133-
if (
134-
$this->dic->isDependencyAvailable('ctrl') && $this->dic->ctrl()->isAsynch() ||
132+
133+
if (($this->dic->isDependencyAvailable('ctrl') && $this->dic->ctrl()->isAsynch()) ||
135134
(
136135
$this->dic->isDependencyAvailable('http') &&
137-
strtolower($this->dic->http()->request()->getServerParams()['HTTP_X_REQUESTED_WITH'] ?? '') === 'xmlhttprequest'
136+
strtolower(
137+
$this->dic->http()->request()->getServerParams()['HTTP_X_REQUESTED_WITH'] ?? ''
138+
) === 'xmlhttprequest'
138139
)
139140
) {
140141
return false;
141142
}
142143

143-
if (
144-
$this->dic->isDependencyAvailable('http') &&
145-
strpos($this->dic->http()->request()->getServerParams()['HTTP_ACCEPT'], 'text/html') !== false
146-
) {
144+
if ($this->dic->isDependencyAvailable('http') &&
145+
str_contains($this->dic->http()->request()->getServerParams()['HTTP_ACCEPT'] ?? '', 'text/html')) {
147146
return true;
148147
}
149-
if (
150-
$this->dic->isDependencyAvailable('http') &&
151-
strpos($this->dic->http()->request()->getServerParams()['HTTP_ACCEPT'], 'application/json') !== false
152-
) {
148+
149+
if ($this->dic->isDependencyAvailable('http') &&
150+
str_contains($this->dic->http()->request()->getServerParams()['HTTP_ACCEPT'] ?? '', 'application/json')) {
153151
return false;
154152
}
153+
155154
return true;
156155
}
157156

0 commit comments

Comments
 (0)