fix: per_type is DB-only, main form save never touches it

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Lizandro Guarnizo
2026-06-30 19:11:54 -05:00
co-authored by Claude Sonnet 4.6
parent 3c79fac8d7
commit ae5b7266d4
+3 -17
View File
@@ -540,24 +540,10 @@ $routes = [
$geminiModel = trim($_POST['gemini_model'] ?? '');
if ($geminiModel !== '') $config['gemini_model'] = $geminiModel;
// Per-category menus — base on DB value so form size limits can't wipe it
$perTypeMenus = $_POST['per_type_menu'] ?? [];
$dbPerType = $existingConfig['per_type'] ?? [];
$perType = (is_array($dbPerType) && $dbPerType !== [] && !isset($dbPerType[0])) ? $dbPerType : [];
if (!empty($perTypeMenus)) {
// POST has per_type data — apply it on top of DB value
foreach ([1, 2, 3] as $cat) {
$mk = trim($perTypeMenus[$cat] ?? '');
$key = (string)$cat;
if ($mk !== '') {
$perType[$key] = array_merge($perType[$key] ?? [], ['greeting_menu' => $mk]);
} else {
unset($perType[$key]['greeting_menu']);
if (empty($perType[$key])) unset($perType[$key]);
}
}
// per_type is managed exclusively via /admin/bot-config/save-per-type — copy as-is from DB
if (isset($existingConfig['per_type'])) {
$config['per_type'] = $existingConfig['per_type'];
}
$config['per_type'] = empty($perType) ? new stdClass() : $perType;
// General
$greeting = trim($_POST['greeting'] ?? '');