Handle case where value is deleted in history #13749
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a sort of stopgap for #13710, which handles a few different cases
EOL Date will not show as changed if it was not actually changed anymore. It was being cast as a date which was really turning it into a date time
Encrypted fields will not show as changed if they're not really changed. We're still storing the change in history, since the encrypted value does change. This really needs to be handled in the controllers where we don't "save" those fields to the asset itself if nothing was changed.
And finally - the real reason I started this - this fixes an error where if a certain set of circumstances have occurred, an asset's history will look empty with an
ErrorException: Attempt to read property "name" on null
error. This would happen when the following happens:I'd really like to handle this better by actually capturing the "at that time" value when the asset is saved, to prevent people from sidestepping the history by editing Location 123 to be XYZ, without ever touching the asset. If the asset was changed, the location name/id at the time should be what we're logging, so we know that at that time, the location was named 123. But alas, that's an issue for a different PR.