fix(reports): separate readable categories from report content
Store readable category snapshots separately from details and evidence, validate report categories, and preserve context in admin displays and moderation actions. Widen report categories to TEXT and bump the schema to 3.2.0 without legacy data conversion. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b2811cc248
commit
b45fd161f0
16 files changed
+797
-75
No files matched your search
@@ -175,34 +175,12 @@ class UserRuntime {
|
||||
public static function ban_settings(): array {
|
||||
$settings = self::read_report_section();
|
||||
|
||||
// 预置原因:group 数组 [{t:...}](对齐参考主题)或旧版每行一条文本。
|
||||
// slug 不能用 sanitize_key(标签) 派生:中文标签会被清洗成空串,
|
||||
// 导致前端按 slug 非空过滤后整列表被丢弃。改用标签内容的稳定短哈希
|
||||
// (跨请求一致、可通过服务端 sanitize_key、ASCII 标签同样稳定)。
|
||||
$reasons_raw = $settings['ban_preset_reason'] ?? null;
|
||||
$reasons_raw = $settings['ban_preset_reason'] ?? [];
|
||||
$reasons = [];
|
||||
$reason_slug = static function (string $text): string {
|
||||
$key = sanitize_key($text);
|
||||
return $key !== '' ? $key : substr(md5($text), 0, 12);
|
||||
};
|
||||
if (is_array($reasons_raw)) {
|
||||
foreach ($reasons_raw as $row) {
|
||||
$text = trim((string) ($row['t'] ?? ''));
|
||||
if ($text !== '') {
|
||||
$reasons[] = ['slug' => $reason_slug($text), 'name' => sanitize_text_field($text)];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
foreach (preg_split('/\r\n|\r|\n/', (string) $reasons_raw) as $line) {
|
||||
$line = trim((string) $line);
|
||||
if ($line === '') {
|
||||
continue;
|
||||
}
|
||||
$parts = explode('|', $line, 2);
|
||||
$reasons[] = [
|
||||
'slug' => $reason_slug((string) ($parts[1] ?? $parts[0])),
|
||||
'name' => sanitize_text_field($parts[1] ?? $parts[0]),
|
||||
];
|
||||
foreach (is_array($reasons_raw) ? $reasons_raw : [] as $row) {
|
||||
$text = is_array($row) ? sanitize_text_field((string) ($row['t'] ?? '')) : '';
|
||||
if ($text !== '') {
|
||||
$reasons[] = ['name' => $text];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user