X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/989de47f22254b10a5c13ce10e01e03d7d32a381..refs/pull/325/head:/app/Services/PermissionService.php diff --git a/app/Services/PermissionService.php b/app/Services/PermissionService.php index 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(); }