Skip to content

Commit

Permalink
fix(PropFind): Include handle() props in d:allprop PROPFINDs
Browse files Browse the repository at this point in the history
Signed-off-by: provokateurin <[email protected]>
  • Loading branch information
provokateurin committed Oct 9, 2024
1 parent a6ff593 commit 2c5abeb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
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

0 comments on commit 2c5abeb

Please sign in to comment.