]> BookStack Code Mirror - bookstack/commitdiff
Merge branch 'master' of github.com:BookStackApp/BookStack
authorDan Brown <redacted>
Fri, 30 Mar 2018 13:10:36 +0000 (14:10 +0100)
committerDan Brown <redacted>
Fri, 30 Mar 2018 13:10:36 +0000 (14:10 +0100)
1  2 
app/Repos/EntityRepo.php

diff --combined app/Repos/EntityRepo.php
index e94d3436991cf425f3ba80ac4c0a8380a012d1ed,acdda3c8d08a601eee67780bcb6e351a62ff5c01..14f9d8d0eaf8c2d7a56fbed7280bdf3b79e4ec1e
@@@ -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;
      }
  
      /**
          $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;
          $scriptSearchRegex = '/<script.*?>.*?<\/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);