From 0f96a2ccb98ecb47ea3c92fe33423fb1ad997f80 Mon Sep 17 00:00:00 2001 From: Victor Dubiniuk Date: Tue, 10 Sep 2019 12:06:33 +0300 Subject: [PATCH 1/2] Fix Undefined variable: response notice in case of non-404 error Signed-off-by: skjnldsv --- lib/private/Files/Storage/DAV.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/private/Files/Storage/DAV.php b/lib/private/Files/Storage/DAV.php index b849a69246f5e..3d3937b44b7c7 100644 --- a/lib/private/Files/Storage/DAV.php +++ b/lib/private/Files/Storage/DAV.php @@ -250,6 +250,7 @@ protected function propfind(string $path): array|false { // we either don't know it, or we know it exists but need more details if (is_null($cachedResponse) || $cachedResponse === true) { $this->init(); + $response = false; try { $response = $this->client->propFind( $this->encodePath($path), @@ -260,9 +261,9 @@ protected function propfind(string $path): array|false { if ($e->getHttpStatus() === 404 || $e->getHttpStatus() === 405) { $this->statCache->clear($path . '/'); $this->statCache->set($path, false); - return false; + } else { + $this->convertException($e, $path); } - $this->convertException($e, $path); } catch (\Exception $e) { $this->convertException($e, $path); } From 954b6c68a062897986f16d0faa2e4f7f832149b7 Mon Sep 17 00:00:00 2001 From: skjnldsv Date: Fri, 8 Nov 2024 10:42:07 +0100 Subject: [PATCH 2/2] chore: use `$this->logger` and prevent Server::get Signed-off-by: skjnldsv --- lib/private/Files/Storage/DAV.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/private/Files/Storage/DAV.php b/lib/private/Files/Storage/DAV.php index 3d3937b44b7c7..10670d6331a0e 100644 --- a/lib/private/Files/Storage/DAV.php +++ b/lib/private/Files/Storage/DAV.php @@ -346,7 +346,7 @@ public function fopen(string $path, string $mode) { if ($response->getStatusCode() === Http::STATUS_LOCKED) { throw new \OCP\Lock\LockedException($path); } else { - Server::get(LoggerInterface::class)->error('Guzzle get returned status code ' . $response->getStatusCode(), ['app' => 'webdav client']); + $this->logger->error('Guzzle get returned status code ' . $response->getStatusCode(), ['app' => 'webdav client']); } } @@ -773,7 +773,7 @@ public function hasUpdated(string $path, int $time): bool { * @throws ForbiddenException if the action is not allowed */ protected function convertException(Exception $e, string $path = ''): void { - Server::get(LoggerInterface::class)->debug($e->getMessage(), ['app' => 'files_external', 'exception' => $e]); + $this->logger->debug($e->getMessage(), ['app' => 'files_external', 'exception' => $e]); if ($e instanceof ClientHttpException) { if ($e->getHttpStatus() === Http::STATUS_LOCKED) { throw new \OCP\Lock\LockedException($path);