Skip to content
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
18 changes: 17 additions & 1 deletion lib/DAV/PropFind.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,23 @@ public function __construct($path, array $properties, $depth = 0, $requestType =
*/
public function handle($propertyName, $valueOrCallBack)
{
if ($this->itemsLeft && isset($this->result[$propertyName]) && 404 === $this->result[$propertyName][0]) {
// If this is an ALLPROPS request and the property is
// unknown, add it to the result; else ignore it:
if (!isset($this->result[$propertyName])) {
if (self::ALLPROPS === $this->requestType) {
if (is_callable($valueOrCallBack)) {
$value = $valueOrCallBack();
} else {
$value = $valueOrCallBack;
}

$this->result[$propertyName] = [200, $value];
}

return;
}

if ($this->itemsLeft && 404 === $this->result[$propertyName][0]) {
if (is_callable($valueOrCallBack)) {
$value = $valueOrCallBack();
} else {
Expand Down
6 changes: 5 additions & 1 deletion tests/Sabre/DAV/PropFindTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,13 @@ public function testSetAllpropCustom()
{
$propFind = new PropFind('foo', ['{DAV:}displayname'], 0, PropFind::ALLPROPS);
$propFind->set('{DAV:}customproperty', 'bar');
$propFind->handle('{DAV:}otherproperty', fn () => 'baz');

self::assertEquals([
200 => ['{DAV:}customproperty' => 'bar'],
200 => [
'{DAV:}customproperty' => 'bar',
'{DAV:}otherproperty' => 'baz',
],
], $propFind->getResultForMultiStatus());
}

Expand Down