From ae5b7266d4af1909fb291690aef55808e2b463a5 Mon Sep 17 00:00:00 2001 From: Lizandro Guarnizo <77708265+lizandrogd@users.noreply.github.com> Date: Tue, 30 Jun 2026 19:11:54 -0500 Subject: [PATCH] fix: per_type is DB-only, main form save never touches it Co-Authored-By: Claude Sonnet 4.6 --- public/index.php | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/public/index.php b/public/index.php index 6a9750d..907f682 100644 --- a/public/index.php +++ b/public/index.php @@ -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'] ?? '');