Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert PR 1365 "add params for put interface" #1375

Merged
merged 4 commits into from
Dec 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions lib/CalDAV/CalendarObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,10 @@ public function get()
* Updates the ICalendar-formatted object.
*
* @param string|resource $calendarData
* @param object|null $params
*
* @return string
*/
public function put($calendarData, $params = null)
public function put($calendarData)
{
if (is_resource($calendarData)) {
$calendarData = stream_get_contents($calendarData);
Expand Down
3 changes: 1 addition & 2 deletions lib/CalDAV/Schedule/SchedulingObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,10 @@ public function get()
* Updates the ICalendar-formatted object.
*
* @param string|resource $calendarData
* @param object|null $params
*
* @return string
*/
public function put($calendarData, $params = null)
public function put($calendarData)
{
throw new MethodNotAllowed('Updating scheduling objects is not supported');
}
Expand Down
5 changes: 2 additions & 3 deletions lib/CardDAV/Card.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,11 @@ public function get()
/**
* Updates the VCard-formatted object.
*
* @param string $cardData
* @param object|null $params
* @param string $cardData
*
* @return string|null
*/
public function put($cardData, $params = null)
public function put($cardData)
{
if (is_resource($cardData)) {
$cardData = stream_get_contents($cardData);
Expand Down
3 changes: 1 addition & 2 deletions lib/DAV/CorePlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,6 @@ public function httpPut(RequestInterface $request, ResponseInterface $response)
{
$body = $request->getBodyAsStream();
$path = $request->getPath();
$params = (object) ['versioning' => $request->getHeader('versioning')];

// Intercepting Content-Range
if ($request->getHeader('Content-Range')) {
Expand Down Expand Up @@ -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;
}

Expand Down
5 changes: 2 additions & 3 deletions lib/DAV/FS/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ 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)
public function put($data)
{
file_put_contents($this->path, $data);
clearstatcache(true, $this->path);
Expand Down
3 changes: 1 addition & 2 deletions lib/DAV/FSExt/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,10 @@ class File extends Node implements DAV\PartialUpdate\IPatchSupport
* Data is a readable stream resource.
*
* @param resource|string $data
* @param object|null $params
*
* @return string
*/
public function put($data, $params = null)
public function put($data)
{
file_put_contents($this->path, $data);
clearstatcache(true, $this->path);
Expand Down
3 changes: 1 addition & 2 deletions lib/DAV/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,10 @@ 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
*/
public function put($data, $params = null)
public function put($data)
{
throw new Exception\Forbidden('Permission denied to change data');
}
Expand Down
3 changes: 1 addition & 2 deletions lib/DAV/IFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,10 @@ interface IFile extends INode
* return an ETag, and just return null.
*
* @param resource|string $data
* @param object|null $params
*
* @return string|null
*/
public function put($data, $params = null);
public function put($data);

/**
* Returns the data.
Expand Down
12 changes: 6 additions & 6 deletions lib/DAV/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
$node = $this->tree->getNodeForPath($uri);

Expand All @@ -1134,7 +1133,8 @@ public function updateFile($uri, $data, &$etag = null, $params = null)
if (!$this->emit('beforeWriteContent', [$uri, $node, &$data, &$modified])) {
return false;
}
$etag = $node->put($data, $params);

$etag = $node->put($data);
if ($modified) {
$etag = null;
}
Expand Down
5 changes: 2 additions & 3 deletions tests/Sabre/DAV/Mock/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,11 @@ 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
*/
public function put($data, $params = null)
public function put($data)
{
if (is_resource($data)) {
$data = stream_get_contents($data);
Expand Down
5 changes: 2 additions & 3 deletions tests/Sabre/DAV/Mock/StreamingFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,11 @@ 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
*/
public function put($data, $params = null)
public function put($data)
{
if (is_string($data)) {
$stream = fopen('php://memory', 'r+');
Expand Down
8 changes: 4 additions & 4 deletions tests/Sabre/DAV/PartialUpdate/FileMock.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ class FileMock implements IPatchSupport
{
protected $data = '';

public function put($data, $params = null)
public function put($str)
{
if (is_resource($data)) {
$data = stream_get_contents($data);
if (is_resource($str)) {
$str = stream_get_contents($str);
}
$this->data = $data;
$this->data = $str;
}

/**
Expand Down