From 380717ed5ad86f8ae818abc7a7bce14f8ca6078c Mon Sep 17 00:00:00 2001 From: Stanislas Kita Date: Thu, 22 Jan 2026 16:05:37 +0100 Subject: [PATCH 1/2] Fix(SQL): prevent SQL error when column not exist (Item_DeviceSimcard) --- CHANGELOG.md | 1 + inc/tagitem.class.php | 15 +++++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 62fb830..734d754 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - Fix tag search - Fix `webapplication` plugin integration +- Prevent SQL error when column `name` not exist from `Item_Device` ## [2.14.3] - 2025-12-22 diff --git a/inc/tagitem.class.php b/inc/tagitem.class.php index d842535..120e722 100644 --- a/inc/tagitem.class.php +++ b/inc/tagitem.class.php @@ -265,7 +265,9 @@ public static function showForTag(PluginTagTag $tag) $item_id = $result2[$i]['items_id']; if ($item->canView()) { - $column = (strtolower(substr((string) $itemtype, 0, 6)) === "device") ? "designation" : "name"; + $column = (stripos((string) $itemtype, 'item_device') !== false) + ? '' + : ((stripos((string) $itemtype, 'device') === 0) ? 'designation' : 'name'); // For rules itemtypes (example : ruledictionnaryphonemodel) if (strtolower(substr((string) $itemtype, 0, 4)) === 'rule' || $itemtype == "PluginResourcesRulechecklist") { @@ -297,10 +299,15 @@ public static function showForTag(PluginTagTag $tag) 'glpi_plugin_tag_tagitems.plugin_tag_tags_id' => $instID, ] + getEntitiesRestrictCriteria($itemtable, '', '', $item->maybeRecursive()), 'ORDERBY' => [ - $itemtable . '.' . $column, - ], + ] ]; + if ($column !== '') { + $criteria['ORDERBY'] = [ + $itemtable . '.' . $column, + ]; + } + if ($item->maybeTemplate()) { $criteria['WHERE'][$itemtable . '.is_template'] = 0; } @@ -364,7 +371,7 @@ public static function showForTag(PluginTagTag $tag) ); } - $linkname = $data[$column]; + $linkname = $data[$column] ?? ""; if ($_SESSION["glpiis_ids_visible"] || empty($data[$column])) { $linkname = sprintf(__s('%1$s (%2$s)'), $linkname, $data["id"]); From f162c24db6df5a06f1d1b04989b48c0e26e2ec58 Mon Sep 17 00:00:00 2001 From: "Romain B." <8530352+Rom1-B@users.noreply.github.com> Date: Thu, 22 Jan 2026 16:33:15 +0100 Subject: [PATCH 2/2] Update inc/tagitem.class.php --- inc/tagitem.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/tagitem.class.php b/inc/tagitem.class.php index 120e722..743d5ff 100644 --- a/inc/tagitem.class.php +++ b/inc/tagitem.class.php @@ -299,7 +299,7 @@ public static function showForTag(PluginTagTag $tag) 'glpi_plugin_tag_tagitems.plugin_tag_tags_id' => $instID, ] + getEntitiesRestrictCriteria($itemtable, '', '', $item->maybeRecursive()), 'ORDERBY' => [ - ] + ], ]; if ($column !== '') {