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.
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 76/100
Hướng nghiên cứu
Đọc src/Report.php, đặc biệt là displayExport() ở phần định nghĩa cột, và lần theo lệnh gọi được báo cáo đến Spreadsheet::formatValue() của GLPI. Tái hiện thao tác xuất trong GLPI 12.0.2 bằng biểu mẫu mạng định địa chỉ và kiểm tra các giá trị ô được truyền vào đầu ra bảng tính. Hoàn thành khi xuất ở các định dạng được liệt kê không còn gây ra lỗi liên kết mảng.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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
- Ngôn ngữ chính
- PHP
- Star
- 43
- Fork
- 24
- Merge trung bình
- 6 giờ 30 phút
- Pull request đã merge (30 ngày)
- 1
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của pluginsGLPI/addressing
-
Độ khó 3/5 Nửa ngày Mức phù hợp với người mới 45/100
pluginsGLPI/addressing#131 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 45/100
pluginsGLPI/addressing#129 ·
-
Enhancement: Wake on LANĐang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
pluginsGLPI/addressing#125 ·
-
ImprovementsĐang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
pluginsGLPI/addressing#105 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 42/100
pluginsGLPI/addressing#82 · 1 bình luận ·
Tất cả issue của pluginsGLPI/addressing
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
matomo-org/plugin-CustomAlerts#310 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Bug Status: Needs Triage
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 68/100
php/web-php#2102 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
domain/checkout Platform(Default) priority/low testing/acceptance
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
5.14.0 PIE packages still declare PHP >=8.3, so PIE installs them on PHP 8.3 and the build failsĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
-
bug component:user_profiles
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
knowii-oss/knowii#1689 ·
Maintainer thường phản hồi trong vòng 1 ngày