Pass user to revision.publish() in save_target - #919
Open
efrysf wants to merge 1 commit into
Open
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When
save_target()publishes a translated page or draftable snippet, it defers the publish viatransaction.on_commit(new_revision.publish). Becausepublish()is called without arguments, the resultingPageLogEntryhas a nulluser_id, making it impossible to determine who published translated content from the audit log.This passes the
userparameter through topublish()on both thePageandDraftStateMixincode paths (models.py lines 804 and 815).Context
We discovered this while diagnosing a production issue where bulk PO file imports were triggering
DataErroron auto-redirect creation. All 36 publish events inPageLogEntryhad nulluser_id, which made it difficult to trace the activity back to the users who uploaded the PO files. Theuserwas already being passed tosave_revision()on the lines immediately above, but was not forwarded to the subsequentpublish()call.Test plan
test_save_targetpasses (callssave_target()without user, souser=Noneis forwarded — same behavior as before)python3.14-django5.2-wagtail7.2-sqlite): 444 tests, 0 new failures (1 pre-existing failure intest_edit_nested_snippet_translationunrelated to this change)PageLogEntryrecords the user after publishing a translated page via PO file import🤖 Generated with Claude Code