X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/4c985aac7e5f84e5d00071deeae19a521db5a010..refs/pull/261/head:/app/Repos/EntityRepo.php diff --git a/app/Repos/EntityRepo.php b/app/Repos/EntityRepo.php index f1041f126..7bc5fc4fc 100644 --- a/app/Repos/EntityRepo.php +++ b/app/Repos/EntityRepo.php @@ -348,6 +348,10 @@ class EntityRepo foreach ($entities as $entity) { if ($entity->chapter_id === 0 || $entity->chapter_id === '0') continue; $parentKey = 'BookStack\\Chapter:' . $entity->chapter_id; + if (!isset($parents[$parentKey])) { + $tree[] = $entity; + continue; + } $chapter = $parents[$parentKey]; $chapter->pages->push($entity); } @@ -529,11 +533,11 @@ class EntityRepo /** * Alias method to update the book jointPermissions in the PermissionService. - * @param Collection $collection collection on entities + * @param Book $book */ - public function buildJointPermissions(Collection $collection) + public function buildJointPermissionsForBook(Book $book) { - $this->permissionService->buildJointPermissionsForEntities($collection); + $this->permissionService->buildJointPermissionsForEntity($book); } /** @@ -726,6 +730,7 @@ class EntityRepo if ($chapter) $page->chapter_id = $chapter->id; $book->pages()->save($page); + $page = $this->page->find($page->id); $this->permissionService->buildJointPermissionsForEntity($page); return $page; }