NOW MANAGED ON CODEBERG
Fixed error causing permissions to be deleted on book sort
Dan Brown492e2f173e13
diff --git a/app/Http/Controllers/BookController.php b/app/Http/Controllers/BookController.phpindex 57ac486d5..408192ff9 100644--- a/app/Http/Controllers/BookController.php+++ b/app/Http/Controllers/BookController.php@@ -208,7 +208,7 @@ class BookController extends Controller}// Update permissions on changed models- $this->entityRepo->buildJointPermissions($updatedModels);+ if (count($updatedModels) === 0) $this->entityRepo->buildJointPermissions($updatedModels);return redirect($book->getUrl());}diff --git a/app/Services/PermissionService.php b/app/Services/PermissionService.phpindex 39a2c38be..72a810b6b 100644--- a/app/Services/PermissionService.php+++ b/app/Services/PermissionService.php@@ -243,13 +243,14 @@ class PermissionService*/protected function deleteManyJointPermissionsForEntities($entities){+ if (count($entities) === 0) return;$query = $this->jointPermission->newQuery();- foreach ($entities as $entity) {- $query->orWhere(function($query) use ($entity) {- $query->where('entity_id', '=', $entity->id)- ->where('entity_type', '=', $entity->getMorphClass());- });- }+ foreach ($entities as $entity) {+ $query->orWhere(function($query) use ($entity) {+ $query->where('entity_id', '=', $entity->id)+ ->where('entity_type', '=', $entity->getMorphClass());+ });+ }$query->delete();}