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

DAV\PropPatch::handleRemaining should only register one callback #1553

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
10 changes: 5 additions & 5 deletions lib/DAV/PropPatch.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,12 @@ public function handleRemaining(callable $callback)
foreach ($properties as $propertyName) {
// HTTP Accepted
$this->result[$propertyName] = 202;

$this->propertyUpdateCallbacks[] = [
$properties,
$callback,
];
}

$this->propertyUpdateCallbacks[] = [
$properties,
$callback,
];
}

/**
Expand Down
26 changes: 26 additions & 0 deletions tests/Sabre/DAV/PropPatchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,32 @@ public function testHandleRemaining()
self::assertTrue($hasRan);
}

public function testHandleMultipleRemaining()
{
$cunCounter = 0;

$this->propPatch = new PropPatch([
'{DAV:}displayname' => 'foo',
'unittest' => 'bar',
]);

$this->propPatch->handleRemaining(function ($mutations) use (&$cunCounter) {
++$cunCounter;
self::assertCount(2, $mutations);

return true;
});

self::assertTrue($this->propPatch->commit());
$result = $this->propPatch->getResult();
self::assertEquals([
'{DAV:}displayname' => 200,
'unittest' => 200,
], $result);

self::assertSame(1, $cunCounter);
}

public function testHandleRemainingNothingToDo()
{
$hasRan = false;
Expand Down