1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2024-10-30 07:32:39 +01:00

Fixed markdown content on revision restore

Closes #2496
This commit is contained in:
Dan Brown 2021-02-06 14:14:38 +00:00
parent 37de4e2e0a
commit a7e3c26fe3
No known key found for this signature in database
GPG Key ID: 46D9F943C24A2EF9
2 changed files with 9 additions and 7 deletions

View File

@ -223,10 +223,6 @@ class PageRepo
{
$revision = new PageRevision($page->getAttributes());
if (setting('app-editor') !== 'markdown') {
$revision->markdown = '';
}
$revision->page_id = $page->id;
$revision->slug = $page->slug;
$revision->book_slug = $page->book->slug;
@ -289,7 +285,13 @@ class PageRepo
$page->fill($revision->toArray());
$content = new PageContent($page);
$content->setNewHTML($revision->html);
if (!empty($revision->markdown)) {
$content->setNewMarkdown($revision->markdown);
} else {
$content->setNewHTML($revision->html);
}
$page->updated_by = user()->id;
$page->refreshSlug();
$page->save();

View File

@ -74,7 +74,7 @@ class PageRevisionTest extends TestCase
$page = Page::first();
$pageRepo->update($page, ['name' => 'updated page abc123', 'markdown' => '## New Content def456', 'summary' => 'initial page revision testing']);
$pageRepo->update($page, ['name' => 'updated page again', 'markdown' => '## New Content Updated', 'summary' => 'page revision testing']);
$page = Page::find($page->id);
$page = Page::find($page->id);
$pageView = $this->get($page->getUrl());
$pageView->assertDontSee('abc123');
@ -90,7 +90,7 @@ class PageRevisionTest extends TestCase
$pageView = $this->get($page->getUrl());
$this->assertDatabaseHas('pages', [
'id' => $page->id,
'markdown' => '## New Content Updated',
'markdown' => '## New Content def456',
]);
$pageView->assertSee('abc123');
$pageView->assertSee('def456');