From 32fe7e3273c61e5a69f7fef0f3b0edd3cb21ee6e Mon Sep 17 00:00:00 2001 From: Phil Davis <phil@jankaritech.com> Date: Thu, 9 Dec 2021 15:41:55 +0545 Subject: [PATCH 1/4] Revert "Add PHPdoc for params parameter" This reverts commit 2df6a6c241b85d8ebcfad4f513e2c50c75819f87. --- lib/CalDAV/CalendarObject.php | 1 - lib/CalDAV/Schedule/SchedulingObject.php | 1 - lib/CardDAV/Card.php | 3 +-- lib/DAV/FS/File.php | 3 +-- lib/DAV/FSExt/File.php | 1 - lib/DAV/File.php | 1 - lib/DAV/IFile.php | 1 - lib/DAV/Server.php | 9 ++++----- tests/Sabre/DAV/Mock/File.php | 3 +-- tests/Sabre/DAV/Mock/StreamingFile.php | 3 +-- tests/Sabre/DAV/PartialUpdate/FileMock.php | 8 ++++---- 11 files changed, 12 insertions(+), 22 deletions(-) diff --git a/lib/CalDAV/CalendarObject.php b/lib/CalDAV/CalendarObject.php index 1fb042d23b..9db7e03287 100644 --- a/lib/CalDAV/CalendarObject.php +++ b/lib/CalDAV/CalendarObject.php @@ -92,7 +92,6 @@ public function get() * Updates the ICalendar-formatted object. * * @param string|resource $calendarData - * @param object|null $params * * @return string */ diff --git a/lib/CalDAV/Schedule/SchedulingObject.php b/lib/CalDAV/Schedule/SchedulingObject.php index 532fd8b06a..ed9f76e52e 100644 --- a/lib/CalDAV/Schedule/SchedulingObject.php +++ b/lib/CalDAV/Schedule/SchedulingObject.php @@ -59,7 +59,6 @@ public function get() * Updates the ICalendar-formatted object. * * @param string|resource $calendarData - * @param object|null $params * * @return string */ diff --git a/lib/CardDAV/Card.php b/lib/CardDAV/Card.php index 44bbf3c2d3..a39b7dcecf 100644 --- a/lib/CardDAV/Card.php +++ b/lib/CardDAV/Card.php @@ -78,8 +78,7 @@ public function get() /** * Updates the VCard-formatted object. * - * @param string $cardData - * @param object|null $params + * @param string $cardData * * @return string|null */ diff --git a/lib/DAV/FS/File.php b/lib/DAV/FS/File.php index 2fb96d0820..4c46822b4e 100644 --- a/lib/DAV/FS/File.php +++ b/lib/DAV/FS/File.php @@ -18,8 +18,7 @@ class File extends Node implements DAV\IFile /** * Updates the data. * - * @param resource $data - * @param object|null $params + * @param resource $data */ public function put($data, $params = null) { diff --git a/lib/DAV/FSExt/File.php b/lib/DAV/FSExt/File.php index a867b95c67..2bd6488cb5 100644 --- a/lib/DAV/FSExt/File.php +++ b/lib/DAV/FSExt/File.php @@ -22,7 +22,6 @@ class File extends Node implements DAV\PartialUpdate\IPatchSupport * Data is a readable stream resource. * * @param resource|string $data - * @param object|null $params * * @return string */ diff --git a/lib/DAV/File.php b/lib/DAV/File.php index 42ec3e8b95..8f98fd5d9d 100644 --- a/lib/DAV/File.php +++ b/lib/DAV/File.php @@ -34,7 +34,6 @@ abstract class File extends Node implements IFile * return an ETag, and just return null. * * @param string|resource $data - * @param object|null $params * * @return string|null */ diff --git a/lib/DAV/IFile.php b/lib/DAV/IFile.php index c96b62d9f6..91c9bad339 100644 --- a/lib/DAV/IFile.php +++ b/lib/DAV/IFile.php @@ -35,7 +35,6 @@ interface IFile extends INode * return an ETag, and just return null. * * @param resource|string $data - * @param object|null $params * * @return string|null */ diff --git a/lib/DAV/Server.php b/lib/DAV/Server.php index 883e219a5f..e5b4c65c08 100644 --- a/lib/DAV/Server.php +++ b/lib/DAV/Server.php @@ -1114,14 +1114,13 @@ public function createFile($uri, $data, &$etag = null) * * This method will return true if the file was actually updated * - * @param string $uri - * @param resource $data - * @param string $etag - * @param object|null $params + * @param string $uri + * @param resource $data + * @param string $etag * * @return bool */ - public function updateFile($uri, $data, &$etag = null, $params = null) + public function updateFile($uri, $data, &$etag = null, $params) { $node = $this->tree->getNodeForPath($uri); diff --git a/tests/Sabre/DAV/Mock/File.php b/tests/Sabre/DAV/Mock/File.php index cf4a7fed3c..82391b3f5c 100644 --- a/tests/Sabre/DAV/Mock/File.php +++ b/tests/Sabre/DAV/Mock/File.php @@ -82,8 +82,7 @@ public function setName($name) * different object on a subsequent GET you are strongly recommended to not * return an ETag, and just return null. * - * @param resource $data - * @param object|null $params + * @param resource $data * * @return string|null */ diff --git a/tests/Sabre/DAV/Mock/StreamingFile.php b/tests/Sabre/DAV/Mock/StreamingFile.php index 1815f81f3d..4f1c1c2d5b 100644 --- a/tests/Sabre/DAV/Mock/StreamingFile.php +++ b/tests/Sabre/DAV/Mock/StreamingFile.php @@ -35,8 +35,7 @@ class StreamingFile extends File * different object on a subsequent GET you are strongly recommended to not * return an ETag, and just return null. * - * @param resource $data - * @param object|null $params + * @param resource $data * * @return string|null */ diff --git a/tests/Sabre/DAV/PartialUpdate/FileMock.php b/tests/Sabre/DAV/PartialUpdate/FileMock.php index 374c32fbd0..3a596acdaf 100644 --- a/tests/Sabre/DAV/PartialUpdate/FileMock.php +++ b/tests/Sabre/DAV/PartialUpdate/FileMock.php @@ -10,12 +10,12 @@ class FileMock implements IPatchSupport { protected $data = ''; - public function put($data, $params = null) + public function put($str, $params = null) { - if (is_resource($data)) { - $data = stream_get_contents($data); + if (is_resource($str)) { + $str = stream_get_contents($str); } - $this->data = $data; + $this->data = $str; } /** From 9b018549b0c408a2569429c2ba1ffd3ff807d8e6 Mon Sep 17 00:00:00 2001 From: Phil Davis <phil@jankaritech.com> Date: Thu, 9 Dec 2021 15:42:05 +0545 Subject: [PATCH 2/4] Revert "php unit fix" This reverts commit 0e2b4e3b28f015fde7a104a8198b107fe27a8765. --- tests/Sabre/DAV/Mock/File.php | 2 +- tests/Sabre/DAV/Mock/StreamingFile.php | 2 +- tests/Sabre/DAV/PartialUpdate/FileMock.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/Sabre/DAV/Mock/File.php b/tests/Sabre/DAV/Mock/File.php index 82391b3f5c..d48ddaa922 100644 --- a/tests/Sabre/DAV/Mock/File.php +++ b/tests/Sabre/DAV/Mock/File.php @@ -86,7 +86,7 @@ public function setName($name) * * @return string|null */ - public function put($data, $params = null) + public function put($data) { if (is_resource($data)) { $data = stream_get_contents($data); diff --git a/tests/Sabre/DAV/Mock/StreamingFile.php b/tests/Sabre/DAV/Mock/StreamingFile.php index 4f1c1c2d5b..951327e334 100644 --- a/tests/Sabre/DAV/Mock/StreamingFile.php +++ b/tests/Sabre/DAV/Mock/StreamingFile.php @@ -39,7 +39,7 @@ class StreamingFile extends File * * @return string|null */ - public function put($data, $params = null) + public function put($data) { if (is_string($data)) { $stream = fopen('php://memory', 'r+'); diff --git a/tests/Sabre/DAV/PartialUpdate/FileMock.php b/tests/Sabre/DAV/PartialUpdate/FileMock.php index 3a596acdaf..72fdb5ec84 100644 --- a/tests/Sabre/DAV/PartialUpdate/FileMock.php +++ b/tests/Sabre/DAV/PartialUpdate/FileMock.php @@ -10,7 +10,7 @@ class FileMock implements IPatchSupport { protected $data = ''; - public function put($str, $params = null) + public function put($str) { if (is_resource($str)) { $str = stream_get_contents($str); From e5940a57bb0ff0061c564dc342a6d4fbe740bbf4 Mon Sep 17 00:00:00 2001 From: Phil Davis <phil@jankaritech.com> Date: Thu, 9 Dec 2021 15:42:15 +0545 Subject: [PATCH 3/4] Revert "php cs fix" This reverts commit a4432fad1aa14ec919cea4400e00f6cab75e0098. --- lib/CalDAV/CalendarObject.php | 2 +- lib/CalDAV/Schedule/SchedulingObject.php | 2 +- lib/CardDAV/Card.php | 2 +- lib/DAV/CorePlugin.php | 4 ++-- lib/DAV/FS/File.php | 2 +- lib/DAV/FSExt/File.php | 2 +- lib/DAV/File.php | 2 +- lib/DAV/IFile.php | 2 +- lib/DAV/Server.php | 4 ++-- 9 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/CalDAV/CalendarObject.php b/lib/CalDAV/CalendarObject.php index 9db7e03287..e49813d5c3 100644 --- a/lib/CalDAV/CalendarObject.php +++ b/lib/CalDAV/CalendarObject.php @@ -95,7 +95,7 @@ public function get() * * @return string */ - public function put($calendarData, $params = null) + public function put($calendarData,$params=null) { if (is_resource($calendarData)) { $calendarData = stream_get_contents($calendarData); diff --git a/lib/CalDAV/Schedule/SchedulingObject.php b/lib/CalDAV/Schedule/SchedulingObject.php index ed9f76e52e..2a23b36033 100644 --- a/lib/CalDAV/Schedule/SchedulingObject.php +++ b/lib/CalDAV/Schedule/SchedulingObject.php @@ -62,7 +62,7 @@ public function get() * * @return string */ - public function put($calendarData, $params = null) + public function put($calendarData,$params=null) { throw new MethodNotAllowed('Updating scheduling objects is not supported'); } diff --git a/lib/CardDAV/Card.php b/lib/CardDAV/Card.php index a39b7dcecf..8f4114d9d4 100644 --- a/lib/CardDAV/Card.php +++ b/lib/CardDAV/Card.php @@ -82,7 +82,7 @@ public function get() * * @return string|null */ - public function put($cardData, $params = null) + public function put($cardData,$params=null) { if (is_resource($cardData)) { $cardData = stream_get_contents($cardData); diff --git a/lib/DAV/CorePlugin.php b/lib/DAV/CorePlugin.php index afb424f770..8568b4dcba 100644 --- a/lib/DAV/CorePlugin.php +++ b/lib/DAV/CorePlugin.php @@ -429,7 +429,7 @@ public function httpPut(RequestInterface $request, ResponseInterface $response) { $body = $request->getBodyAsStream(); $path = $request->getPath(); - $params = (object) ['versioning' => $request->getHeader('versioning')]; + $params = (object) array('versioning' => $request->getHeader('versioning')); // Intercepting Content-Range if ($request->getHeader('Content-Range')) { @@ -490,7 +490,7 @@ public function httpPut(RequestInterface $request, ResponseInterface $response) if (!($node instanceof IFile)) { throw new Exception\Conflict('PUT is not allowed on non-files.'); } - if (!$this->server->updateFile($path, $body, $etag, $params)) { + if (!$this->server->updateFile($path, $body, $etag,$params)) { return false; } diff --git a/lib/DAV/FS/File.php b/lib/DAV/FS/File.php index 4c46822b4e..b6c7149179 100644 --- a/lib/DAV/FS/File.php +++ b/lib/DAV/FS/File.php @@ -20,7 +20,7 @@ class File extends Node implements DAV\IFile * * @param resource $data */ - public function put($data, $params = null) + public function put($data,$params=null) { file_put_contents($this->path, $data); clearstatcache(true, $this->path); diff --git a/lib/DAV/FSExt/File.php b/lib/DAV/FSExt/File.php index 2bd6488cb5..d249b52418 100644 --- a/lib/DAV/FSExt/File.php +++ b/lib/DAV/FSExt/File.php @@ -25,7 +25,7 @@ class File extends Node implements DAV\PartialUpdate\IPatchSupport * * @return string */ - public function put($data, $params = null) + public function put($data,$params=null) { file_put_contents($this->path, $data); clearstatcache(true, $this->path); diff --git a/lib/DAV/File.php b/lib/DAV/File.php index 8f98fd5d9d..ca203d77f4 100644 --- a/lib/DAV/File.php +++ b/lib/DAV/File.php @@ -37,7 +37,7 @@ abstract class File extends Node implements IFile * * @return string|null */ - public function put($data, $params = null) + public function put($data,$params=null) { throw new Exception\Forbidden('Permission denied to change data'); } diff --git a/lib/DAV/IFile.php b/lib/DAV/IFile.php index 91c9bad339..00b316ff2e 100644 --- a/lib/DAV/IFile.php +++ b/lib/DAV/IFile.php @@ -38,7 +38,7 @@ interface IFile extends INode * * @return string|null */ - public function put($data, $params = null); + public function put($data,$params=null); /** * Returns the data. diff --git a/lib/DAV/Server.php b/lib/DAV/Server.php index e5b4c65c08..226a07cab2 100644 --- a/lib/DAV/Server.php +++ b/lib/DAV/Server.php @@ -1120,7 +1120,7 @@ public function createFile($uri, $data, &$etag = null) * * @return bool */ - public function updateFile($uri, $data, &$etag = null, $params) + public function updateFile($uri, $data, &$etag = null,$params) { $node = $this->tree->getNodeForPath($uri); @@ -1133,7 +1133,7 @@ public function updateFile($uri, $data, &$etag = null, $params) if (!$this->emit('beforeWriteContent', [$uri, $node, &$data, &$modified])) { return false; } - $etag = $node->put($data, $params); + $etag = $node->put($data,$params); if ($modified) { $etag = null; } From 83bbb1a1072ca9d0800727653ff9091f41c44026 Mon Sep 17 00:00:00 2001 From: Phil Davis <phil@jankaritech.com> Date: Thu, 9 Dec 2021 15:42:29 +0545 Subject: [PATCH 4/4] Revert "add params for put interface" This reverts commit 6432caaadf53a1fe9cf5283143ca14576d9c0eb0. --- lib/CalDAV/CalendarObject.php | 2 +- lib/CalDAV/Schedule/SchedulingObject.php | 2 +- lib/CardDAV/Card.php | 2 +- lib/DAV/CorePlugin.php | 3 +-- lib/DAV/FS/File.php | 2 +- lib/DAV/FSExt/File.php | 2 +- lib/DAV/File.php | 2 +- lib/DAV/IFile.php | 2 +- lib/DAV/Server.php | 5 +++-- 9 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/CalDAV/CalendarObject.php b/lib/CalDAV/CalendarObject.php index e49813d5c3..671f4b5dbc 100644 --- a/lib/CalDAV/CalendarObject.php +++ b/lib/CalDAV/CalendarObject.php @@ -95,7 +95,7 @@ public function get() * * @return string */ - public function put($calendarData,$params=null) + public function put($calendarData) { if (is_resource($calendarData)) { $calendarData = stream_get_contents($calendarData); diff --git a/lib/CalDAV/Schedule/SchedulingObject.php b/lib/CalDAV/Schedule/SchedulingObject.php index 2a23b36033..b40f28a947 100644 --- a/lib/CalDAV/Schedule/SchedulingObject.php +++ b/lib/CalDAV/Schedule/SchedulingObject.php @@ -62,7 +62,7 @@ public function get() * * @return string */ - public function put($calendarData,$params=null) + public function put($calendarData) { throw new MethodNotAllowed('Updating scheduling objects is not supported'); } diff --git a/lib/CardDAV/Card.php b/lib/CardDAV/Card.php index 8f4114d9d4..c9cd2bbf61 100644 --- a/lib/CardDAV/Card.php +++ b/lib/CardDAV/Card.php @@ -82,7 +82,7 @@ public function get() * * @return string|null */ - public function put($cardData,$params=null) + public function put($cardData) { if (is_resource($cardData)) { $cardData = stream_get_contents($cardData); diff --git a/lib/DAV/CorePlugin.php b/lib/DAV/CorePlugin.php index 8568b4dcba..74350c28d6 100644 --- a/lib/DAV/CorePlugin.php +++ b/lib/DAV/CorePlugin.php @@ -429,7 +429,6 @@ public function httpPut(RequestInterface $request, ResponseInterface $response) { $body = $request->getBodyAsStream(); $path = $request->getPath(); - $params = (object) array('versioning' => $request->getHeader('versioning')); // Intercepting Content-Range if ($request->getHeader('Content-Range')) { @@ -490,7 +489,7 @@ public function httpPut(RequestInterface $request, ResponseInterface $response) if (!($node instanceof IFile)) { throw new Exception\Conflict('PUT is not allowed on non-files.'); } - if (!$this->server->updateFile($path, $body, $etag,$params)) { + if (!$this->server->updateFile($path, $body, $etag)) { return false; } diff --git a/lib/DAV/FS/File.php b/lib/DAV/FS/File.php index b6c7149179..b78a801389 100644 --- a/lib/DAV/FS/File.php +++ b/lib/DAV/FS/File.php @@ -20,7 +20,7 @@ class File extends Node implements DAV\IFile * * @param resource $data */ - public function put($data,$params=null) + public function put($data) { file_put_contents($this->path, $data); clearstatcache(true, $this->path); diff --git a/lib/DAV/FSExt/File.php b/lib/DAV/FSExt/File.php index d249b52418..74849b564e 100644 --- a/lib/DAV/FSExt/File.php +++ b/lib/DAV/FSExt/File.php @@ -25,7 +25,7 @@ class File extends Node implements DAV\PartialUpdate\IPatchSupport * * @return string */ - public function put($data,$params=null) + public function put($data) { file_put_contents($this->path, $data); clearstatcache(true, $this->path); diff --git a/lib/DAV/File.php b/lib/DAV/File.php index ca203d77f4..daf83aa4d8 100644 --- a/lib/DAV/File.php +++ b/lib/DAV/File.php @@ -37,7 +37,7 @@ abstract class File extends Node implements IFile * * @return string|null */ - public function put($data,$params=null) + public function put($data) { throw new Exception\Forbidden('Permission denied to change data'); } diff --git a/lib/DAV/IFile.php b/lib/DAV/IFile.php index 00b316ff2e..974aee00dd 100644 --- a/lib/DAV/IFile.php +++ b/lib/DAV/IFile.php @@ -38,7 +38,7 @@ interface IFile extends INode * * @return string|null */ - public function put($data,$params=null); + public function put($data); /** * Returns the data. diff --git a/lib/DAV/Server.php b/lib/DAV/Server.php index 226a07cab2..1f8300d4a5 100644 --- a/lib/DAV/Server.php +++ b/lib/DAV/Server.php @@ -1120,7 +1120,7 @@ public function createFile($uri, $data, &$etag = null) * * @return bool */ - public function updateFile($uri, $data, &$etag = null,$params) + public function updateFile($uri, $data, &$etag = null) { $node = $this->tree->getNodeForPath($uri); @@ -1133,7 +1133,8 @@ public function updateFile($uri, $data, &$etag = null,$params) if (!$this->emit('beforeWriteContent', [$uri, $node, &$data, &$modified])) { return false; } - $etag = $node->put($data,$params); + + $etag = $node->put($data); if ($modified) { $etag = null; }