Skip to content

Commit c6ed913

Browse files
committed
Ensure permissions are set on response
1 parent a325b19 commit c6ed913

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/Database/Database.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4729,8 +4729,10 @@ public function createOrUpdateDocumentsWithIncrease(
47294729
)));
47304730
}
47314731

4732-
$disallowed = ['$tenant', '$internalId'];
4733-
if ($old->getArrayCopy(disallow: $disallowed) == $document->getArrayCopy(disallow: $disallowed)) {
4732+
$updatesPermissions = \in_array('$permissions', \array_keys($document->getArrayCopy()))
4733+
&& $document->getPermissions() != $old->getPermissions();
4734+
4735+
if ($old->getAttributes() == $document->getAttributes() && !$updatesPermissions) {
47344736
unset($documents[$key]);
47354737
continue;
47364738
}
@@ -4765,6 +4767,10 @@ public function createOrUpdateDocumentsWithIncrease(
47654767
->setAttribute('$createdAt', empty($createdAt) || !$this->preserveDates ? $time : $createdAt)
47664768
->setAttribute('$updatedAt', empty($updatedAt) || !$this->preserveDates ? $time : $updatedAt);
47674769

4770+
if (!$updatesPermissions) {
4771+
$document->setAttribute('$permissions', $old->getPermissions());
4772+
}
4773+
47684774
if ($this->adapter->getSharedTables()) {
47694775
if ($this->adapter->getTenantPerDocument()) {
47704776
if ($document->getTenant() === null) {

0 commit comments

Comments
 (0)