X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/1c43602f4bed60a84f47735ca8bc4a399018e013..refs/pull/3072/head:/app/Entities/Tools/TrashCan.php diff --git a/app/Entities/Tools/TrashCan.php b/app/Entities/Tools/TrashCan.php index 82569278e..fcf933726 100644 --- a/app/Entities/Tools/TrashCan.php +++ b/app/Entities/Tools/TrashCan.php @@ -235,13 +235,15 @@ class TrashCan { $shouldRestore = true; $restoreCount = 0; - $parent = $deletion->deletable->getParent(); - if ($parent && $parent->trashed()) { - $shouldRestore = false; + if ($deletion->deletable instanceof Entity) { + $parent = $deletion->deletable->getParent(); + if ($parent && $parent->trashed()) { + $shouldRestore = false; + } } - if ($shouldRestore) { + if ($deletion->deletable instanceof Entity && $shouldRestore) { $restoreCount = $this->restoreEntity($deletion->deletable); } @@ -323,6 +325,8 @@ class TrashCan if ($entity instanceof Bookshelf) { return $this->destroyShelf($entity); } + + return 0; } /**