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
Fenn-CS committed May 22, 2023
1 parent bb2c2bb commit d0fc159
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
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
Expand Down

0 comments on commit d0fc159

Please sign in to comment.