mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-10-30 07:32:39 +01:00
Fixed revision issues caused by page fillable changes
This commit is contained in:
parent
31514bae06
commit
3502abdd49
@ -278,7 +278,7 @@ class PageRepo
|
||||
$revision = $page->revisions()->where('id', '=', $revisionId)->first();
|
||||
$page->fill($revision->toArray());
|
||||
$content = new PageContent($page);
|
||||
$content->setNewHTML($page->html);
|
||||
$content->setNewHTML($revision->html);
|
||||
$page->updated_by = user()->id;
|
||||
$page->refreshSlug();
|
||||
$page->save();
|
||||
|
@ -1,5 +1,6 @@
|
||||
<?php namespace BookStack\Http\Controllers;
|
||||
|
||||
use BookStack\Entities\Managers\PageContent;
|
||||
use BookStack\Entities\Repos\PageRepo;
|
||||
use BookStack\Exceptions\NotFoundException;
|
||||
use BookStack\Facades\Activity;
|
||||
@ -46,6 +47,9 @@ class PageRevisionController extends Controller
|
||||
}
|
||||
|
||||
$page->fill($revision->toArray());
|
||||
// TODO - Refactor PageContent so we don't need to juggle this
|
||||
$page->html = $revision->html;
|
||||
$page->html = (new PageContent($page))->render();
|
||||
|
||||
$this->setPageTitle(trans('entities.pages_revision_named', ['pageName' => $page->getShortName()]));
|
||||
return view('pages.revision', [
|
||||
@ -73,6 +77,9 @@ class PageRevisionController extends Controller
|
||||
$diff = (new Htmldiff)->diff($prevContent, $revision->html);
|
||||
|
||||
$page->fill($revision->toArray());
|
||||
// TODO - Refactor PageContent so we don't need to juggle this
|
||||
$page->html = $revision->html;
|
||||
$page->html = (new PageContent($page))->render();
|
||||
$this->setPageTitle(trans('entities.pages_revision_named', ['pageName'=>$page->getShortName()]));
|
||||
|
||||
return view('pages.revision', [
|
||||
|
@ -24,6 +24,21 @@ class PageRevisionTest extends TestCase
|
||||
$revisionView->assertSee('new content');
|
||||
}
|
||||
|
||||
public function test_page_revision_preview_shows_content_of_revision()
|
||||
{
|
||||
$this->asEditor();
|
||||
|
||||
$pageRepo = app(PageRepo::class);
|
||||
$page = Page::first();
|
||||
$pageRepo->update($page, ['name' => 'updated page', 'html' => '<p>new revision content</p>', 'summary' => 'page revision testing']);
|
||||
$pageRevision = $page->revisions->last();
|
||||
$pageRepo->update($page, ['name' => 'updated page', 'html' => '<p>Updated content</p>', 'summary' => 'page revision testing 2']);
|
||||
|
||||
$revisionView = $this->get($page->getUrl() . '/revisions/' . $pageRevision->id);
|
||||
$revisionView->assertStatus(200);
|
||||
$revisionView->assertSee('new revision content');
|
||||
}
|
||||
|
||||
public function test_page_revision_restore_updates_content()
|
||||
{
|
||||
$this->asEditor();
|
||||
|
Loading…
Reference in New Issue
Block a user