aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/SetupCheck
diff options
context:
space:
mode:
authorCôme Chilliet <come.chilliet@nextcloud.com>2024-03-18 11:56:04 +0100
committerCôme Chilliet <come.chilliet@nextcloud.com>2024-03-18 11:56:04 +0100
commita0a957c9619c2df142d4eab1df35b1f69008f23b (patch)
tree344de25ed1d387967fafef9bd31ef7620164b27e /lib/private/SetupCheck
parent3af954fcc876a7c35b2c71b138fc02c37fcf83c1 (diff)
downloadnextcloud-server-a0a957c9619c2df142d4eab1df35b1f69008f23b.tar.gz
nextcloud-server-a0a957c9619c2df142d4eab1df35b1f69008f23b.zip
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>
Diffstat (limited to 'lib/private/SetupCheck')
-rw-r--r--lib/private/SetupCheck/SetupCheckManager.php7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/private/SetupCheck/SetupCheckManager.php b/lib/private/SetupCheck/SetupCheckManager.php
index b8b6cfa11e7..fbf57d81fd3 100644
--- a/lib/private/SetupCheck/SetupCheckManager.php
+++ b/lib/private/SetupCheck/SetupCheckManager.php
@@ -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] ??= [];