fix: [object:deltaMerge] Stopped updating object's attributes when updating the FS/LS.

- Make sure to compare the correct date value of FS/LS and not their representation
pull/6590/head
mokaddem 2020-11-11 09:56:05 +01:00
parent 17c793d10f
commit 774c4c104a
No known key found for this signature in database
GPG Key ID: 164C473F627A06FA
1 changed files with 10 additions and 1 deletions

View File

@ -793,7 +793,7 @@ class MispObject extends AppModel
if ($f == 'sharing_group_id' && empty($newAttribute[$f])) {
$newAttribute[$f] = 0;
}
if (isset($newAttribute[$f]) && $newAttribute[$f] != $originalAttribute[$f]) {
if (isset($newAttribute[$f]) && $this->attributeValueDifferent($originalAttribute[$f], $newAttribute[$f], $f)) {
$different = true;
}
}
@ -1486,4 +1486,13 @@ class MispObject extends AppModel
}
return true;
}
private function attributeValueDifferent($newValue, $originalValue, $field)
{
if (in_array($field, ['first_seen', 'last_seen'])) {
return new DateTime($newValue) != new DateTime($originalValue);
} else {
return $newValue != $originalValue;
}
}
}