From a0e0627de066a8c32d5713a4074e8cd290755234 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 6 May 2021 14:46:11 +0200 Subject: [PATCH] Don't break OCC if an app is breaking in it's Application class Signed-off-by: Joas Schilling --- .../AppFramework/Bootstrap/Coordinator.php | 30 ++++++++++--------- lib/private/legacy/OC_App.php | 10 ++++++- 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/lib/private/AppFramework/Bootstrap/Coordinator.php b/lib/private/AppFramework/Bootstrap/Coordinator.php index c8155c3b5b..9e85cfdbcd 100644 --- a/lib/private/AppFramework/Bootstrap/Coordinator.php +++ b/lib/private/AppFramework/Bootstrap/Coordinator.php @@ -105,22 +105,24 @@ class Coordinator { */ $appNameSpace = App::buildAppNamespace($appId); $applicationClassName = $appNameSpace . '\\AppInfo\\Application'; - if (class_exists($applicationClassName) && in_array(IBootstrap::class, class_implements($applicationClassName), true)) { - try { - /** @var IBootstrap|App $application */ - $apps[$appId] = $application = $this->serverContainer->query($applicationClassName); - } catch (QueryException $e) { - // Weird, but ok - continue; - } - try { + try { + if (class_exists($applicationClassName) && in_array(IBootstrap::class, class_implements($applicationClassName), true)) { + try { + /** @var IBootstrap|App $application */ + $apps[$appId] = $application = $this->serverContainer->query($applicationClassName); + } catch (QueryException $e) { + // Weird, but ok + continue; + } $application->register($this->registrationContext->for($appId)); - } catch (Throwable $e) { - $this->logger->logException($e, [ - 'message' => 'Error during app service registration: ' . $e->getMessage(), - 'level' => ILogger::FATAL, - ]); } + } catch (Throwable $e) { + $this->logger->logException($e, [ + 'message' => 'Error during app service registration: ' . $e->getMessage(), + 'level' => ILogger::FATAL, + 'app' => $appId, + ]); + continue; } } diff --git a/lib/private/legacy/OC_App.php b/lib/private/legacy/OC_App.php index a1ddfcdecb..9c980dd847 100644 --- a/lib/private/legacy/OC_App.php +++ b/lib/private/legacy/OC_App.php @@ -128,7 +128,15 @@ class OC_App { ob_start(); foreach ($apps as $app) { if (!isset(self::$loadedApps[$app]) && ($types === [] || self::isType($app, $types))) { - self::loadApp($app); + try { + self::loadApp($app); + } catch (\Throwable $e) { + \OC::$server->getLogger()->logException($e, [ + 'message' => 'Error during app loading: ' . $e->getMessage(), + 'level' => ILogger::FATAL, + 'app' => $app, + ]); + } } } ob_end_clean();