Skip to content

修复:处理题目编辑与导出中的空值及权限问题#1130

Merged
zhblue merged 2 commits intozhblue:masterfrom
jepeng-miao:master
Jan 25, 2026
Merged

修复:处理题目编辑与导出中的空值及权限问题#1130
zhblue merged 2 commits intozhblue:masterfrom
jepeng-miao:master

Conversation

@jepeng-miao
Copy link
Copy Markdown
Contributor

修复:处理题目编辑与导出中的空值及权限问题

  1. 修复题目编辑 (problem_edit.php):

    • 优雅处理写测试样例文件 (sample.in/sample.out) 时的权限错误。
      • 在 fopen 调用前添加 @ 抑制符并增加 if($fp) 检查,防止因 Web 服务器缺少数据目录写入权限而导致页面致命错误。
    • 修复 htmlentities() 中 "Passing null to parameter 修复该页面最右一列以及最下一行根本没有表格的问题。 #1" 的废弃警告。
      • 在将 remote_oj 和 remote_id 传递给 htmlentities 之前,强制转换为 (string) 类型,确保不传入 null 值。
    • 恢复数据库更新功能(移除了临时的调试打印代码)。
  2. 修复题目导出 (problem_export_xml.php):

    • 修复 str_replace() 中 "Passing null to parameter 标题出错 #3" 的废弃警告。
      • 在 fixcdata() 函数中增加空值检查,如果内容为 null 则直接返回空字符串。
    • 此修复防止了 XML 导出文件损坏,避免了 PHP 警告信息被错误地注入到 remote_oj/remote_id 标签中。

修复题目编辑 (problem_edit.php):
   - 优雅处理写测试样例文件 (sample.in/sample.out) 时的权限错误。
     - 在 `fopen` 调用前添加 `@` 抑制符并增加 `if($fp)` 检查,防止因 Web 服务器缺少数据目录写入权限而导致页面致命错误。
   - 修复 `htmlentities()` 中 "Passing null to parameter #1" 的废弃警告。
     - 在将 `remote_oj` 和 `remote_id` 传递给 `htmlentities` 之前,强制转换为 `(string)` 类型,确保不传入 null 值。
   - 恢复数据库更新功能(移除了临时的调试打印代码)。
修复题目导出 (problem_export_xml.php):
   - 修复 `str_replace()` 中 "Passing null to parameter zhblue#3" 的废弃警告。
     - 在 `fixcdata()` 函数中增加空值检查,如果内容为 null 则直接返回空字符串。
   - 此修复防止了 XML 导出文件损坏,避免了 PHP 警告信息被错误地注入到 `remote_oj`/`remote_id` 标签中。
@zhblue zhblue merged commit 81276b8 into zhblue:master Jan 25, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants