From 37567dfe1844d39784793942fb8cdbaae6ba6ef0 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Fri, 4 Oct 2024 10:49:55 +0100 Subject: [PATCH] Check workflow cancel before getting workflow --- wagtail/actions/publish_revision.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/wagtail/actions/publish_revision.py b/wagtail/actions/publish_revision.py index 79c07df7d5..5d27f738ca 100644 --- a/wagtail/actions/publish_revision.py +++ b/wagtail/actions/publish_revision.py @@ -94,9 +94,8 @@ class PublishRevisionAction: ) if isinstance(self.object, WorkflowMixin): - workflow_state = self.object.current_workflow_state - if workflow_state and getattr( - settings, "WAGTAIL_WORKFLOW_CANCEL_ON_PUBLISH", True + if getattr(settings, "WAGTAIL_WORKFLOW_CANCEL_ON_PUBLISH", True) and ( + workflow_state := self.object.current_workflow_state ): workflow_state.cancel(user=self.user)