Skip to content

Commit b3e893b

Browse files
authored
Fix(Core): use Asset_PeripheralAsset instead of Computer_Item (#291)
* Fix(Core): use Asset_PeripheralAsset instead of Computer_Item * fix CI * fix
1 parent 4f01e74 commit b3e893b

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

CHANGELOG.md

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

1212
- Fix menu icon
1313
- Fix dropdown UI
14+
- Fix get linked items (move `glpi_computers_items` to `glpi_assets_assets_peripheralassets`)
1415

1516
### Added
1617

inc/tag.class.php

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
* -------------------------------------------------------------------------
2929
*/
3030
use Glpi\Application\View\TemplateRenderer;
31+
use Glpi\Asset\Asset_PeripheralAsset;
3132
use Glpi\DBAL\QueryExpression;
3233
use Glpi\Form\Form;
3334
use Glpi\Message\MessageType;
@@ -287,13 +288,23 @@ public function getLinkedItems()
287288
/** @var DBmysql $DB */
288289
global $DB;
289290

290-
$query = "SELECT `itemtype`, `items_id`
291-
FROM `glpi_computers_items`
292-
WHERE `computers_id` = '" . $this->getID() . "'";
293291
$tab = [];
294-
foreach ($DB->doQuery($query) as $data) {
295-
$tab[$data['itemtype']][$data['items_id']] = $data['items_id'];
292+
$iterator = $DB->request([
293+
'SELECT' => [
294+
'itemtype_peripheral',
295+
'items_id_peripheral',
296+
],
297+
'FROM' => getTableForItemType(Asset_PeripheralAsset::class),
298+
'WHERE' => [
299+
'itemtype_asset' => Computer::class,
300+
'items_id_asset' => $this->getID(),
301+
],
302+
]);
303+
304+
foreach ($iterator as $data) {
305+
$tab[$data['itemtype_peripheral']][$data['items_id_peripheral']] = $data['items_id_peripheral'];
296306
}
307+
297308
return $tab;
298309
}
299310

0 commit comments

Comments
 (0)