From ca8b1c56d36d4d893d5b2100682893b50822e7cd Mon Sep 17 00:00:00 2001 From: Rom1-B <8530352+Rom1-B@users.noreply.github.com> Date: Tue, 19 May 2026 10:24:32 +0200 Subject: [PATCH] Fix: prevent crash and warnings on items export for Problems and Changes --- CHANGELOG.md | 2 ++ inc/change_item.class.php | 8 ++++---- inc/item_problem.class.php | 8 ++++---- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 813e79f..8b200c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - Fixed table formatting and border in PDF - Fixed table cell size in PDF generation +- Fixed PDF crash when exporting Problems with linked items lacking serial/inventory fields +- Fixed PHP warnings flood when exporting Changes with linked items lacking serial/inventory fields ## [4.0.2] - 2025-09-30 diff --git a/inc/change_item.class.php b/inc/change_item.class.php index daebdde..9f5da00 100644 --- a/inc/change_item.class.php +++ b/inc/change_item.class.php @@ -130,8 +130,8 @@ public static function pdfForChange(PluginPdfSimplePDF $pdf, Change $change) Toolbox::stripTags(sprintf(__('%1$s: %2$s'), $typename, $nb)), Toolbox::stripTags($name), Dropdown::getDropdownName('glpi_entities', $data['entity']), - Toolbox::stripTags((string) $data["serial"]), - Toolbox::stripTags((string) $data["otherserial"]), + Toolbox::stripTags($data['serial'] ?? ''), + Toolbox::stripTags($data['otherserial'] ?? ''), $nb, ); } else { @@ -139,8 +139,8 @@ public static function pdfForChange(PluginPdfSimplePDF $pdf, Change $change) '', Toolbox::stripTags($name), Dropdown::getDropdownName('glpi_entities', $data['entity']), - Toolbox::stripTags((string) $data["serial"]), - Toolbox::stripTags((string) $data["otherserial"]), + Toolbox::stripTags($data['serial'] ?? ''), + Toolbox::stripTags($data['otherserial'] ?? ''), $nb, ); } diff --git a/inc/item_problem.class.php b/inc/item_problem.class.php index 9cae4e1..d111d8a 100644 --- a/inc/item_problem.class.php +++ b/inc/item_problem.class.php @@ -132,8 +132,8 @@ public static function pdfForProblem(PluginPdfSimplePDF $pdf, Problem $problem) Toolbox::stripTags(sprintf(__('%1$s: %2$s'), $typename, $nb)), Toolbox::stripTags($name), Dropdown::getDropdownName('glpi_entities', $data['entity']), - Toolbox::stripTags($data['serial']), - Toolbox::stripTags($data['otherserial']), + Toolbox::stripTags($data['serial'] ?? ''), + Toolbox::stripTags($data['otherserial'] ?? ''), $nb, ); } else { @@ -141,8 +141,8 @@ public static function pdfForProblem(PluginPdfSimplePDF $pdf, Problem $problem) '', Toolbox::stripTags($name), Dropdown::getDropdownName('glpi_entities', $data['entity']), - Toolbox::stripTags($data['serial']), - Toolbox::stripTags($data['otherserial']), + Toolbox::stripTags($data['serial'] ?? ''), + Toolbox::stripTags($data['otherserial'] ?? ''), $nb, ); }