Skip to content

Commit 459859a

Browse files
committed
fix(PropFind): Include handle() props in d:allprop PROPFINDs
Signed-off-by: provokateurin <[email protected]>
1 parent a6ff593 commit 459859a

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

lib/DAV/PropFind.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,23 @@ public function __construct($path, array $properties, $depth = 0, $requestType =
9090
*/
9191
public function handle($propertyName, $valueOrCallBack)
9292
{
93-
if ($this->itemsLeft && isset($this->result[$propertyName]) && 404 === $this->result[$propertyName][0]) {
93+
// If this is an ALLPROPS request and the property is
94+
// unknown, add it to the result; else ignore it:
95+
if (!isset($this->result[$propertyName])) {
96+
if (self::ALLPROPS === $this->requestType) {
97+
if (is_callable($valueOrCallBack)) {
98+
$value = $valueOrCallBack();
99+
} else {
100+
$value = $valueOrCallBack;
101+
}
102+
103+
$this->result[$propertyName] = [200, $value];
104+
}
105+
106+
return;
107+
}
108+
109+
if ($this->itemsLeft && 404 === $this->result[$propertyName][0]) {
94110
if (is_callable($valueOrCallBack)) {
95111
$value = $valueOrCallBack();
96112
} else {

tests/Sabre/DAV/PropFindTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,13 @@ public function testSetAllpropCustom()
5252
{
5353
$propFind = new PropFind('foo', ['{DAV:}displayname'], 0, PropFind::ALLPROPS);
5454
$propFind->set('{DAV:}customproperty', 'bar');
55+
$propFind->set('{DAV:}otherproperty', 'baz');
5556

5657
self::assertEquals([
57-
200 => ['{DAV:}customproperty' => 'bar'],
58+
200 => [
59+
'{DAV:}customproperty' => 'bar',
60+
'{DAV:}otherproperty' => 'baz',
61+
],
5862
], $propFind->getResultForMultiStatus());
5963
}
6064

0 commit comments

Comments
 (0)