diff --git a/lib/DAV/PropFind.php b/lib/DAV/PropFind.php index e9ffb07cbc..0df2eb5361 100644 --- a/lib/DAV/PropFind.php +++ b/lib/DAV/PropFind.php @@ -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 { diff --git a/tests/Sabre/DAV/PropFindTest.php b/tests/Sabre/DAV/PropFindTest.php index ffbd4e493f..be3c4eb62b 100644 --- a/tests/Sabre/DAV/PropFindTest.php +++ b/tests/Sabre/DAV/PropFindTest.php @@ -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()); }