Skip to content
Merged
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
28 changes: 10 additions & 18 deletions inc/container.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1171,7 +1171,8 @@ public function updateFieldsValues($data, $itemtype, $massiveaction = false)
$data['plugin_fields_containers_id'],
$items_id,
$itemtype,
$data
$data,
$obj
);
} else {
$first_found = array_pop($found);
Expand All @@ -1184,7 +1185,7 @@ public function updateFieldsValues($data, $itemtype, $massiveaction = false)
$items_id,
$itemtype,
$data,
$first_found
$obj
);
}

Expand All @@ -1205,7 +1206,7 @@ public static function constructHistory(
$items_id,
$itemtype,
$data,
$old_values = []
$field_obj
) {
// Don't log few itemtypes
$obj = new $itemtype();
Expand All @@ -1229,7 +1230,7 @@ public static function constructHistory(
$data = array_diff_key($data, $blacklist_k);

//add/update values condition
if (empty($old_values)) {
if (!isset($data['id'])) {
// -- add new item --

foreach ($data as $key => $value) {
Expand All @@ -1241,7 +1242,7 @@ public static function constructHistory(
//find searchoption
foreach ($searchoptions as $id_search_option => $searchoption) {
if ($searchoption['linkfield'] == $key) {
$changes[0] = $id_search_option;
$changes[0] = $id_search_option;

if ($searchoption['datatype'] === 'dropdown') {
//manage dropdown values
Expand Down Expand Up @@ -1277,19 +1278,10 @@ public static function constructHistory(
} else {
// -- update existing item --

//find changes
$updates = [];
foreach ($old_values as $key => $old_value) {
if (
!isset($data[$key])
|| empty($old_value) && empty($data[$key])
|| $old_value !== '' && $data[$key] == 'NULL'
) {
continue;
}

if ($data[$key] !== $old_value) {
$updates[$key] = [0, $old_value ?? '', $data[$key]];
// construct $updates
if ($field_obj->updates) {
foreach ($field_obj->updates as $key) {
$updates[$key] = [0, $field_obj->oldvalues[$key], $field_obj->input[$key]];
}
}

Expand Down