feat(tickets): make ticket title/content/reply length limits configurable

Add ticket_title_max / ticket_content_max / ticket_reply_max to the
users/ticket schema (PHP + SPA) with clamped TicketSettings readers.
All write paths (front REST, admin REST, note REST, native admin page)
and front-end maxlength/counters now read the configured limits.
Remove the hardcoded TICKET_CONTENT_MAX constant.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
kate522andClaude Fable 5 committed 2026-10-27 23:06:28 +08:00
1 parent 6681b0c306
commit 63ab8b8fc9
13 files changed
+71 -28

No files matched your search

+3 -3
View File
@@ -311,10 +311,10 @@ final class TicketRestAdmin {
if ($user_id <= 0 || !get_userdata($user_id)) {
return new \WP_Error('aksrt_ticket_user', __('请选择工单所属用户', 'aksrt'), ['status' => 400]);
}
if ($title === '' || mb_strlen($title) > 200) {
if ($title === '' || mb_strlen($title) > TicketSettings::title_max()) {
return new \WP_Error('aksrt_ticket_title', __('请填写有效的工单标题', 'aksrt'), ['status' => 400]);
}
if ($content === '' || mb_strlen($content) > 5000) {
if ($content === '' || mb_strlen($content) > TicketSettings::content_max()) {
return new \WP_Error('aksrt_ticket_content', __('请填写有效的问题描述', 'aksrt'), ['status' => 400]);
}
if (!TicketTypeService::exists($type_id)) {
@@ -356,7 +356,7 @@ final class TicketRestAdmin {
return new \WP_Error('aksrt_ticket_closed', __('工单已关闭,无法回复', 'aksrt'), ['status' => 409]);
}
$content = trim((string) $request->get_param('content'));
if ($content === '' || mb_strlen($content) > 3000) {
if ($content === '' || mb_strlen($content) > TicketSettings::reply_max()) {
return new \WP_Error('aksrt_ticket_reply_content', __('请填写有效的回复内容', 'aksrt'), ['status' => 400]);
}
$quote_id = absint($request->get_param('quote_reply_id'));