Skip to content

Commit fed3d54

Browse files
committed
Fix(SQL): prevent SQL error when column not exist (Item_DeviceSimcard)
1 parent 45ff257 commit fed3d54

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1010
### Fixed
1111

1212
- Fix tag search
13+
- Prevent SQL error when column `name` not exist from `Item_Device`
1314

1415
## [2.14.3] - 2025-12-22
1516

inc/tagitem.class.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,9 @@ public static function showForTag(PluginTagTag $tag)
265265
$item_id = $result2[$i]['items_id'];
266266

267267
if ($item->canView()) {
268-
$column = (strtolower(substr((string) $itemtype, 0, 6)) === "device") ? "designation" : "name";
268+
$column = (stripos((string) $itemtype, 'item_device') !== false)
269+
? ''
270+
: ((stripos((string) $itemtype, 'device') === 0) ? 'designation' : 'name');
269271

270272
// For rules itemtypes (example : ruledictionnaryphonemodel)
271273
if (strtolower(substr((string) $itemtype, 0, 4)) === 'rule' || $itemtype == "PluginResourcesRulechecklist") {
@@ -297,10 +299,15 @@ public static function showForTag(PluginTagTag $tag)
297299
'glpi_plugin_tag_tagitems.plugin_tag_tags_id' => $instID,
298300
] + getEntitiesRestrictCriteria($itemtable, '', '', $item->maybeRecursive()),
299301
'ORDERBY' => [
300-
$itemtable . '.' . $column,
301-
],
302+
]
302303
];
303304

305+
if ($column !== '') {
306+
$criteria['ORDERBY'] = [
307+
$itemtable . '.' . $column,
308+
];
309+
}
310+
304311
if ($item->maybeTemplate()) {
305312
$criteria['WHERE'][$itemtable . '.is_template'] = 0;
306313
}
@@ -364,7 +371,7 @@ public static function showForTag(PluginTagTag $tag)
364371
);
365372
}
366373

367-
$linkname = $data[$column];
374+
$linkname = $data[$column] ?? "";
368375

369376
if ($_SESSION["glpiis_ids_visible"] || empty($data[$column])) {
370377
$linkname = sprintf(__s('%1$s (%2$s)'), $linkname, $data["id"]);

0 commit comments

Comments
 (0)