Omit datetime from JSON conversion that converts from strings (#19807)
* Remove date object conversion as valueEditors don't seem to need it * Update fault summary reference * Added justification comment. --------- Co-authored-by: Andy Butland <abutland73@gmail.com>
This commit is contained in:
@@ -13,7 +13,7 @@ namespace Umbraco.Cms.Core.PropertyEditors;
|
||||
public class PlainDateTimePropertyEditor : DataEditor
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="PlainIntegerPropertyEditor" /> class.
|
||||
/// Initializes a new instance of the <see cref="PlainDateTimePropertyEditor" /> class.
|
||||
/// </summary>
|
||||
public PlainDateTimePropertyEditor(IDataValueEditorFactory dataValueEditorFactory)
|
||||
: base(dataValueEditorFactory)
|
||||
|
||||
@@ -101,8 +101,15 @@ public sealed class JsonObjectConverter : JsonConverter<object>
|
||||
JsonTokenType.Number when reader.TryGetInt32(out int i) => i,
|
||||
JsonTokenType.Number when reader.TryGetInt64(out long l) => l,
|
||||
JsonTokenType.Number => reader.GetDouble(),
|
||||
JsonTokenType.String when reader.TryGetDateTimeOffset(out DateTimeOffset datetime) => datetime,
|
||||
JsonTokenType.String when reader.TryGetDateTime(out DateTime datetime) => datetime,
|
||||
|
||||
// DateTime and DateTimeOffset are not handled here, as in doing so we would convert strings that look like dates into dates,
|
||||
// which, if coming fron a content property based on a text string property editor, isn't what we want.
|
||||
// The date picker property editors work with strings, so this is fine.
|
||||
// Testing also suggests other dates like for content content schedules aren't affected.
|
||||
// See:
|
||||
// - https://github.com/umbraco/Umbraco-CMS/issues/19360
|
||||
// - https://github.com/umbraco/Umbraco-CMS/pull/19807
|
||||
|
||||
JsonTokenType.String => reader.GetString(),
|
||||
_ => JsonDocument.ParseValue(ref reader).RootElement.Clone()
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user