Merge pull request #6132 from nextcloud/do-not-log-maintenance-mode
Do not log WebDAV maintenance mode exception
This commit is contained in:
commit
60a485b80d
|
@ -28,8 +28,7 @@
|
||||||
namespace OCA\DAV\Connector\Sabre;
|
namespace OCA\DAV\Connector\Sabre;
|
||||||
|
|
||||||
use OCP\ILogger;
|
use OCP\ILogger;
|
||||||
use Sabre\DAV\Exception;
|
use Sabre\DAV\Exception\ServiceUnavailable;
|
||||||
use Sabre\HTTP\Response;
|
|
||||||
|
|
||||||
class ExceptionLoggerPlugin extends \Sabre\DAV\ServerPlugin {
|
class ExceptionLoggerPlugin extends \Sabre\DAV\ServerPlugin {
|
||||||
protected $nonFatalExceptions = [
|
protected $nonFatalExceptions = [
|
||||||
|
@ -90,7 +89,12 @@ class ExceptionLoggerPlugin extends \Sabre\DAV\ServerPlugin {
|
||||||
public function logException(\Exception $ex) {
|
public function logException(\Exception $ex) {
|
||||||
$exceptionClass = get_class($ex);
|
$exceptionClass = get_class($ex);
|
||||||
$level = \OCP\Util::FATAL;
|
$level = \OCP\Util::FATAL;
|
||||||
if (isset($this->nonFatalExceptions[$exceptionClass])) {
|
if (isset($this->nonFatalExceptions[$exceptionClass]) ||
|
||||||
|
(
|
||||||
|
$exceptionClass === ServiceUnavailable::class &&
|
||||||
|
$ex->getMessage() === 'System in maintenance mode.'
|
||||||
|
)
|
||||||
|
) {
|
||||||
$level = \OCP\Util::DEBUG;
|
$level = \OCP\Util::DEBUG;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@ use OCA\DAV\Connector\Sabre\ExceptionLoggerPlugin as PluginToTest;
|
||||||
use OC\Log;
|
use OC\Log;
|
||||||
use PHPUnit_Framework_MockObject_MockObject;
|
use PHPUnit_Framework_MockObject_MockObject;
|
||||||
use Sabre\DAV\Exception\NotFound;
|
use Sabre\DAV\Exception\NotFound;
|
||||||
|
use Sabre\DAV\Exception\ServiceUnavailable;
|
||||||
use Sabre\DAV\Server;
|
use Sabre\DAV\Server;
|
||||||
use Test\TestCase;
|
use Test\TestCase;
|
||||||
|
|
||||||
|
@ -77,6 +78,8 @@ class ExceptionLoggerPluginTest extends TestCase {
|
||||||
public function providesExceptions() {
|
public function providesExceptions() {
|
||||||
return [
|
return [
|
||||||
[0, '', new NotFound()],
|
[0, '', new NotFound()],
|
||||||
|
[0, 'System in maintenance mode.', new ServiceUnavailable('System in maintenance mode.')],
|
||||||
|
[4, 'Upgrade needed', new ServiceUnavailable('Upgrade needed')],
|
||||||
[4, 'This path leads to nowhere', new InvalidPath('This path leads to nowhere')]
|
[4, 'This path leads to nowhere', new InvalidPath('This path leads to nowhere')]
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue