diff --git a/apps/dav/lib/Connector/Sabre/FilesPlugin.php b/apps/dav/lib/Connector/Sabre/FilesPlugin.php index df63f33253427..93eeef0e4d8a4 100644 --- a/apps/dav/lib/Connector/Sabre/FilesPlugin.php +++ b/apps/dav/lib/Connector/Sabre/FilesPlugin.php @@ -229,11 +229,12 @@ public function handleDownloadToken(RequestInterface $request, ResponseInterface } } - public function httpGet(RequestInterface $request, ResponseInterface $response) { + public function httpGet(RequestInterface $request, ResponseInterface $response): bool { // only handle symlinks $node = $this->tree->getNodeForPath($request->getPath()); - if (!($node instanceof \OCA\DAV\Connector\Sabre\File && $this->symlinkManager->isSymlink($node->getFileInfo()))) { - return; + if (!($node instanceof \OCA\DAV\Connector\Sabre\File + && $this->symlinkManager->isSymlink($node->getFileInfo()))) { + return true; } $date = \DateTime::createFromFormat('U', $node->getLastModified()); @@ -255,7 +256,7 @@ public function httpGet(RequestInterface $request, ResponseInterface $response) * @param RequestInterface $request * @param ResponseInterface $response */ - public function afterHttpGet(RequestInterface $request, ResponseInterface $response) { + public function afterHttpGet(RequestInterface $request, ResponseInterface $response): void { // Only handle valid files $node = $this->tree->getNodeForPath($request->getPath()); if (!($node instanceof IFile)) { diff --git a/apps/dav/lib/Upload/SymlinkPlugin.php b/apps/dav/lib/Upload/SymlinkPlugin.php index 7e51b79a9f90f..e2e3d6020624c 100644 --- a/apps/dav/lib/Upload/SymlinkPlugin.php +++ b/apps/dav/lib/Upload/SymlinkPlugin.php @@ -32,7 +32,11 @@ use Sabre\HTTP\ResponseInterface; class SymlinkPlugin extends ServerPlugin { - /** @var Server */ + /** + * @var Server + * + * @psalm-suppress PropertyNotSetInConstructor + */ private $server; /** @var SymlinkManager */ private $symlinkManager; @@ -44,7 +48,7 @@ public function __construct() { /** * @inheritdoc */ - public function initialize(Server $server) { + public function initialize(Server $server): void { $server->on('method:PUT', [$this, 'httpPut']); $server->on('method:DELETE', [$this, 'httpDelete']); $server->on('afterMove', [$this, 'afterMove']); @@ -70,7 +74,9 @@ public function httpPut(RequestInterface $request, ResponseInterface $response): $symlinkNode->put($symlinkTarget); $this->symlinkManager->storeSymlink($symlinkNode->getFileInfo()); - $response->setHeader("OC-ETag", $etag); + if ($etag) { + $response->setHeader('OC-ETag', $etag); + } $response->setStatus(201); return false; // this request was handled already } else { diff --git a/lib/private/Files/SymlinkManager.php b/lib/private/Files/SymlinkManager.php index f8592ad7060f7..a1c6937cb4efe 100644 --- a/lib/private/Files/SymlinkManager.php +++ b/lib/private/Files/SymlinkManager.php @@ -146,7 +146,7 @@ private function updateSymlink($node) { ->set('storage', $query->createNamedParameter($storageId)) ->set('path', $query->createNamedParameter($path)); if ($query->executeStatement() != 1) { - throw new \OCP\DB\Exception("Invalid number of rows changed while updating symlink!"); + throw new \OCP\DB\Exception('Invalid number of rows changed while updating symlink!'); } } @@ -164,7 +164,7 @@ private function insertSymlink($node) { ->setValue('storage', $query->createNamedParameter($storageId)) ->setValue('path', $query->createNamedParameter($path)); if ($query->executeStatement() != 1) { - throw new \OCP\DB\Exception("Invalid number of rows changed while inserting symlink!"); + throw new \OCP\DB\Exception('Invalid number of rows changed while inserting symlink!'); } } @@ -179,7 +179,7 @@ private function deleteSymlinkById($id) { ->where($query->expr()->eq('id', $query->createNamedParameter($id))); $rowsChanged = $query->executeStatement(); if ($rowsChanged > 1) { - throw new \OCP\DB\Exception("Too many symlink rows deleted!"); + throw new \OCP\DB\Exception('Too many symlink rows deleted!'); } return $rowsChanged == 1; }