Skip to content

Commit 5c53b16

Browse files
committed
Do not log WebDAV maintenance mode exception
Log the maintenance mode exception only in debug level. Fixes #6124 Signed-off-by: Morris Jobke <[email protected]>
1 parent e70135b commit 5c53b16

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

‎apps/dav/lib/Connector/Sabre/ExceptionLoggerPlugin.php‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@
2828
namespace OCA\DAV\Connector\Sabre;
2929

3030
use OCP\ILogger;
31-
use Sabre\DAV\Exception;
32-
use Sabre\HTTP\Response;
31+
use Sabre\DAV\Exception\ServiceUnavailable;
3332

3433
class ExceptionLoggerPlugin extends \Sabre\DAV\ServerPlugin {
3534
protected $nonFatalExceptions = [
@@ -90,7 +89,12 @@ public function initialize(\Sabre\DAV\Server $server) {
9089
public function logException(\Exception $ex) {
9190
$exceptionClass = get_class($ex);
9291
$level = \OCP\Util::FATAL;
93-
if (isset($this->nonFatalExceptions[$exceptionClass])) {
92+
if (isset($this->nonFatalExceptions[$exceptionClass]) ||
93+
(
94+
$exceptionClass === ServiceUnavailable::class &&
95+
$ex->getMessage() === 'System in maintenance mode.'
96+
)
97+
) {
9498
$level = \OCP\Util::DEBUG;
9599
}
96100

‎apps/dav/tests/unit/Connector/Sabre/ExceptionLoggerPluginTest.php‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
use OC\Log;
2929
use PHPUnit_Framework_MockObject_MockObject;
3030
use Sabre\DAV\Exception\NotFound;
31+
use Sabre\DAV\Exception\ServiceUnavailable;
3132
use Sabre\DAV\Server;
3233
use Test\TestCase;
3334

@@ -77,6 +78,8 @@ public function testLogging($expectedLogLevel, $expectedMessage, $exception) {
7778
public function providesExceptions() {
7879
return [
7980
[0, '', new NotFound()],
81+
[0, 'System in maintenance mode.', new ServiceUnavailable('System in maintenance mode.')],
82+
[4, 'Upgrade needed', new ServiceUnavailable('Upgrade needed')],
8083
[4, 'This path leads to nowhere', new InvalidPath('This path leads to nowhere')]
8184
];
8285
}

0 commit comments

Comments
 (0)