优化部分代码,增加微信公众号模板

This commit is contained in:
李琦
2026-08-13 19:01:21 +08:00
parent 21f39eed85
commit 2f5e298d6b
10 changed files with 83 additions and 41 deletions

View File

@@ -141,13 +141,19 @@ class BaseController
$result = [];
foreach ($checkFields as $fieldName) {
$checkValue = $data[$fieldName] ?? '';
if (is_array($checkValue) && !empty($checkValue)) {
$result[$fieldName] = $checkValue;
if (is_array($checkValue)) {
// 数组值单独处理:非空才收;空数组按「跳过」(与 GF 版一致),
// 且绝不对数组做 strval避免触发 "Array to string conversion" 警告
if (!empty($checkValue)) {
$result[$fieldName] = $checkValue;
}
} else {
if (mb_strlen(strval($checkValue)) <= 0 && !in_array($fieldName, $this->notRequest)) {
$requiredFields[] = $fieldName;
} else {
if (!empty($checkValue) || $checkValue === 0) {
// 用字符串长度判断是否有值,避免 !empty 把合法的 0 / "0" 误当空丢弃
// HTTP 参数皆为字符串status=0 会传成 "0",原写法会导致状态无法写入/改回启用)
if (mb_strlen(strval($checkValue)) > 0) {
$result[$fieldName] = $checkValue;
}
}