Skip to content

Commit d0fc159

Browse files
committed
Avoid db connection when logging db connection errors
`\OC\Log\LogDetails::logDetails` depends on `\OC_App::getAppVersions()` which makes a database connection causing the logger to break when the database service is unavaiable. Signed-off-by: fenn-cs <fenn25.fn@gmail.com>
1 parent bb2c2bb commit d0fc159

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/private/Server.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,13 @@ public function __construct($webRoot, \OC\Config $config) {
730730

731731
if ($config->getSystemValueBool('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
732732
if (!$config->getSystemValueBool('log_query')) {
733-
$v = \OC_App::getAppVersions();
733+
try {
734+
$v = \OC_App::getAppVersions();
735+
} catch (\Doctrine\DBAL\Exception $e) {
736+
// Database service probably unavailable
737+
// Probably related to https://github.com/nextcloud/server/issues/37424
738+
return $arrayCacheFactory;
739+
}
734740
} else {
735741
// If the log_query is enabled, we can not get the app versions
736742
// as that does a query, which will be logged and the logging

0 commit comments

Comments
 (0)