Skip to content

Commit bcc515a

Browse files
printminion-cobackportbot[bot]
authored andcommitted
fix(console): write app command loading errors to stderr
When an app fails to load its commands from info.xml, the error was written to stdout, while every other diagnostic in loadCommands() uses $output->getErrorOutput(). The command itself then runs normally and exits 0, so the message silently corrupts machine-readable output: $ ./occ app:list --output=json Connection refused {"enabled":{...},"disabled":{...}} $ echo $? 0 Anything piping `occ <cmd> --output=json` into a JSON parser breaks, with no non-zero exit code to detect it by. Observed with notify_push on a setup that has the phpredis extension loaded but no Redis configured: RedisFactory::isAvailable() only checks whether the extension is loaded, so constructing the app's console commands ends up calling pconnect() and throws RedisException. --no-warnings is not a workaround for this, as it sets VERBOSITY_QUIET and suppresses the payload too. Route the message to the error output instead. It is still reported via logger->error() exactly as before. Assisted-by: ClaudeCode:claude-opus-5 Signed-off-by: Misha M.-Kupriyanov <kupriyanov@strato.de>
1 parent 6db9f3c commit bcc515a

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

lib/private/Console/Application.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public function loadCommands(
9595
try {
9696
$this->loadCommandsFromInfoXml($info['commands']);
9797
} catch (\Throwable $e) {
98-
$output->writeln('<error>' . $e->getMessage() . '</error>');
98+
$output->getErrorOutput()->writeln('<error>' . $e->getMessage() . '</error>');
9999
$this->logger->error($e->getMessage(), [
100100
'exception' => $e,
101101
]);
@@ -117,7 +117,7 @@ public function loadCommands(
117117
try {
118118
$this->loadCommandsFromInfoXml($info['commands']);
119119
} catch (\Throwable $e) {
120-
$output->writeln('<error>' . $e->getMessage() . '</error>');
120+
$output->getErrorOutput()->writeln('<error>' . $e->getMessage() . '</error>');
121121
$this->logger->error($e->getMessage(), [
122122
'exception' => $e,
123123
]);

0 commit comments

Comments
 (0)