Skip to content

Pass user to revision.publish() in save_target - #919

Open
efrysf wants to merge 1 commit into
wagtail:mainfrom
efrysf:fix/pass-user-to-publish
Open

Pass user to revision.publish() in save_target#919
efrysf wants to merge 1 commit into
wagtail:mainfrom
efrysf:fix/pass-user-to-publish

Conversation

@efrysf

@efrysf efrysf commented May 2, 2026

Copy link
Copy Markdown

Summary

When save_target() publishes a translated page or draftable snippet, it defers the publish via transaction.on_commit(new_revision.publish). Because publish() is called without arguments, the resulting PageLogEntry has a null user_id, making it impossible to determine who published translated content from the audit log.

This passes the user parameter through to publish() on both the Page and DraftStateMixin code paths (models.py lines 804 and 815).

Context

We discovered this while diagnosing a production issue where bulk PO file imports were triggering DataError on auto-redirect creation. All 36 publish events in PageLogEntry had null user_id, which made it difficult to trace the activity back to the users who uploaded the PO files. The user was already being passed to save_revision() on the lines immediately above, but was not forwarded to the subsequent publish() call.

Test plan

  • Existing test_save_target passes (calls save_target() without user, so user=None is forwarded — same behavior as before)
  • Full tox suite (python3.14-django5.2-wagtail7.2-sqlite): 444 tests, 0 new failures (1 pre-existing failure in test_edit_nested_snippet_translation unrelated to this change)
  • Verify PageLogEntry records the user after publishing a translated page via PO file import

🤖 Generated with Claude Code

…s the publishing user

When save_target() publishes a translated page, it defers the publish
via transaction.on_commit(new_revision.publish). Because publish() is
called without arguments, the resulting PageLogEntry has a null user_id.

This passes the user through via a lambda so the publish log entry
correctly attributes the action to the user who initiated the
translation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant