fix(setupcheck): Catch Throwables from setup checks and show them to the admin

This avoids letting a buggy setup check from an application crash the
 setupcheck system. The throwable is shown instead.

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
pull/44270/head
Côme Chilliet 2 months ago
parent 3af954fcc8
commit a0a957c961
No known key found for this signature in database
GPG Key ID: A3E2F658B28C760A

@ -30,6 +30,7 @@ use OC\AppFramework\Bootstrap\Coordinator;
use OCP\Server;
use OCP\SetupCheck\ISetupCheck;
use OCP\SetupCheck\ISetupCheckManager;
use OCP\SetupCheck\SetupResult;
use Psr\Log\LoggerInterface;
class SetupCheckManager implements ISetupCheckManager {
@ -46,7 +47,11 @@ class SetupCheckManager implements ISetupCheckManager {
/** @var ISetupCheck $setupCheckObject */
$setupCheckObject = Server::get($setupCheck->getService());
$this->logger->debug('Running check '.get_class($setupCheckObject));
$setupResult = $setupCheckObject->run();
try {
$setupResult = $setupCheckObject->run();
} catch (\Throwable $t) {
$setupResult = SetupResult::error("An exception occured while running the setup check:\n$t");
}
$setupResult->setName($setupCheckObject->getName());
$category = $setupCheckObject->getCategory();
$results[$category] ??= [];

Loading…
Cancel
Save