X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/ff8daad22b8d09def810bbcd58f1a76040ccf36f..refs/pull/5689/head:/app/Entities/Controllers/BookController.php diff --git a/app/Entities/Controllers/BookController.php b/app/Entities/Controllers/BookController.php index a1c586f47..5d3d67f64 100644 --- a/app/Entities/Controllers/BookController.php +++ b/app/Entities/Controllers/BookController.php @@ -18,6 +18,7 @@ use BookStack\Exceptions\NotFoundException; use BookStack\Facades\Activity; use BookStack\Http\Controller; use BookStack\References\ReferenceFetcher; +use BookStack\Util\DatabaseTransaction; use BookStack\Util\SimpleListOptions; use Illuminate\Http\Request; use Illuminate\Validation\ValidationException; @@ -70,7 +71,7 @@ class BookController extends Controller /** * Show the form for creating a new book. */ - public function create(string $shelfSlug = null) + public function create(?string $shelfSlug = null) { $this->checkPermission('book-create-all'); @@ -93,7 +94,7 @@ class BookController extends Controller * @throws ImageUploadException * @throws ValidationException */ - public function store(Request $request, string $shelfSlug = null) + public function store(Request $request, ?string $shelfSlug = null) { $this->checkPermission('book-create-all'); $validated = $this->validate($request, [ @@ -263,7 +264,9 @@ class BookController extends Controller $this->checkPermission('bookshelf-create-all'); $this->checkPermission('book-create-all'); - $shelf = $transformer->transformBookToShelf($book); + $shelf = (new DatabaseTransaction(function () use ($book, $transformer) { + return $transformer->transformBookToShelf($book); + }))->run(); return redirect($shelf->getUrl()); }