Stop history view from breaking if a log entry's revision is missing (#12427)

e.g. after the purge_revisions management command has been run
pull/12429/head
Matt Westcott 2024-10-18 16:09:39 +01:00
rodzic 207e9e50d9
commit 72fb0e9880
4 zmienionych plików z 25 dodań i 0 usunięć

Wyświetl plik

@ -153,6 +153,7 @@ Changelog
* Fix: Fix focal point chooser when localization enabled (Sébastien Corbin) * 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: 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 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: Remove duplicate section on frontend caching proxies from performance page (Jake Howard)
* Docs: Document `restriction_type` field on PageViewRestriction (Shlomo Markowitz) * Docs: Document `restriction_type` field on PageViewRestriction (Shlomo Markowitz)
* Docs: Document Wagtail's bug bounty policy (Jake Howard) * Docs: Document Wagtail's bug bounty policy (Jake Howard)

Wyświetl plik

@ -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) * Footer action buttons now include their `media` definitions (Sage Abdullah)
* Improve the text contrast of the bulk actions "Select all" button (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) * 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 ### Documentation

Wyświetl plik

@ -1,7 +1,9 @@
from datetime import timedelta from datetime import timedelta
from io import StringIO
from django.conf import settings from django.conf import settings
from django.contrib.auth.models import Group, Permission from django.contrib.auth.models import Group, Permission
from django.core.management import call_command
from django.test import TestCase from django.test import TestCase
from django.urls import reverse from django.urls import reverse
from django.utils import timezone from django.utils import timezone
@ -305,6 +307,26 @@ class TestAuditLogAdmin(AdminTemplateTestUtils, WagtailTestUtils, TestCase):
response = self.client.get(reverse("wagtailadmin_reports:site_history")) response = self.client.get(reverse("wagtailadmin_reports:site_history"))
self.assertContains(response, expected_deleted_string) 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): def test_edit_form_has_history_link(self):
self.hello_page.save_revision() self.hello_page.save_revision()
self.login(user=self.editor) self.login(user=self.editor)

Wyświetl plik

@ -165,6 +165,7 @@ class ActionColumn(Column):
if ( if (
(url_name := self.url_names.get("revisions_unschedule")) (url_name := self.url_names.get("revisions_unschedule"))
and instance.revision
and instance.revision.approved_go_live_at and instance.revision.approved_go_live_at
and self.user_can_unschedule and self.user_can_unschedule
): ):