diff --git a/class/comment.php b/class/comment.php index f3740b0..c554d44 100644 --- a/class/comment.php +++ b/class/comment.php @@ -472,7 +472,15 @@ function commentListShow($tpl_dir) } // --- ПОДГОТОВКА ДАННЫХ ДЛЯ БД --- - $new_comment['parent_id'] = (int)($_POST['parent_id'] ?? 0); + + // ПРОВЕРКА РОДИТЕЛЯ: Если родитель не найден в БД, сбрасываем в 0 (корень) + $parent_id = (int)($_POST['parent_id'] ?? 0); + if ($parent_id > 0) { + $parent_exists = $AVE_DB->Query("SELECT Id FROM " . PREFIX . "_module_comment_info WHERE Id = '" . $parent_id . "'")->GetCell(); + if (!$parent_exists) $parent_id = 0; + } + $new_comment['parent_id'] = $parent_id; + $new_comment['document_id'] = (int)($_POST['doc_id'] ?? 0); $new_comment['comment_author_name'] = addslashes(strip_tags($_POST['comment_author_name'] ?? '')); $new_comment['comment_author_id'] = empty($_SESSION['user_id']) ? 0 : (int)$_SESSION['user_id'];