Skip to content

Commit

Permalink
Merge pull request #26878 from nextcloud/bugfix/noid/dont-break-occ-w…
Browse files Browse the repository at this point in the history
…hen-an-app-is-breaking-in-application-class

Don't break OCC if an app is breaking in it's Application class
  • Loading branch information
nickvergessen committed May 5, 2021
2 parents 20b3487 + 784b059 commit 4d82a94
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 14 deletions.
29 changes: 16 additions & 13 deletions lib/private/AppFramework/Bootstrap/Coordinator.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,21 +113,24 @@ private function registerApps(array $appIds): void {
*/
$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->emergency('Error during app service registration: ' . $e->getMessage(), [
'exception' => $e,
]);
}
} catch (Throwable $e) {
$this->logger->emergency('Error during app service registration: ' . $e->getMessage(), [
'exception' => $e,
'app' => $appId,
]);
continue;
}
}

Expand Down
9 changes: 8 additions & 1 deletion lib/private/legacy/OC_App.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,14 @@ public static function loadApps(array $types = []): bool {
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->get(LoggerInterface::class)->emergency('Error during app loading: ' . $e->getMessage(), [
'exception' => $e,
'app' => $app,
]);
}
}
}
ob_end_clean();
Expand Down

0 comments on commit 4d82a94

Please sign in to comment.