From f7da6234d236affb436f65b8b71c4812ba012220 Mon Sep 17 00:00:00 2001 From: Julien Durand Date: Mon, 10 Aug 2026 12:06:01 +0200 Subject: [PATCH 01/11] fix(45721): Error when generating a pdf containing a network port with multiple ips --- inc/networkport.class.php | 41 ++++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/inc/networkport.class.php b/inc/networkport.class.php index 1d5a0ee..5fbf995 100644 --- a/inc/networkport.class.php +++ b/inc/networkport.class.php @@ -138,17 +138,32 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item) $netport->fields['mac'], )); - $sqlip = ['LEFT JOIN' => ['glpi_networknames' - => ['FKEY' => ['glpi_ipaddresses' => 'items_id', - 'glpi_networknames' => 'id'], - ['glpi_ipaddresses.entities_id' - => $_SESSION['glpiactive_entity']]]], - 'WHERE' => ['glpi_networknames.items_id' => $netport->fields['id']]]; - - $ipname = ''; - $ip = new IPAddress(); - if ($ip->getFromDBByRequest($sqlip)) { - $ipname = $ip->fields['name']; + $ipAdress = new IPAddress(); + + $ips = $DB->request( + [ + 'SELECT' => [$ipAdress->getTable() . '.*'], + 'FROM' => $ipAdress->getTable(), + 'LEFT JOIN' => [ + 'glpi_networknames' => [ + 'FKEY' => [ + 'glpi_ipaddresses' => 'items_id', + 'glpi_networknames' => 'id', + ], + [ + 'glpi_ipaddresses.entities_id'=> $_SESSION['glpiactive_entity'], + ], + ], + ], + 'WHERE' => ['glpi_networknames.items_id' => $netport->fields['id']], + ], + ); + + foreach($ips as $ip){ + $ipname = ''; + + $ipname = $ip['name']; + $ipid = $ip['id']; $pdf->displayLine('' . sprintf(__s('%1$s: %2$s'), __s('ip') . '', $ipname)); @@ -157,8 +172,8 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item) 'LEFT JOIN' => ['glpi_ipnetworks' => ['FKEY' => ['glpi_ipaddresses_ipnetworks' => 'ipnetworks_id', 'glpi_ipnetworks' => 'id']]], - 'WHERE' => ['glpi_ipaddresses_ipnetworks.ipaddresses_id' => $ip->getID()] - + $dbu->getEntitiesRestrictCriteria('glpi_ipnetworks')]; + 'WHERE' => ['glpi_ipaddresses_ipnetworks.ipaddresses_id' => $ipid] + + $dbu->getEntitiesRestrictCriteria('glpi_ipnetworks')]; $res = $DB->request($sql); foreach ($res as $row) { From dc447f161e78dd0a532966e4b371d2dad4566476 Mon Sep 17 00:00:00 2001 From: Julien Durand Date: Mon, 10 Aug 2026 12:07:33 +0200 Subject: [PATCH 02/11] chore(45721): linter --- inc/networkport.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/inc/networkport.class.php b/inc/networkport.class.php index 5fbf995..a0f277d 100644 --- a/inc/networkport.class.php +++ b/inc/networkport.class.php @@ -151,7 +151,7 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item) 'glpi_networknames' => 'id', ], [ - 'glpi_ipaddresses.entities_id'=> $_SESSION['glpiactive_entity'], + 'glpi_ipaddresses.entities_id' => $_SESSION['glpiactive_entity'], ], ], ], @@ -159,7 +159,7 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item) ], ); - foreach($ips as $ip){ + foreach ($ips as $ip) { $ipname = ''; $ipname = $ip['name']; From 84b0d02290884f8d7c42a74dac3572600ba8bf70 Mon Sep 17 00:00:00 2001 From: Julien Durand Date: Mon, 10 Aug 2026 14:38:39 +0200 Subject: [PATCH 03/11] chore(45721): Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1bf37c7..fe30637 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Fixed +- Fix PDF Generation involving a Network port with multiple IPs - Fix PDF export of tabs renamed in GLPI 11 ## [4.1.4] - 2026-07-30 From a47e662c1768d951e6278c0f9e8b85ec08a4a27b Mon Sep 17 00:00:00 2001 From: Julien DURAND Date: Mon, 10 Aug 2026 14:59:43 +0200 Subject: [PATCH 04/11] Update inc/networkport.class.php Co-authored-by: Romain B. <8530352+Rom1-B@users.noreply.github.com> --- inc/networkport.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/inc/networkport.class.php b/inc/networkport.class.php index a0f277d..985acae 100644 --- a/inc/networkport.class.php +++ b/inc/networkport.class.php @@ -138,12 +138,12 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item) $netport->fields['mac'], )); - $ipAdress = new IPAddress(); + $ipAddress = new IPAddress(); $ips = $DB->request( [ - 'SELECT' => [$ipAdress->getTable() . '.*'], - 'FROM' => $ipAdress->getTable(), + 'SELECT' => [$ipAddress->getTable() . '.*'], + 'FROM' => $ipAddress->getTable(), 'LEFT JOIN' => [ 'glpi_networknames' => [ 'FKEY' => [ From ab8ce656812a2fb7f659d34b85c47f7d833a40b7 Mon Sep 17 00:00:00 2001 From: Julien DURAND Date: Mon, 10 Aug 2026 14:59:55 +0200 Subject: [PATCH 05/11] Update inc/networkport.class.php Co-authored-by: Romain B. <8530352+Rom1-B@users.noreply.github.com> --- inc/networkport.class.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/inc/networkport.class.php b/inc/networkport.class.php index 985acae..51e6b6a 100644 --- a/inc/networkport.class.php +++ b/inc/networkport.class.php @@ -160,8 +160,6 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item) ); foreach ($ips as $ip) { - $ipname = ''; - $ipname = $ip['name']; $ipid = $ip['id']; From 3742807748faee71cf9c8b84b9e78c20a9a4cf71 Mon Sep 17 00:00:00 2001 From: Julien DURAND Date: Mon, 10 Aug 2026 16:23:15 +0200 Subject: [PATCH 06/11] Update inc/networkport.class.php Co-authored-by: Stanislas --- inc/networkport.class.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/inc/networkport.class.php b/inc/networkport.class.php index 51e6b6a..7a72529 100644 --- a/inc/networkport.class.php +++ b/inc/networkport.class.php @@ -138,12 +138,10 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item) $netport->fields['mac'], )); - $ipAddress = new IPAddress(); - $ips = $DB->request( [ - 'SELECT' => [$ipAddress->getTable() . '.*'], - 'FROM' => $ipAddress->getTable(), + 'SELECT' => [IPAddress::getTable() . '.*'], + 'FROM' => IPAddress::getTable(), 'LEFT JOIN' => [ 'glpi_networknames' => [ 'FKEY' => [ From 7ecc23b1d7151a7e95bf1edf4e64080d214da681 Mon Sep 17 00:00:00 2001 From: Julien DURAND Date: Mon, 10 Aug 2026 16:34:26 +0200 Subject: [PATCH 07/11] Update inc/networkport.class.php Co-authored-by: Stanislas --- inc/networkport.class.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/inc/networkport.class.php b/inc/networkport.class.php index 7a72529..d2bf152 100644 --- a/inc/networkport.class.php +++ b/inc/networkport.class.php @@ -153,7 +153,10 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item) ], ], ], - 'WHERE' => ['glpi_networknames.items_id' => $netport->fields['id']], + 'WHERE' => [ + 'glpi_networknames.items_id' => $netport->fields['id'], + 'glpi_networknames.itemtype' => 'NetworkPort', + ], ], ); From 01561b96d8cceab1b47497f2028e5c649b1bce2c Mon Sep 17 00:00:00 2001 From: Julien DURAND Date: Tue, 11 Aug 2026 08:39:53 +0200 Subject: [PATCH 08/11] Update inc/networkport.class.php Co-authored-by: Stanislas --- inc/networkport.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/networkport.class.php b/inc/networkport.class.php index d2bf152..41f390a 100644 --- a/inc/networkport.class.php +++ b/inc/networkport.class.php @@ -155,7 +155,7 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item) ], 'WHERE' => [ 'glpi_networknames.items_id' => $netport->fields['id'], - 'glpi_networknames.itemtype' => 'NetworkPort', + 'glpi_networknames.itemtype' => NetworkPort::class, ], ], ); From 80c7d6d115eca89af574077640bd29c07dc3f07e Mon Sep 17 00:00:00 2001 From: Julien DURAND Date: Tue, 11 Aug 2026 09:24:43 +0200 Subject: [PATCH 09/11] Update inc/networkport.class.php Co-authored-by: Stanislas --- inc/networkport.class.php | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/inc/networkport.class.php b/inc/networkport.class.php index 41f390a..9b57020 100644 --- a/inc/networkport.class.php +++ b/inc/networkport.class.php @@ -160,18 +160,14 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item) ], ); - foreach ($ips as $ip) { - $ipname = $ip['name']; - $ipid = $ip['id']; - - $pdf->displayLine('' . sprintf(__s('%1$s: %2$s'), __s('ip') . '', $ipname)); - - $sql = ['SELECT' => 'glpi_ipaddresses_ipnetworks.ipnetworks_id', - 'FROM' => 'glpi_ipaddresses_ipnetworks', - 'LEFT JOIN' => ['glpi_ipnetworks' - => ['FKEY' => ['glpi_ipaddresses_ipnetworks' => 'ipnetworks_id', - 'glpi_ipnetworks' => 'id']]], - 'WHERE' => ['glpi_ipaddresses_ipnetworks.ipaddresses_id' => $ipid] +$pdf->displayLine('' . sprintf(__s('%1$s: %2$s'), __s('ip') . '', $ip['name'])); + +$sql = ['SELECT' => 'glpi_ipaddresses_ipnetworks.ipnetworks_id', +'FROM' => 'glpi_ipaddresses_ipnetworks', +'LEFT JOIN' => ['glpi_ipnetworks' +=> ['FKEY' => ['glpi_ipaddresses_ipnetworks' => 'ipnetworks_id', +'glpi_ipnetworks' => 'id']]], + 'WHERE' => ['glpi_ipaddresses_ipnetworks.ipaddresses_id' => $ip['id']] + $dbu->getEntitiesRestrictCriteria('glpi_ipnetworks')]; $res = $DB->request($sql); From fb983bea4cfacee3b31169d33db214fa7347dc49 Mon Sep 17 00:00:00 2001 From: Julien Durand Date: Tue, 11 Aug 2026 09:46:08 +0200 Subject: [PATCH 10/11] fix(45721): broken code following last diff suggestion implementation --- inc/networkport.class.php | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/inc/networkport.class.php b/inc/networkport.class.php index 9b57020..438a1ff 100644 --- a/inc/networkport.class.php +++ b/inc/networkport.class.php @@ -153,20 +153,19 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item) ], ], ], - 'WHERE' => [ - 'glpi_networknames.items_id' => $netport->fields['id'], - 'glpi_networknames.itemtype' => NetworkPort::class, - ], + 'WHERE' => ['glpi_networknames.items_id' => $netport->fields['id']], ], ); -$pdf->displayLine('' . sprintf(__s('%1$s: %2$s'), __s('ip') . '', $ip['name'])); + foreach ($ips as $ip) { + + $pdf->displayLine('' . sprintf(__s('%1$s: %2$s'), __s('ip') . '', $ip['name'])); -$sql = ['SELECT' => 'glpi_ipaddresses_ipnetworks.ipnetworks_id', -'FROM' => 'glpi_ipaddresses_ipnetworks', -'LEFT JOIN' => ['glpi_ipnetworks' -=> ['FKEY' => ['glpi_ipaddresses_ipnetworks' => 'ipnetworks_id', -'glpi_ipnetworks' => 'id']]], + $sql = ['SELECT' => 'glpi_ipaddresses_ipnetworks.ipnetworks_id', + 'FROM' => 'glpi_ipaddresses_ipnetworks', + 'LEFT JOIN' => ['glpi_ipnetworks' + => ['FKEY' => ['glpi_ipaddresses_ipnetworks' => 'ipnetworks_id', + 'glpi_ipnetworks' => 'id']]], 'WHERE' => ['glpi_ipaddresses_ipnetworks.ipaddresses_id' => $ip['id']] + $dbu->getEntitiesRestrictCriteria('glpi_ipnetworks')]; From 2b74b33b505227b32311686d2afdf57ce03355d9 Mon Sep 17 00:00:00 2001 From: Julien Durand Date: Tue, 11 Aug 2026 11:10:01 +0200 Subject: [PATCH 11/11] fix(45721): Restore where condition after it was accidentally deleted --- inc/networkport.class.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/inc/networkport.class.php b/inc/networkport.class.php index 438a1ff..bfb2390 100644 --- a/inc/networkport.class.php +++ b/inc/networkport.class.php @@ -153,7 +153,10 @@ public static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item) ], ], ], - 'WHERE' => ['glpi_networknames.items_id' => $netport->fields['id']], + 'WHERE' => [ + 'glpi_networknames.items_id' => $netport->fields['id'], + 'glpi_networknames.itemtype' => NetworkPort::class, + ], ], );