fix: avoid outer "uncaught exception" for ServerMaintenanceMode

We already exclude ServerMaintenanceMode in the inner logger, but there are some spots where it can can bubble up still via DAV.

Fixes #55894

Signed-off-by: Josh <josh.t.richards@gmail.com>
This commit is contained in:
Josh 2025-10-23 18:05:44 -04:00 committed by GitHub
parent ed1647b80d
commit bf9949ecc0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -58,6 +58,7 @@ use OCA\DAV\DAV\ViewOnlyPlugin;
use OCA\DAV\Db\PropertyMapper;
use OCA\DAV\Events\SabrePluginAddEvent;
use OCA\DAV\Events\SabrePluginAuthInitEvent;
use OCA\DAV\Exception\ServerMaintenanceMode;
use OCA\DAV\Files\BrowserErrorPagePlugin;
use OCA\DAV\Files\FileSearchBackend;
use OCA\DAV\Files\LazySearchBackend;
@ -422,12 +423,18 @@ class Server {
/** @var IEventLogger $eventLogger */
$eventLogger = \OCP\Server::get(IEventLogger::class);
$eventLogger->start('dav_server_exec', '');
$this->server->start();
$eventLogger->end('dav_server_exec');
if ($this->profiler->isEnabled()) {
$eventLogger->end('runtime');
$profile = $this->profiler->collect(\OCP\Server::get(IRequest::class), new Response());
$this->profiler->saveProfile($profile);
try {
$this->server->start();
} catch (ServerMaintenanceMode $e) {
// Sabre already sent a 503; avoid the global "Uncaught exception" log.
// do not rethrow
} finally {
$eventLogger->end('dav_server_exec');
if ($this->profiler->isEnabled()) {
$eventLogger->end('runtime');
$profile = $this->profiler->collect(\OCP\Server::get(IRequest::class), new Response());
$this->profiler->saveProfile($profile);
}
}
}