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 11, 2023
1 parent ded2ad6 commit f4c0158
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 f4c0158

Please sign in to comment.