Repository navigation
Open
Labels
Milestone
Description
If an app ships with an incompatible command the occ command will be broken and unusable, eg:
An unhandled exception has been thrown:
ArgumentCountError: Too few arguments to function OCA\User_LDAP\Command\Search::__construct(), 0 passed in /var/www/owncloud/lib/private/Console/Application.php on line 170 and exactly 3 expected in /var/www/owncloud/apps/user_ldap/lib/Command/Search.php:50
Stack trace:
#0 /var/www/owncloud/lib/private/Console/Application.php(170): OCA\User_LDAP\Command\Search->__construct()
#1 /var/www/owncloud/lib/private/Console/Application.php(108): OC\Console\Application->loadCommandsFromInfoXml(Array)
#2 /var/www/owncloud/console.php(105): OC\Console\Application->loadCommands(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#3 /var/www/owncloud/occ(11): require_once('/var/www/ownclo...')
#4 {main}
core/lib/private/Console/Application.php
Lines 164 to 178 in 3bff5c2
| private function loadCommandsFromInfoXml($commands) { | |
| foreach ($commands as $command) { | |
| try { | |
| $c = \OC::$server->query($command); | |
| } catch (QueryException $e) { | |
| if (\class_exists($command)) { | |
| $c = new $command(); | |
| } else { | |
| throw new \Exception("Console command '$command' is unknown and could not be loaded"); | |
| } | |
| } | |
| $this->application->add($c); | |
| } | |
| } |
- add ILogger to DI,
- log an error
- skip to the next command
- add tests ... currently not covered AFAICT
Activity
ownclouders commentedon Dec 14, 2018
GitMate.io thinks possibly related issues are #13402 (... broken), #24494 (occ command to clear all locks), #13976 (Kill OC_Request), #25964 (occ-.htaccess generation breaks .htaccess), and #30177 (Kill occ command maintenance:createjs).
Kanishksgithub commentedon Nov 16, 2023
i want to work on this could you briefly define exactly what i have to do in this issue
DeepDiver1975 commentedon Nov 16, 2023
instead of throwing the exception write a log statement - this way the loop will finish and all other commands are available ....
Kanishksgithub commentedon Nov 16, 2023
could you assign me i want to work on this issue
Kanishksgithub commentedon Nov 16, 2023
i want to fix this bug
DeepDiver1975 commentedon Nov 16, 2023
Just go for it an submit your pull request. THX a lot! 🙏
DeepDiver1975 commentedon Jun 19, 2026
Classification: confirmed-bug (still reproducible on
master)🤖 Automated issue analysis by Claude Code review agent.
This is still present and unfixed on current
master. The offending code inlib/private/Console/Application.phpis essentially unchanged since 2016:Root cause. When a command class declares constructor dependencies that the DI container cannot resolve,
\OC::$server->query($command)throwsQueryException, which is caught. The fallback then callsnew $command()with no arguments. For a command whose constructor has required parameters (e.g.OCA\User_LDAP\Command\Search::__construct()expecting 3 args, as in the report) this raises anArgumentCountError(a\Error/\Throwable, not aQueryExceptionor\Exception). That error is not caught here, propagates up throughloadCommands(), and aborts the entireoccbootstrap — so a single broken app command makes all commands unusable.Two distinct problems remain in this method:
new $command()is unguarded against\Error/\Throwablethrown by the constructor (the actual crash in the report).elsebranchthrow new \Exception(...)also aborts the whole loop rather than skipping the one bad command.The maintainer's earlier guidance still applies: instead of throwing/letting it bubble, log an error and continue to the next command so the rest of
occstays available. The original checklist is still open:ILoggerto DI (the constructor currently takes onlyIConfig,EventDispatcherInterface,IRequest— no logger is injected)Suggested shape of the fix: wrap the per-command load (
query+new $command()fallback +addCommand) in atry { ... } catch (\Throwable $e) { $this->logger->logException($e, ['app' => 'core']); continue; }so one incompatible command is logged and skipped instead of killing occ.This is a junior-friendly, well-scoped fix. No PR is being opened automatically.
DeepDiver1975 commentedon Jun 19, 2026
🤖 Follow-up: opened a fix — #41642. It wraps each command load in
try/catch (\Throwable)so a broken command is logged viaILoggerand skipped instead of killing occ; the existing query/new $command()/unknown-class path and the success behavior are unchanged. Includes a regression test.