diff options
author | John Molakvoæ <skjnldsv@users.noreply.github.com> | 2024-03-15 13:03:34 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-15 13:03:34 +0100 |
commit | 9338ef36ded767f2c35b7ec575b351859420ed09 (patch) | |
tree | 65c53c6a36f300859dc22b2d423275bcf2911367 /lib/private/Console | |
parent | 6b09a79227a5dc98aa4620c6e5e15b610a06c806 (diff) | |
parent | df1cd1ba7e6e1f6e66a2b3229b5c082f1b81162e (diff) | |
download | nextcloud-server-9338ef36ded767f2c35b7ec575b351859420ed09.tar.gz nextcloud-server-9338ef36ded767f2c35b7ec575b351859420ed09.zip |
Merge branch 'master' into refactor/OC-Server-getShareManager
Signed-off-by: John Molakvoæ <skjnldsv@users.noreply.github.com>
Diffstat (limited to 'lib/private/Console')
-rw-r--r-- | lib/private/Console/Application.php | 34 | ||||
-rw-r--r-- | lib/private/Console/TimestampFormatter.php | 19 |
2 files changed, 29 insertions, 24 deletions
diff --git a/lib/private/Console/Application.php b/lib/private/Console/Application.php index 113f0507ef5..44f64e09e94 100644 --- a/lib/private/Console/Application.php +++ b/lib/private/Console/Application.php @@ -47,23 +47,18 @@ use Symfony\Component\Console\Output\ConsoleOutputInterface; use Symfony\Component\Console\Output\OutputInterface; class Application { - /** @var IConfig */ - private $config; + private IConfig $config; private SymfonyApplication $application; - /** @var IEventDispatcher */ - private $dispatcher; - /** @var IRequest */ - private $request; - /** @var LoggerInterface */ - private $logger; - /** @var MemoryInfo */ - private $memoryInfo; + private IEventDispatcher $dispatcher; + private IRequest $request; + private LoggerInterface $logger; + private MemoryInfo $memoryInfo; public function __construct(IConfig $config, - IEventDispatcher $dispatcher, - IRequest $request, - LoggerInterface $logger, - MemoryInfo $memoryInfo) { + IEventDispatcher $dispatcher, + IRequest $request, + LoggerInterface $logger, + MemoryInfo $memoryInfo) { $defaults = \OC::$server->getThemingDefaults(); $this->config = $config; $this->application = new SymfonyApplication($defaults->getName(), \OC_Util::getVersionString()); @@ -74,8 +69,6 @@ class Application { } /** - * @param InputInterface $input - * @param ConsoleOutputInterface $output * @throws \Exception */ public function loadCommands( @@ -128,7 +121,14 @@ class Application { // load commands using info.xml $info = $appManager->getAppInfo($app); if (isset($info['commands'])) { - $this->loadCommandsFromInfoXml($info['commands']); + try { + $this->loadCommandsFromInfoXml($info['commands']); + } catch (\Throwable $e) { + $output->writeln("<error>" . $e->getMessage() . "</error>"); + $this->logger->error($e->getMessage(), [ + 'exception' => $e, + ]); + } } // load from register_command.php \OC_App::registerAutoloading($app, $appPath); diff --git a/lib/private/Console/TimestampFormatter.php b/lib/private/Console/TimestampFormatter.php index 8d74c28e94f..afb1f67c37f 100644 --- a/lib/private/Console/TimestampFormatter.php +++ b/lib/private/Console/TimestampFormatter.php @@ -27,17 +27,17 @@ use Symfony\Component\Console\Formatter\OutputFormatterInterface; use Symfony\Component\Console\Formatter\OutputFormatterStyleInterface; class TimestampFormatter implements OutputFormatterInterface { - /** @var IConfig */ + /** @var ?IConfig */ protected $config; /** @var OutputFormatterInterface */ protected $formatter; /** - * @param IConfig $config + * @param ?IConfig $config * @param OutputFormatterInterface $formatter */ - public function __construct(IConfig $config, OutputFormatterInterface $formatter) { + public function __construct(?IConfig $config, OutputFormatterInterface $formatter) { $this->config = $config; $this->formatter = $formatter; } @@ -104,11 +104,16 @@ class TimestampFormatter implements OutputFormatterInterface { return $this->formatter->format($message); } - $timeZone = $this->config->getSystemValue('logtimezone', 'UTC'); - $timeZone = $timeZone !== null ? new \DateTimeZone($timeZone) : null; + if ($this->config instanceof IConfig) { + $timeZone = $this->config->getSystemValue('logtimezone', 'UTC'); + $timeZone = $timeZone !== null ? new \DateTimeZone($timeZone) : null; - $time = new \DateTime('now', $timeZone); - $timestampInfo = $time->format($this->config->getSystemValue('logdateformat', \DateTimeInterface::ATOM)); + $time = new \DateTime('now', $timeZone); + $timestampInfo = $time->format($this->config->getSystemValue('logdateformat', \DateTimeInterface::ATOM)); + } else { + $time = new \DateTime('now'); + $timestampInfo = $time->format(\DateTimeInterface::ATOM); + } return $timestampInfo . ' ' . $this->formatter->format($message); } |