Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

试图INSERT空字符串到表tc_tiebastatus #284

Open
2 tasks done
n0099 opened this issue Feb 14, 2025 · 4 comments
Open
2 tasks done

试图INSERT空字符串到表tc_tiebastatus #284

n0099 opened this issue Feb 14, 2025 · 4 comments

Comments

@n0099
Copy link
Collaborator

n0099 commented Feb 14, 2025

  • 我已升级贴吧云签到到最新版本,并且运行了升级脚本
  • 我已搜索过 Issue 区,没有找到相关问题

问题描述

百度贴吧云签到 Ver.5.02  - 控制台模式
==========================================================
百度贴吧云签到 V5.02 (PHP 8.3.16) 在工作时发生致命的异常 @ 2025-02-14 09:12:55
消息:#1366 - Incorrect integer value: '' for column 'status' at row 1

文件 | 行 | 代码 |
/var/www/html/lib/class.mysqli.php | 132 | [抛出异常] |
/var/www/html/lib/class.mysqli.php | 132 | query |
/var/www/html/lib/class.misc.php | 343 | query |
/var/www/html/lib/class.misc.php | 386 | DoSign_All |
/var/www/html/lib/cron_system_sign.php | 24 | DoSign |
/var/www/html/lib/class.cron.php | 202 | cron_system_sign |
/var/www/html/lib/class.cron.php | 248 | run |
/var/www/html/do.php | 53 | runall |



real    9m47.311s
user    0m0.427s
sys     0m0.614s

复现步骤

docker exec tc-php-fpm-1 bash -c 'time php do.php'

环境

  • 云签到版本:5.02
  • 服务器系统和版本:Ubuntu 24.04.1 中的 Debian 12 docker container
  • 云签到是否在 Docker 中运行:是
  • PHP 版本:8.3.16
  • MySQL 版本:8.0.41
@n0099 n0099 added the question label Feb 14, 2025
@BANKA2017
Copy link
Collaborator

BANKA2017 commented Feb 14, 2025

CREATE TABLE `{VAR-PREFIX}tieba` (
`id` int(30) unsigned NOT NULL AUTO_INCREMENT,
`uid` int(30) unsigned NOT NULL,
`pid` int(30) unsigned NOT NULL DEFAULT '0',
`fid` int(30) unsigned NOT NULL DEFAULT '0',
`tieba` varchar(200) DEFAULT '' NOT NULL,
`no` tinyint(1) NOT NULL DEFAULT '0',
`status` mediumint(8) UNSIGNED NOT NULL DEFAULT '0' ,
`latest` tinyint(2) unsigned NOT NULL DEFAULT '0',
`last_error` text,
PRIMARY KEY (`id`),
INDEX `uid` (`uid`) USING BTREE ,
INDEX `latest` (`latest`) USING BTREE
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

可以看出 status 类型是 uint,而

$m->query("UPDATE `" . DB_NAME . "`.`" . DB_PREFIX . $table . "` SET `latest` = '" . $today . "',`status` = '" . $error_code . "',`last_error` = '" . $error_msg . "' WHERE `" . DB_PREFIX . $table . "`.`id` = '{$id}'", true);

插入的 $error_code 并没有初始值,全都是在检查中动态声明赋值的。

因为各种原因导致三种签到都没成功获取到返回内容时就会出现这种错误了

那么修复建议就显而易见了:

给变量 $error_code 一个初始值,至于这个初始值应该是什么(反正不应是 0)就有待讨论了

@BANKA2017 BANKA2017 added the bug label Feb 14, 2025
@n0099
Copy link
Collaborator Author

n0099 commented Feb 14, 2025

edit history中

  • 临时方法:设置里面不要选上网页签到(理论上客户端都能签到,另外两种有什么选上的必要吗)

但我只开启了


至于这个初始值应该是什么

建议-1或sql中的三值逻辑梦魇NULL https://news.ycombinator.com/item?id=42645110

SELECT COUNT(*), status FROM `tc_tieba` GROUP BY status;
COUNT(*) status
11326 0
66 300004
71 340006
766 3250002
654 1
9 340008
72 1990055

@BANKA2017
Copy link
Collaborator

BANKA2017 commented Feb 14, 2025

请以最终结论为准

另外 UNSIGNED NOT NULL 决定了值不能是负数或者 NULL

有一种办法是没返回/解析 json 失败的时候干脆不更新数据库,让下一次签到去处理,大概就是

if ($status_succ === true) {
    $m->query(...);
} elseif (!empty($error_code)) {
    $m->query(...);
}

截至目前我还没收到这种操作出现问题的报告

@n0099
Copy link
Collaborator Author

n0099 commented Feb 14, 2025

UNSIGNED

建议学习pgsql精神遵守iso sql使用signed类型 n0099/open-tbm#489.1.

9.1. 由于pgsql没有mysql特有(isosql不要求)带unsigned修饰的的int类型 https://stackoverflow.com/questions/20810134/why-unsigned-integer-is-not-available-in-postgresql/59802732#59802732 正如同m$ft精神mvp最爱的中小实体企业c#工控上位机人上壬 https://z.n0099.net/#narrow/near/94726 除非使用扩展 https://github.com/petere/pguint 因而

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants