diff --git a/src/Umbraco.Core/Models/ContentBase.cs b/src/Umbraco.Core/Models/ContentBase.cs index 56a31cd76d..bf2fd580d9 100644 --- a/src/Umbraco.Core/Models/ContentBase.cs +++ b/src/Umbraco.Core/Models/ContentBase.cs @@ -167,7 +167,7 @@ namespace Umbraco.Core.Models } /// - public DateTime? GetCultureDate(string culture) + public DateTime? GetUpdateDate(string culture) { if (culture.IsNullOrWhiteSpace()) return null; if (!ContentTypeBase.VariesByCulture()) return null; @@ -202,6 +202,12 @@ namespace Umbraco.Core.Models } } + internal void TouchCulture(string culture) + { + if (ContentTypeBase.VariesByCulture() && _cultureInfos != null && _cultureInfos.TryGetValue(culture, out var infos)) + _cultureInfos[culture] = (infos.Name, DateTime.Now); + } + protected void ClearCultureInfos() { _cultureInfos = null; diff --git a/src/Umbraco.Core/Models/IContentBase.cs b/src/Umbraco.Core/Models/IContentBase.cs index de1b2666d5..460bd521d4 100644 --- a/src/Umbraco.Core/Models/IContentBase.cs +++ b/src/Umbraco.Core/Models/IContentBase.cs @@ -80,13 +80,13 @@ namespace Umbraco.Core.Models bool IsCultureAvailable(string culture); /// - /// Gets the date a culture was created. + /// Gets the date a culture was updated. /// /// /// When is null, returns null. /// If the specified culture is not available, returns null. /// - DateTime? GetCultureDate(string culture); + DateTime? GetUpdateDate(string culture); /// /// List of properties, which make up all the data available for this Content object diff --git a/src/Umbraco.Core/Persistence/Dtos/ContentVersionCultureVariationDto.cs b/src/Umbraco.Core/Persistence/Dtos/ContentVersionCultureVariationDto.cs index cd6c66d5f0..1dca820a6c 100644 --- a/src/Umbraco.Core/Persistence/Dtos/ContentVersionCultureVariationDto.cs +++ b/src/Umbraco.Core/Persistence/Dtos/ContentVersionCultureVariationDto.cs @@ -10,7 +10,7 @@ namespace Umbraco.Core.Persistence.Dtos internal class ContentVersionCultureVariationDto { public const string TableName = Constants.DatabaseSchema.Tables.ContentVersionCultureVariation; - private int? _publishedUserId; + private int? _updateUserId; [Column("id")] [PrimaryKeyColumn] @@ -33,13 +33,12 @@ namespace Umbraco.Core.Persistence.Dtos [Column("name")] public string Name { get; set; } - [Column("date")] - public DateTime Date { get; set; } + [Column("date")] // fixme: db rename to 'updateDate' + public DateTime UpdateDate { get; set; } - // fixme want? - [Column("availableUserId")] + [Column("availableUserId")] // fixme: db rename to 'updateDate' [ForeignKey(typeof(UserDto))] [NullSetting(NullSetting = NullSettings.Null)] - public int? PublishedUserId { get => _publishedUserId == 0 ? null : _publishedUserId; set => _publishedUserId = value; } //return null if zero + public int? UpdateUserId { get => _updateUserId == 0 ? null : _updateUserId; set => _updateUserId = value; } //return null if zero } } diff --git a/src/Umbraco.Core/Persistence/Dtos/ContentVersionDto.cs b/src/Umbraco.Core/Persistence/Dtos/ContentVersionDto.cs index 3ec40c74b3..a13bf921d9 100644 --- a/src/Umbraco.Core/Persistence/Dtos/ContentVersionDto.cs +++ b/src/Umbraco.Core/Persistence/Dtos/ContentVersionDto.cs @@ -21,11 +21,11 @@ namespace Umbraco.Core.Persistence.Dtos [ForeignKey(typeof(ContentDto))] public int NodeId { get; set; } - [Column("versionDate")] + [Column("versionDate")] // fixme: db rename to 'updateDate' [Constraint(Default = SystemMethods.CurrentDateTime)] public DateTime VersionDate { get; set; } - [Column("userId")] + [Column("userId")] // fixme: db rename to 'updateUserId' [ForeignKey(typeof(UserDto))] [NullSetting(NullSetting = NullSettings.Null)] public int? UserId { get => _userId == 0 ? null : _userId; set => _userId = value; } //return null if zero diff --git a/src/Umbraco.Core/Persistence/Dtos/NodeDto.cs b/src/Umbraco.Core/Persistence/Dtos/NodeDto.cs index 10450f2bf4..56da821360 100644 --- a/src/Umbraco.Core/Persistence/Dtos/NodeDto.cs +++ b/src/Umbraco.Core/Persistence/Dtos/NodeDto.cs @@ -45,7 +45,7 @@ namespace Umbraco.Core.Persistence.Dtos [Index(IndexTypes.NonClustered, Name = "IX_" + TableName + "_Trashed")] public bool Trashed { get; set; } - [Column("nodeUser")] // fixme dbfix rename userId + [Column("nodeUser")] // fixme: db rename to 'createUserId' [ForeignKey(typeof(UserDto))] [NullSetting(NullSetting = NullSettings.Null)] public int? UserId { get => _userId == 0 ? null : _userId; set => _userId = value; } //return null if zero @@ -54,10 +54,10 @@ namespace Umbraco.Core.Persistence.Dtos [NullSetting(NullSetting = NullSettings.Null)] public string Text { get; set; } - [Column("nodeObjectType")] // fixme dbfix rename objectType + [Column("nodeObjectType")] // fixme: db rename to 'objectType' [NullSetting(NullSetting = NullSettings.Null)] [Index(IndexTypes.NonClustered, Name = "IX_" + TableName + "_ObjectType")] - public Guid? NodeObjectType { get; set; } // fixme dbfix rename ObjectType + public Guid? NodeObjectType { get; set; } [Column("createDate")] [Constraint(Default = SystemMethods.CurrentDateTime)] diff --git a/src/Umbraco.Core/Persistence/Repositories/Implement/DocumentRepository.cs b/src/Umbraco.Core/Persistence/Repositories/Implement/DocumentRepository.cs index 033301a8e8..fb1a33eb62 100644 --- a/src/Umbraco.Core/Persistence/Repositories/Implement/DocumentRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/Implement/DocumentRepository.cs @@ -503,8 +503,17 @@ namespace Umbraco.Core.Persistence.Repositories.Implement // names also impact 'edited' foreach (var (culture, name) in content.CultureNames) if (name != content.GetPublishName(culture)) + { + edited = true; (editedCultures ?? (editedCultures = new HashSet(StringComparer.OrdinalIgnoreCase))).Add(culture); + // fixme - change tracking + // at the moment, we don't do any dirty tracking on property values, so we don't know whether the + // culture has just been edited or not, so we don't update its update date - that date only changes + // when the name is set, and it all works because the controller does it - but, if someone uses a + // service to change a property value and save (without setting name), the update date does not change. + } + // replace the content version variations (rather than updating) // only need to delete for the version that existed, the new version (if any) has no property data yet var deleteContentVariations = Sql().Delete().Where(x => x.VersionId == versionToDelete); @@ -1031,7 +1040,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement { Culture = LanguageRepository.GetIsoCodeById(dto.LanguageId), Name = dto.Name, - Date = dto.Date + Date = dto.UpdateDate }); } @@ -1076,7 +1085,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement LanguageId = LanguageRepository.GetIdByIsoCode(culture) ?? throw new InvalidOperationException("Not a valid culture."), Culture = culture, Name = name, - Date = content.GetCultureDate(culture) ?? DateTime.MinValue // we *know* there is a value + UpdateDate = content.GetUpdateDate(culture) ?? DateTime.MinValue // we *know* there is a value }; // if not publishing, we're just updating the 'current' (non-published) version, @@ -1091,7 +1100,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement LanguageId = LanguageRepository.GetIdByIsoCode(culture) ?? throw new InvalidOperationException("Not a valid culture."), Culture = culture, Name = name, - Date = content.GetPublishDate(culture) ?? DateTime.MinValue // we *know* there is a value + UpdateDate = content.GetPublishDate(culture) ?? DateTime.MinValue // we *know* there is a value }; } diff --git a/src/Umbraco.Web/Models/Mapping/ContentMapperProfile.cs b/src/Umbraco.Web/Models/Mapping/ContentMapperProfile.cs index d4d570f6af..8b23763763 100644 --- a/src/Umbraco.Web/Models/Mapping/ContentMapperProfile.cs +++ b/src/Umbraco.Web/Models/Mapping/ContentMapperProfile.cs @@ -108,7 +108,7 @@ namespace Umbraco.Web.Models.Mapping // if we don't have a date for a culture, it means the culture is not available, and // hey we should probably not be mapping it, but it's too late, return a fallback date - var date = source.GetCultureDate(culture); + var date = source.GetUpdateDate(culture); return date ?? source.UpdateDate; } } diff --git a/src/Umbraco.Web/PublishedCache/NuCache/PublishedSnapshotService.cs b/src/Umbraco.Web/PublishedCache/NuCache/PublishedSnapshotService.cs index d5d90b8479..8786753e4f 100644 --- a/src/Umbraco.Web/PublishedCache/NuCache/PublishedSnapshotService.cs +++ b/src/Umbraco.Web/PublishedCache/NuCache/PublishedSnapshotService.cs @@ -1196,7 +1196,7 @@ namespace Umbraco.Web.PublishedCache.NuCache foreach (var (culture, name) in names) { - cultureData[culture] = new CultureVariation { Name = name, Date = content.GetCultureDate(culture) ?? DateTime.MinValue }; + cultureData[culture] = new CultureVariation { Name = name, Date = content.GetUpdateDate(culture) ?? DateTime.MinValue }; } //the dictionary that will be serialized