Skip to content
Open
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
55 changes: 37 additions & 18 deletions src/Log.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,31 +179,50 @@ public static function constructHistory(CommonDBTM $item, $oldvalues, $values)
// Linkfield or standard field not massive action enable
$id_search_option = $key2; // Give ID of the $SEARCHOPTION

// Only consider link/dropdown handling when the search option
// effectively targets the parent item table or the current item table.
$parent_table = getTableForItemType($real_type);
if (($val2['table'] !== $parent_table) && ($val2['table'] !== $item->getTable())) {
// If the option is actually a plain text/string field, keep it as text
if (isset($val2['datatype']) && in_array($val2['datatype'], ['text', 'string'], true)) {
$changes = [$id_search_option, $oldval ?? '', $values[$key] ?? ''];
}
continue;
}

if ($val2['table'] == $item->getTable()) {
$changes = [$id_search_option, $oldval ?? '', $values[$key] ?? ''];
} else {
// other cases; link field -> get data from dropdown
$changes = [$id_search_option,
sprintf(
__('%1$s (%2$s)'),
Dropdown::getDropdownName(
$val2["table"],
if (isset($val2['datatype']) && in_array($val2['datatype'], ['text', 'string'], true)) {
$changes = [$id_search_option, $oldval ?? '', $values[$key] ?? ''];
break;
}

if (!is_numeric($oldval) || !is_numeric($values[$key] ?? null)) {
$changes = [$id_search_option, $oldval ?? '', $values[$key] ?? ''];
} else {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like this is never closed; that's probably the cause of the syntax error.

Please test your proposal on a local instance; this PR cannot work as is.

// Both numeric — safe to use dropdown/id representation
$changes = [$id_search_option,
sprintf(
__('%1$s (%2$s)'),
Dropdown::getDropdownName(
$val2["table"],
$oldval
),
$oldval
),
$oldval
),
sprintf(
__('%1$s (%2$s)'),
Dropdown::getDropdownName(
$val2["table"],
sprintf(
__('%1$s (%2$s)'),
Dropdown::getDropdownName(
$val2["table"],
$values[$key]
),
$values[$key]
),
$values[$key]
),
$oldval,
(int) $values[$key],
];
}
$oldval,
(int)$values[$key],
];
}
break;
}
}
Expand Down
Loading