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..743d5ff 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"]);