fix(export): 修复Excel导出zipstream库PHP8兼容性与临时文件安全流式输出

这个提交包含在:
chen
2026-09-21 15:19:30 +08:00
父节点 d664c7eb85
当前提交 452c2f22a2
共有 15 个文件被更改,包括 132 次插入 和 100 次删除

查看文件

@@ -40,12 +40,20 @@ assert(modelContent.includes('is_numeric($rate)'), 'getChargeRateFormatAttr 包
assert(modelContent.includes('is_numeric($amount)'), 'getRealAmountAttr 包含 is_numeric 校验');
console.log('[测试点 2] Withdraw 模型源代码加固断言通过');
// 3. 检查 addons/shopro/library/Export.php 包含缓冲检查与下载退出
// 3. 检查 addons/shopro/library/Export.php 包含缓冲检查、临时文件生成与安全输出
const exportContent = fs.readFileSync(path.resolve(__dirname, '../../addons/shopro/library/Export.php'), 'utf8');
assert(exportContent.includes('ob_get_level() > 0'), 'Export.php 包含 ob_get_level() 检查防 Notice');
assert(exportContent.includes("if ($this->config['save_type'] != 'save')"), 'Export.php 包含下载模式检查');
assert(exportContent.includes('temp/export/'), 'Export.php 优先写入临时文件校验');
assert(exportContent.includes('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'), 'Export.php 使用标准 xlsx mime 类型');
assert(exportContent.includes('Content-Length'), 'Export.php 包含 Content-Length 响应头');
assert(exportContent.includes("if ($this->config['save_type'] == 'save')"), 'Export.php 包含 save_type 判断');
assert(exportContent.includes('exit;'), 'Export.php 下载完成安全退出');
console.log('[测试点 3] Export.php 缓冲区安全清理与下载模式防污染退出断言通过');
console.log('[测试点 3] Export.php 临时文件安全写入、标准MIME与下载防污染退出断言通过');
// 3.1 检查 composer.json 锁定 maennchen/zipstream-php: ^2.4 防 PHP 8.1 readonly 语法错误
const composerContent = fs.readFileSync(path.resolve(__dirname, '../../composer.json'), 'utf8');
assert(composerContent.includes('"maennchen/zipstream-php": "^2.4"'), 'composer.json 锁定 zipstream-php: ^2.4');
console.log('[测试点 3.1] composer.json 兼容性依赖锁定断言通过');
// 4. 检查 application/admin/controller/shopro/Withdraw.php 包含异常捕获、单 key 汇总、时间格式化
const controllerContent = fs.readFileSync(path.resolve(__dirname, '../../application/admin/controller/shopro/Withdraw.php'), 'utf8');