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>
This commit is contained in:
fenn-cs 2023-04-14 16:20:56 +01:00
parent bb2c2bb7f0
commit d0fc159975

View file

@ -730,7 +730,13 @@ class Server extends ServerContainer implements IServerContainer {
if ($config->getSystemValueBool('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
if (!$config->getSystemValueBool('log_query')) {
$v = \OC_App::getAppVersions();
try {
$v = \OC_App::getAppVersions();
} catch (\Doctrine\DBAL\Exception $e) {
// Database service probably unavailable
// Probably related to https://github.com/nextcloud/server/issues/37424
return $arrayCacheFactory;
}
} else {
// If the log_query is enabled, we can not get the app versions
// as that does a query, which will be logged and the logging