]> source.dussan.org Git - nextcloud-server.git/commitdiff
handle errors in apps while registering commands 2302/head
authorRobin Appelman <robin@icewind.nl>
Thu, 24 Nov 2016 11:28:40 +0000 (12:28 +0100)
committerRobin Appelman <robin@icewind.nl>
Thu, 24 Nov 2016 14:13:29 +0000 (15:13 +0100)
Signed-off-by: Robin Appelman <robin@icewind.nl>
console.php
lib/private/Console/Application.php

index c368a28cac0bc8dcddb28c5c3e398048c8c0a775..fb410ee6983fdc7f70505b18a44ddcba03155383 100644 (file)
@@ -85,7 +85,7 @@ try {
                echo "The process control (PCNTL) extensions are required in case you want to interrupt long running commands - see http://php.net/manual/en/book.pcntl.php" . PHP_EOL;
        }
 
-       $application = new Application(\OC::$server->getConfig(), \OC::$server->getEventDispatcher(), \OC::$server->getRequest());
+       $application = new Application(\OC::$server->getConfig(), \OC::$server->getEventDispatcher(), \OC::$server->getRequest(), \OC::$server->getLogger());
        $application->loadCommands(new ArgvInput(), new ConsoleOutput());
        $application->run();
 } catch (Exception $ex) {
index cd76b43f095c1277ebeb1d89c36c246ce89f07f6..f7806ba01a7f095f9287a2d5618db4fa4fb8860d 100644 (file)
@@ -31,6 +31,7 @@ use OC_App;
 use OCP\AppFramework\QueryException;
 use OCP\Console\ConsoleEvent;
 use OCP\IConfig;
+use OCP\ILogger;
 use OCP\IRequest;
 use Symfony\Component\Console\Application as SymfonyApplication;
 use Symfony\Component\Console\Input\InputInterface;
@@ -45,18 +46,22 @@ class Application {
        private $dispatcher;
        /** @var IRequest */
        private $request;
+       /** @var ILogger  */
+       private $logger;
 
        /**
         * @param IConfig $config
         * @param EventDispatcherInterface $dispatcher
         * @param IRequest $request
+        * @param ILogger $logger
         */
-       public function __construct(IConfig $config, EventDispatcherInterface $dispatcher, IRequest $request) {
+       public function __construct(IConfig $config, EventDispatcherInterface $dispatcher, IRequest $request, ILogger $logger) {
                $defaults = \OC::$server->getThemingDefaults();
                $this->config = $config;
                $this->application = new SymfonyApplication($defaults->getName(), \OC_Util::getVersionString());
                $this->dispatcher = $dispatcher;
                $this->request = $request;
+               $this->logger = $logger;
        }
 
        /**
@@ -110,7 +115,11 @@ class Application {
                                                \OC_App::registerAutoloading($app, $appPath);
                                                $file = $appPath . '/appinfo/register_command.php';
                                                if (file_exists($file)) {
-                                                       require $file;
+                                                       try {
+                                                               require $file;
+                                                       } catch (\Exception $e) {
+                                                               $this->logger->logException($e);
+                                                       }
                                                }
                                        }
                                }