fix(report): give preset reasons a stable non-empty slug for CJK labels
ban_settings() derived each reason slug via sanitize_key(label), which strips CJK text to an empty string; the frontend filter then discarded every reason (including the schema defaults) and fell back to the hard-coded list. Derive the slug from an ASCII key when possible and from a stable md5 short hash of the label otherwise, and relax the frontend filter to the label only. Adds a WP-stub harness that verifies the defaults path end to end (tests/dev/verify-ban-settings-defaults.php).
This commit is contained in:
@@ -108,6 +108,10 @@ test('ban/report settings page mirrors the reference theme schema', () => {
|
||||
// 缺键回退 schema 默认值(参考主题 _pz 语义):运行时经 read_domain 读取,
|
||||
// 裸 get_all() 会让未保存过分区的站点拿不到 ban_preset_reason 默认值。
|
||||
assert.match(runtime, /read_domain\('users', 'report'\)/)
|
||||
// 预置原因 slug 不得由 sanitize_key(标签) 直接派生:中文标签会被清洗成
|
||||
// 空串,前端按 slug 非空过滤后整张原因列表会被丢弃。ASCII 键优先,
|
||||
// 否则用标签内容的稳定 md5 短哈希。
|
||||
assert.match(runtime, /md5\(\$text\)/)
|
||||
// 死链清理:user_report_categories 从不是真实存储键,解析器必须删除。
|
||||
assert.ok(!runtime.includes('parse_report_categories'), 'dead parse_report_categories must stay removed')
|
||||
assert.ok(!runtime.includes('user_report_categories'), 'dead user_report_categories key must stay removed')
|
||||
|
||||
Reference in New Issue
Block a user