mirror of
https://github.com/BookStackApp/BookStack.git
synced 2026-05-04 18:08:46 +03:00
Compare commits
1 Commits
developmen
...
tortillas5
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a81d59029d |
@@ -118,27 +118,29 @@ class PageRepo
|
|||||||
*/
|
*/
|
||||||
public function update(Page $page, array $input): Page
|
public function update(Page $page, array $input): Page
|
||||||
{
|
{
|
||||||
// Hold the old details to compare later
|
// Hold the old details to compare later.
|
||||||
$oldName = $page->name;
|
$oldName = $page->name;
|
||||||
$oldHtml = $page->html;
|
$oldHtml = $page->html;
|
||||||
$oldMarkdown = $page->markdown;
|
$oldMarkdown = $page->markdown;
|
||||||
|
|
||||||
$this->updateTemplateStatusAndContentFromInput($page, $input);
|
$this->updateTemplateStatusAndContentFromInput($page, $input);
|
||||||
$page = $this->baseRepo->update($page, $input);
|
|
||||||
|
|
||||||
// Update with new details
|
// Values used to determine if a change has been made.
|
||||||
$page->revision_count++;
|
|
||||||
$page->save();
|
|
||||||
|
|
||||||
// Remove all update drafts for this user and page.
|
|
||||||
$this->revisionRepo->deleteDraftsForCurrentUser($page);
|
|
||||||
|
|
||||||
// Save a revision after updating
|
|
||||||
$summary = trim($input['summary'] ?? '');
|
$summary = trim($input['summary'] ?? '');
|
||||||
$htmlChanged = isset($input['html']) && $input['html'] !== $oldHtml;
|
$htmlChanged = isset($page->html) && $page->html !== $oldHtml;
|
||||||
$nameChanged = isset($input['name']) && $input['name'] !== $oldName;
|
$nameChanged = isset($input['name']) && $input['name'] !== $oldName;
|
||||||
$markdownChanged = isset($input['markdown']) && $input['markdown'] !== $oldMarkdown;
|
$markdownChanged = isset($page->markdown) && $page->markdown !== $oldMarkdown;
|
||||||
|
|
||||||
|
// Update with new details, only if the page really changed.
|
||||||
if ($htmlChanged || $nameChanged || $markdownChanged || $summary) {
|
if ($htmlChanged || $nameChanged || $markdownChanged || $summary) {
|
||||||
|
$page = $this->baseRepo->update($page, $input);
|
||||||
|
|
||||||
|
$page->revision_count++;
|
||||||
|
$page->save();
|
||||||
|
|
||||||
|
// Remove all update drafts for this user and page.
|
||||||
|
$this->revisionRepo->deleteDraftsForCurrentUser($page);
|
||||||
|
|
||||||
$this->revisionRepo->storeNewForPage($page, $summary);
|
$this->revisionRepo->storeNewForPage($page, $summary);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user