Skip to content

Commit 355f48c

Browse files
committed
Fix permissions check
1 parent 072f7e1 commit 355f48c

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

src/Database/Adapter/MariaDB.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1534,7 +1534,7 @@ public function createOrUpdateDocuments(
15341534

15351535
// Calculate removals
15361536
foreach (Database::PERMISSIONS as $type) {
1537-
$toRemove = \array_diff($currentPermissions[$type], $document->getPermissionsByType($type));
1537+
$toRemove = \array_diff($currentPermissions[$type] ?? [], $document->getPermissionsByType($type));
15381538
if (!empty($toRemove)) {
15391539
$removeQueries[] = "(
15401540
_document = :_uid_{$index}
@@ -1552,16 +1552,19 @@ public function createOrUpdateDocuments(
15521552

15531553
// Calculate additions
15541554
foreach (Database::PERMISSIONS as $type) {
1555-
$toAdd = \array_diff($document->getPermissionsByType($type), $currentPermissions[$type]);
1555+
$toAdd = \array_diff($document->getPermissionsByType($type), $currentPermissions[$type] ?? []);
15561556
foreach ($toAdd as $i => $permission) {
15571557
$addQuery = "(:_uid_{$index}, '{$type}', :add_{$type}_{$index}_{$i}";
1558+
15581559
if ($this->sharedTables) {
15591560
$addQuery .= ", :_tenant_{$index}";
15601561
}
1562+
15611563
$addQuery .= ")";
15621564
$addQueries[] = $addQuery;
15631565
$addBindValues[":_uid_{$index}"] = $document->getId();
15641566
$addBindValues[":add_{$type}_{$index}_{$i}"] = $permission;
1567+
15651568
if ($this->sharedTables) {
15661569
$addBindValues[":_tenant_{$index}"] = $document->getTenant();
15671570
}

0 commit comments

Comments
 (0)