From: Dan Brown Date: Fri, 30 Mar 2018 13:10:36 +0000 (+0100) Subject: Merge branch 'master' of github.com:BookStackApp/BookStack X-Git-Tag: v0.21.0~1^2~21 X-Git-Url: http://source.bookstackapp.com/bookstack/commitdiff_plain/58a6b2df7db982f0575e79493257ef68a8468a81?ds=inline;hp=-c Merge branch 'master' of github.com:BookStackApp/BookStack --- 58a6b2df7db982f0575e79493257ef68a8468a81 diff --combined app/Repos/EntityRepo.php index e94d34369,acdda3c8d..14f9d8d0e --- a/app/Repos/EntityRepo.php +++ b/app/Repos/EntityRepo.php @@@ -492,19 -492,14 +492,19 @@@ class EntityRep public function createFromInput($type, $input = [], $book = false) { $isChapter = strtolower($type) === 'chapter'; - $entity = $this->getEntity($type)->newInstance($input); - $entity->slug = $this->findSuitableSlug($type, $entity->name, false, $isChapter ? $book->id : false); - $entity->created_by = user()->id; - $entity->updated_by = user()->id; - $isChapter ? $book->chapters()->save($entity) : $entity->save(); - $this->permissionService->buildJointPermissionsForEntity($entity); - $this->searchService->indexEntity($entity); - return $entity; + $entityModel = $this->getEntity($type)->newInstance($input); + $entityModel->slug = $this->findSuitableSlug($type, $entityModel->name, false, $isChapter ? $book->id : false); + $entityModel->created_by = user()->id; + $entityModel->updated_by = user()->id; + $isChapter ? $book->chapters()->save($entityModel) : $entityModel->save(); + + if (isset($input['tags'])) { + $this->tagRepo->saveTagsToEntity($entityModel, $input['tags']); + } + + $this->permissionService->buildJointPermissionsForEntity($entityModel); + $this->searchService->indexEntity($entityModel); + return $entityModel; } /** @@@ -523,11 -518,6 +523,11 @@@ $entityModel->fill($input); $entityModel->updated_by = user()->id; $entityModel->save(); + + if (isset($input['tags'])) { + $this->tagRepo->saveTagsToEntity($entityModel, $input['tags']); + } + $this->permissionService->buildJointPermissionsForEntity($entityModel); $this->searchService->indexEntity($entityModel); return $entityModel; @@@ -784,7 -774,9 +784,9 @@@ $scriptSearchRegex = '/.*?<\/script>/ms'; $matches = []; preg_match_all($scriptSearchRegex, $html, $matches); - if (count($matches) === 0) return $html; + if (count($matches) === 0) { + return $html; + } foreach ($matches[0] as $match) { $html = str_replace($match, htmlentities($match), $html);