Skip to content

Commit

Permalink
Avoid db connection when logging db connection errors
Browse files Browse the repository at this point in the history
`\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>
  • Loading branch information
nfebe committed May 9, 2023
1 parent ded2ad6 commit e4459fd
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/private/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,13 @@ public function __construct($webRoot, \OC\Config $config) {

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
$v = [];
}
} 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
Expand Down

0 comments on commit e4459fd

Please sign in to comment.