diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 2b52ee7299..a4ec69fe00 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -153,6 +153,7 @@ Changelog * Fix: Fix focal point chooser when localization enabled (Sébastien Corbin) * Fix: Ensure that system checks for `WAGTAIL_DATE_FORMAT`, `WAGTAIL_DATETIME_FORMAT` and `WAGTAIL_TIME_FORMAT` take `FORMAT_MODULE_PATH` into account (Sébastien Corbin) * Fix: Prevent rich text fields inside choosers from being duplicated when opened repeatedly (Sage Abdullah) + * Fix: Prevent history view from breaking if a log entry's revision is missing (Matt Westcott) * Docs: Remove duplicate section on frontend caching proxies from performance page (Jake Howard) * Docs: Document `restriction_type` field on PageViewRestriction (Shlomo Markowitz) * Docs: Document Wagtail's bug bounty policy (Jake Howard) diff --git a/docs/releases/6.3.md b/docs/releases/6.3.md index 116a26e7e7..c0af50686c 100644 --- a/docs/releases/6.3.md +++ b/docs/releases/6.3.md @@ -99,6 +99,7 @@ This feature was developed by Bart Cieliński, alexkiro, and Sage Abdullah. * Footer action buttons now include their `media` definitions (Sage Abdullah) * Improve the text contrast of the bulk actions "Select all" button (Sage Abdullah) * Fix error on workflow settings view with multiple snippet types assigned to the same workflow on Postgres (Sage Abdullah) + * Prevent history view from breaking if a log entry's revision is missing (Matt Westcott) ### Documentation diff --git a/wagtail/admin/tests/test_audit_log.py b/wagtail/admin/tests/test_audit_log.py index 7e823e2966..8c189b54a5 100644 --- a/wagtail/admin/tests/test_audit_log.py +++ b/wagtail/admin/tests/test_audit_log.py @@ -1,7 +1,9 @@ from datetime import timedelta +from io import StringIO from django.conf import settings from django.contrib.auth.models import Group, Permission +from django.core.management import call_command from django.test import TestCase from django.urls import reverse from django.utils import timezone @@ -305,6 +307,26 @@ class TestAuditLogAdmin(AdminTemplateTestUtils, WagtailTestUtils, TestCase): response = self.client.get(reverse("wagtailadmin_reports:site_history")) self.assertContains(response, expected_deleted_string) + def test_page_history_after_revision_purge(self): + self._update_page(self.hello_page) + call_command("purge_revisions", days=0, stdout=StringIO()) + + history_url = reverse( + "wagtailadmin_pages:history", kwargs={"page_id": self.hello_page.id} + ) + + self.login(user=self.editor) + + response = self.client.get(history_url) + self.assertEqual(response.status_code, 200) + + self.assertContains(response, "Created", 1) + self.assertContains(response, "Draft saved", 2) + self.assertContains(response, "Locked", 1) + self.assertContains(response, "Unlocked", 1) + self.assertContains(response, "Page scheduled for publishing", 1) + self.assertContains(response, "Published", 1) + def test_edit_form_has_history_link(self): self.hello_page.save_revision() self.login(user=self.editor) diff --git a/wagtail/admin/views/generic/history.py b/wagtail/admin/views/generic/history.py index 2944a93359..4d01671afe 100644 --- a/wagtail/admin/views/generic/history.py +++ b/wagtail/admin/views/generic/history.py @@ -165,6 +165,7 @@ class ActionColumn(Column): if ( (url_name := self.url_names.get("revisions_unschedule")) + and instance.revision and instance.revision.approved_go_live_at and self.user_can_unschedule ):