Skip to content

Commit fbf0491

Browse files
authored
Merge pull request #1580 from nextcloud/backport/1577/stable29
[stable29] fix: Do not register listener when not in console
2 parents 3774955 + 4fa355a commit fbf0491

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

lib/AppInfo/Application.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ public function __construct(array $urlParams = []) {
3939
}
4040

4141
public function register(IRegistrationContext $context): void {
42-
$context->registerEventListener(BeforeMessageLoggedEvent::class, LogListener::class);
42+
if (defined('OC_CONSOLE') && \OC_CONSOLE) {
43+
$context->registerEventListener(BeforeMessageLoggedEvent::class, LogListener::class);
44+
}
4345
$context->registerService(Formatter::class, function (ContainerInterface $c) {
4446
return new Formatter(\OC::$SERVERROOT);
4547
});

lib/Listener/LogListener.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,10 @@ class LogListener implements IEventListener {
3838
private ?Console $console;
3939

4040
public function __construct(Formatter $formatter, SystemConfig $config) {
41-
if (defined('OC_CONSOLE') && \OC_CONSOLE) {
42-
$level = getenv('OCC_LOG');
43-
if ($level) {
44-
$terminal = new Terminal();
45-
$this->console = new Console($formatter, $config, $level, $terminal->getWidth());
46-
} else {
47-
$this->console = null;
48-
}
41+
$level = getenv('OCC_LOG');
42+
if ($level) {
43+
$terminal = new Terminal();
44+
$this->console = new Console($formatter, $config, $level, $terminal->getWidth());
4945
} else {
5046
$this->console = null;
5147
}

0 commit comments

Comments
 (0)