Merge pull request #26879 from nextcloud/backport/26878/stable21

[stable21] Don't break OCC if an app is breaking in it's Application class
This commit is contained in:
Roeland Jago Douma 2021-05-12 09:40:01 +02:00 committed by GitHub
commit dd014059d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 15 deletions

View File

@ -113,6 +113,7 @@ class Coordinator {
*/ */
$appNameSpace = App::buildAppNamespace($appId); $appNameSpace = App::buildAppNamespace($appId);
$applicationClassName = $appNameSpace . '\\AppInfo\\Application'; $applicationClassName = $appNameSpace . '\\AppInfo\\Application';
try {
if (class_exists($applicationClassName) && in_array(IBootstrap::class, class_implements($applicationClassName), true)) { if (class_exists($applicationClassName) && in_array(IBootstrap::class, class_implements($applicationClassName), true)) {
try { try {
/** @var IBootstrap|App $application */ /** @var IBootstrap|App $application */
@ -121,14 +122,15 @@ class Coordinator {
// Weird, but ok // Weird, but ok
continue; continue;
} }
try {
$application->register($this->registrationContext->for($appId)); $application->register($this->registrationContext->for($appId));
}
} catch (Throwable $e) { } catch (Throwable $e) {
$this->logger->logException($e, [ $this->logger->logException($e, [
'message' => 'Error during app service registration: ' . $e->getMessage(), 'message' => 'Error during app service registration: ' . $e->getMessage(),
'level' => ILogger::FATAL, 'level' => ILogger::FATAL,
'app' => $appId,
]); ]);
} continue;
} }
} }

View File

@ -134,7 +134,15 @@ class OC_App {
ob_start(); ob_start();
foreach ($apps as $app) { foreach ($apps as $app) {
if (!isset(self::$loadedApps[$app]) && ($types === [] || self::isType($app, $types))) { if (!isset(self::$loadedApps[$app]) && ($types === [] || self::isType($app, $types))) {
try {
self::loadApp($app); 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(); ob_end_clean();