# \`日志匿名器详细信息\`设置未完全匿名用户名

**URL:** https://meta.discourse.org/t/log-anonymizer-details-setting-not-fully-anonymizing-usernames/387500
**Category:** Bug
**Tags:** anonymization
**Created:** [2025年十一月3日 21:35 UTC](https://meta.discourse.org/t/log-anonymizer-details-setting-not-fully-anonymizing-usernames/387500 "2025-11-03T21:35:46Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [2026年一月1日 12:52 UTC](https://meta.discourse.org/t/log-anonymizer-details-setting-not-fully-anonymizing-usernames/387500/2 "2026-01-01T12:52:13Z")

</div>

根据用户名来移除内容有点棘手/危险，所以我选择用 `[removed due to user anonymization]` 消息替换整个 context 和 details 字段

> <https://github.com/discourse/discourse/pull/36936>
>
> When \`log\_anonymizer\_details\` is disabled, the anonymization process correctly a…voids recording the old username in the new "anonymize\_user" log entry. However, historical staff action logs created before anonymization (like "check\_email") could still contain the original username in fields like \`context\` or \`previous\_value\`, making it possible to link an anonymized user back to their original identity.
> 
> For example, when an admin views a user's email from \`/admin/users/123/johndoe\`, the staff action log stores that URL path in the \`context\` field. After anonymization, this path still contains "johndoe", defeating the purpose of the setting.
> 
> This fix passes the original username to the AnonymizeUser background job, which now scrubs any historical UserHistory records that contain the username. Rather than attempting error-prone string replacement, affected fields are replaced with "\[removed due to user anonymization\]" to make it clear why the data is missing while preserving the audit trail.
> 
> Ref - https://meta.discourse.org/t/387500

---

_[View the full topic](https://meta.discourse.org/t/log-anonymizer-details-setting-not-fully-anonymizing-usernames/387500)._
