Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Fix retrieval of dropdown and multiline values containing special characters
- Fix repeated User updates failing with `Data too long for column cookie_token` by excluding token fields from update payloads (backport of PR #566 from GLPI 11-compatible line)
- Fix various minor bugs in the import/export workflow (backport of PR #656 from GLPI 11-compatible line)
- Move network port lookup query to the GLPI DBAL iterator (backport of PR #659 from GLPI 11-compatible line)

## [2.14.4] - 2025-11-25

Expand Down
44 changes: 27 additions & 17 deletions inc/networkportinjection.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -344,30 +344,40 @@ public function processAfterInsertOrUpdate($values, $add = true, $rights = [])
return false;
}

// Find port in database
$sql = "SELECT `glpi_networkports`.`id`
FROM `glpi_networkports`, `glpi_networkequipments`
WHERE `glpi_networkports`.`itemtype`='NetworkEquipment'
AND `glpi_networkports`.`items_id` = `glpi_networkequipments`.`id`
AND `glpi_networkequipments`.`is_template` = '0'
AND `glpi_networkequipments`.`entities_id`
= '" . $values['NetworkPort']["entities_id"] . "'";
// Find port in database
$criteria = [
'glpi_networkports.itemtype' => 'NetworkEquipment',
'glpi_networkequipments.is_template' => 0,
'glpi_networkequipments.entities_id' => $values['NetworkPort']["entities_id"],
];
if ($use_name) {
$sql .= " AND `glpi_networkequipments`.`name` = '" . $values['NetworkPort']["netname"] . "'";
$criteria['glpi_networkequipments.name'] = $values['NetworkPort']["netname"];
}
if ($use_logical_number) {
$sql .= " AND `glpi_networkports`.`logical_number` = '" . $values['NetworkPort']["netport"] . "'";
$criteria['glpi_networkports.logical_number'] = $values['NetworkPort']["netport"];
}
if ($use_mac) {
$sql .= " AND `glpi_networkports`.`mac` = '" . $values['NetworkPort']["netmac"] . "'";
$criteria['glpi_networkports.mac'] = $values['NetworkPort']["netmac"];
}
$res = $DB->doQuery($sql);

//if at least one parameter is given
$nb = $DB->numrows($res);
if ($nb == 1) {
//Get data for this port
$netport = $DB->fetchArray($res);
$result = $DB->request([
'SELECT' => 'glpi_networkports.id',
'FROM' => 'glpi_networkports',
'INNER JOIN' => [
'glpi_networkequipments' => [
'ON' => [
'glpi_networkports' => 'items_id',
'glpi_networkequipments' => 'id',
],
],
],
'WHERE' => $criteria,
]);

//if at least one parameter is given
if (count($result) === 1) {
//Get data for this port
$netport = $result->current();
$netport_netport = new NetworkPort_NetworkPort();
//If this port already connected to another one ?
if (!$netport_netport->getOppositeContact((int) $netport['id'])) {
Expand Down