X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/1c43602f4bed60a84f47735ca8bc4a399018e013..refs/pull/3630/head:/app/Http/Controllers/PageRevisionController.php diff --git a/app/Http/Controllers/PageRevisionController.php b/app/Http/Controllers/PageRevisionController.php index d595a6e26..086518960 100644 --- a/app/Http/Controllers/PageRevisionController.php +++ b/app/Http/Controllers/PageRevisionController.php @@ -2,9 +2,11 @@ namespace BookStack\Http\Controllers; +use BookStack\Actions\ActivityType; use BookStack\Entities\Repos\PageRepo; use BookStack\Entities\Tools\PageContent; use BookStack\Exceptions\NotFoundException; +use BookStack\Facades\Activity; use Ssddanbrown\HtmlDiff\Diff; class PageRevisionController extends Controller @@ -124,17 +126,15 @@ class PageRevisionController extends Controller throw new NotFoundException("Revision #{$revId} not found"); } - // Get the current revision for the page - $currentRevision = $page->getCurrentRevision(); - - // Check if its the latest revision, cannot delete latest revision. - if (intval($currentRevision->id) === intval($revId)) { + // Check if it's the latest revision, cannot delete the latest revision. + if (intval($page->currentRevision->id ?? null) === intval($revId)) { $this->showErrorNotification(trans('entities.revision_cannot_delete_latest')); return redirect($page->getUrl('/revisions')); } $revision->delete(); + Activity::add(ActivityType::REVISION_DELETE, $revision); $this->showSuccessNotification(trans('entities.revision_delete_success')); return redirect($page->getUrl('/revisions'));