fix(AdminGoodsSaveHandle): P1+P2 空安全修复 — 解决 "Undefined array key 'id'" 错误

P1 (line 80): array_filter 回调内 $r['id'] 前加 isset() 空安全
P2 (line 71-73): find() 返回 null 时 continue 跳过,避免访问 $template['seat_map']

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
council/BackendArchitect
Council 2026-04-20 09:59:31 +08:00
parent 8211419400
commit 804d465d09
1 changed files with 4 additions and 1 deletions

View File

@ -68,13 +68,16 @@ class AdminGoodsSaveHandle
$templateId = intval($config['template_id'] ?? 0);
if ($templateId > 0) {
$template = Db::name('vr_seat_templates')->find($templateId);
if (empty($template)) {
continue;
}
$seatMap = json_decode($template['seat_map'] ?? '{}', true);
$allRooms = $seatMap['rooms'] ?? [];
// 按 selected_rooms 过滤,只存用户选中的房间
$selectedRoomIds = array_column(
array_filter($allRooms, function ($r) use ($config) {
return in_array($r['id'], $config['selected_rooms'] ?? []);
return isset($r['id']) && in_array($r['id'], $config['selected_rooms'] ?? []);
}), null
);