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.
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Anfängerfreundlichkeit
- 76/100
Rechercherichtung
Lies src/Report.php, insbesondere displayExport() im Bereich der Spaltendefinitionen, und verfolge den gemeldeten Aufruf bis zu GLPIs Spreadsheet::formatValue(). Reproduziere den Export in GLPI 12.0.2 mit dem Formular für das Adressierungsnetzwerk und untersuche die Zellwerte, die an die Tabellenausgabe übergeben werden. Als erledigt gilt die Aufgabe, wenn der Export in den aufgeführten Formaten keinen Array-Bindungsfehler mehr auslöst.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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
- Vorherrschende Sprache
- PHP
- Sterne
- 43
- Forks
- 24
- Ø Merge
- 6 Std. 30 Min.
- Gemergte PRs (30 T.)
- 1
Entwicklungsumgebung
Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus pluginsGLPI/addressing
-
Schwierigkeit 3/5 Ein halber Tag Anfängerfreundlichkeit 45/100
pluginsGLPI/addressing#131 ·
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 45/100
pluginsGLPI/addressing#129 ·
-
Enhancement: Wake on LANOffen
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 35/100
pluginsGLPI/addressing#125 ·
-
ImprovementsOffen
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 25/100
pluginsGLPI/addressing#105 ·
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 42/100
pluginsGLPI/addressing#82 · 1 Kommentar ·
Alle Issues in pluginsGLPI/addressing
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
matomo-org/plugin-CustomAlerts#310 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Bug Status: Needs Triage
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 68/100
php/web-php#2102 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
domain/checkout Platform(Default) priority/low testing/acceptance
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
Maintainer antworten meist innerhalb von 1 Tag
-
5.14.0 PIE packages still declare PHP >=8.3, so PIE installs them on PHP 8.3 and the build failsOffen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 66/100
-
bug component:user_profiles
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 85/100
knowii-oss/knowii#1689 ·
Maintainer antworten meist innerhalb von 1 Tag