fix: 修复 PHP 8.2 下 bug 模块因 session 异常值导致的 TypeError#187
Open
whjstc wants to merge 1 commit intoeasysoft:mainfrom
Open
fix: 修复 PHP 8.2 下 bug 模块因 session 异常值导致的 TypeError#187whjstc wants to merge 1 commit intoeasysoft:mainfrom
whjstc wants to merge 1 commit intoeasysoft:mainfrom
Conversation
|
收到。谢谢反馈。:) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题描述
在 PHP 8.2 环境下,访问 Bug 相关页面时,
bug模块构造函数会根据当前 tab 从 session 读取project/execution,并将其传给productModel::getProducts()。当前代码直接读取:
当 session 中的
project或execution异常为false、null或空字符串时,会继续传入:而
productModel::getProducts()在 PHP 8.2 下带有更严格的参数类型约束,bool传入后会直接触发TypeError,导致页面 fatal error。报错示例:
修复方案
在
module/bug/control.php中为 session 读取结果增加兜底处理:zget()读取 session 值false、null、空字符串统一归一为0getProducts()的始终是合法的int|array修复后不改变正常业务逻辑,仅在 session 异常值场景下回退到默认值,避免 PHP 8.2 下的致命错误。
影响范围
bug模块初始化时对 session 中project/execution的读取验证
php -lgetProducts()传入false