Exporting the IP addressing report (from an addressing network's form) fails with HTTP 500 and the generic "An unexpected error occurred" message. The plugin itself works fine otherwise.
还没有人认领这个 Issue。
评估
调研方向
阅读 src/Report.php,尤其是列定义附近的 displayExport(),并追踪报告中的调用到 GLPI 的 Spreadsheet::formatValue()。在 GLPI 12.0.2 中使用寻址网络表单重现导出,并检查传递给电子表格输出的单元格值。完成的标准是以所列格式导出时不再引发数组绑定错误。
由索引模型根据 Issue 内容生成。
描述
Code of Conduct
- I agree to follow this project's Code of Conduct
Is there an existing issue for this?
- I have searched the existing issues
GLPI Version
12.0.2
Plugin version
3.3.1
Bug description
Steps to reproduce
- Go to Tools > IP Addressing and open a network (e.g.
addressing.form.php?id=2) - Choose any export format (e.g. PDF landscape) and start the export
- → HTTP 500, "An unexpected error occurred"
Request:
GET /front/report.dynamic.php?item_type=GlpiPlugin%5CAddressing%5CReport&id=2&ping_on=1&ping_off=1&filter=0&seeallotedip=1&seedoubleip=1&seereservedip=1&seefreeip=1&start=0&display_type=2&export=
Expected behavior
The report is exported in the selected format.
Actual behavior
glpi.CRITICAL: *** Uncaught PHP Exception PhpOffice\PhpSpreadsheet\Exception: "Unable to bind unstringable array" at DefaultValueBinder.php line 43
Backtrace :
...c/PhpSpreadsheet/Cell/DefaultValueBinder.php:43
...preadsheet/src/PhpSpreadsheet/Cell/Cell.php:252 PhpOffice\PhpSpreadsheet\Cell\DefaultValueBinder->bindValue()
...src/PhpSpreadsheet/Worksheet/Worksheet.php:1219 PhpOffice\PhpSpreadsheet\Cell\Cell->setValue()
./src/Glpi/Search/Output/Spreadsheet.php:596 PhpOffice\PhpSpreadsheet\Worksheet\Worksheet->setCellValue()
./src/Glpi/Search/Output/Spreadsheet.php:151 Glpi\Search\Output\Spreadsheet->formatValue()
.../glpi/marketplace/addressing/src/Report.php:451 Glpi\Search\Output\Spreadsheet->displayData()
.../glpi/marketplace/addressing/src/Report.php:113 GlpiPlugin\Addressing\Report::displayExport()
/var/glpi/marketplace/addressing/hook.php:444 GlpiPlugin\Addressing\Report->displayReport()
./src/Plugin.php:1913 plugin_addressing_dynamicReport()
./front/report.dynamic.php:116 Plugin::doOneHook()
...Glpi/Controller/LegacyFileLoadController.php:64 require()
...
./public/index.php:78 Glpi\Kernel\Kernel->handle()
Root cause
In GLPI 12, Glpi\Search\Output\Spreadsheet::formatValue() only unwraps a cell array (['displayname' => ...]) when the column options contain a searchopt key:
if (is_array($value) && isset($options['searchopt'])) {
...
$value = DataExport::normalizeValueForTextExport($value['displayname'] ?? '');
}
$worksheet->setCellValue([$x_coordinate, $y_coordinate], $value);
Report::displayExport() builds its column definitions without searchopt, so the whole cell array is passed to setCellValue(), which throws Unable to bind unstringable array. As GLPI 12 handles all non-HTML outputs via Spreadsheet, this affects every export format (PDF, CSV, ODS, XLSX).
Proposed fix
In src/Report.php, displayExport():
$colid = 0;
foreach ($headers as $header) {
$addressing_data['data']['cols'][] = [
- 'name' => $header,
- 'itemtype' => $itemtype,
- 'id' => ++$colid,
+ 'name' => $header,
+ 'itemtype' => $itemtype,
+ 'id' => ++$colid,
+ // Spreadsheet::formatValue() only unwraps the cell array
+ // (['displayname' => ...]) when a search option is given.
+ 'searchopt' => ['datatype' => 'string'],
];
}
Using datatype => 'string' avoids the date formatting branch and lets normalizeValueForTextExport() decode the escaped displayname, as displayExport() already expects.
Tested on GLPI 12.0.2: export works again with this change.
Relevant log output
Page URL
No response
Steps To reproduce
No response
Your GLPI setup information
No response
Anything else?
No response
- 主要语言
- PHP
- 星标
- 43
- 派生
- 24
- 平均合并
- 6 小时 30 分钟
- 30 天内合并 PR
- 1
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
pluginsGLPI/addressing 的其他 Issue
-
难度 3/5 半天 新手友好度 45/100
pluginsGLPI/addressing#131 ·
-
难度 3/5 1-2 天 新手友好度 45/100
pluginsGLPI/addressing#129 ·
-
难度 4/5 3-5 天 新手友好度 35/100
pluginsGLPI/addressing#125 ·
-
Improvements未关闭
难度 5/5 一周以上 新手友好度 25/100
pluginsGLPI/addressing#105 ·
-
难度 3/5 1-2 天 新手友好度 42/100
pluginsGLPI/addressing#82 · 1 条评论 ·
查看 pluginsGLPI/addressing 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 65/100
matomo-org/plugin-CustomAlerts#310 ·
维护者通常 1 天内回复
-
Bug Status: Needs Triage
难度 1/5 1 小时以内 新手友好度 68/100
维护者通常 1 天内回复
-
domain/checkout Platform(Default) priority/low testing/acceptance
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
5.14.0 PIE packages still declare PHP >=8.3, so PIE installs them on PHP 8.3 and the build fails未关闭
难度 2/5 1-3 小时 新手友好度 66/100
-
bug component:user_profiles
难度 2/5 1-3 小时 新手友好度 85/100
knowii-oss/knowii#1689 ·
维护者通常 1 天内回复