diff --git a/src/Umbraco.Core/Services/DictionaryItemService.cs b/src/Umbraco.Core/Services/DictionaryItemService.cs index 467f4ea26a..6b99ea7e24 100644 --- a/src/Umbraco.Core/Services/DictionaryItemService.cs +++ b/src/Umbraco.Core/Services/DictionaryItemService.cs @@ -159,7 +159,25 @@ internal sealed class DictionaryItemService : RepositoryService, IDictionaryItem /// public async Task> UpdateAsync( IDictionaryItem dictionaryItem, Guid userKey) - => await SaveAsync( + { + // Create and update dates aren't tracked for dictionary items. They exist on IDictionaryItem due to the + // inheritance from IEntity, but we don't store them. + // However we have logic in ServerEventSender that will provide SignalR events for created and update operations, + // where these dates are used to distinguish between the two (whether or not the entity has an identity cannot + // be used here, as these events fire after persistence when the identity is known for both creates and updates). + // So ensure we set something that can be distinguished here. + if (dictionaryItem.CreateDate == default) + { + dictionaryItem.CreateDate = DateTime.MinValue; + } + + if (dictionaryItem.UpdateDate == default) + { + // TODO (V17): To align with updates of system dates, this needs to change to DateTime.UtcNow. + dictionaryItem.UpdateDate = DateTime.Now; + } + + return await SaveAsync( dictionaryItem, () => { @@ -174,6 +192,7 @@ internal sealed class DictionaryItemService : RepositoryService, IDictionaryItem AuditType.Save, "Update DictionaryItem", userKey); + } /// public async Task> DeleteAsync(Guid id, Guid userKey)