diff --git a/src/Umbraco.Core/Persistence/Repositories/ContentRepository.cs b/src/Umbraco.Core/Persistence/Repositories/ContentRepository.cs index d947c1c0fa..93d72d07f5 100644 --- a/src/Umbraco.Core/Persistence/Repositories/ContentRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/ContentRepository.cs @@ -298,7 +298,7 @@ namespace Umbraco.Core.Persistence.Repositories } //If Published state has changed then previous versions should have their publish state reset - if (shouldCreateNewVersion && entity.Published) + if (((ICanBeDirty)entity).IsPropertyDirty("Published")) { var publishedDocs = Database.Fetch("WHERE nodeId = @Id AND published = @IsPublished", new { Id = entity.Id, IsPublished = true }); foreach (var doc in publishedDocs) diff --git a/src/Umbraco.Core/Persistence/Repositories/ContentTypeRepository.cs b/src/Umbraco.Core/Persistence/Repositories/ContentTypeRepository.cs index 87e982fd2b..59f9347476 100644 --- a/src/Umbraco.Core/Persistence/Repositories/ContentTypeRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/ContentTypeRepository.cs @@ -144,6 +144,7 @@ namespace Umbraco.Core.Persistence.Repositories string.Format("DELETE FROM umbracoUser2NodePermission WHERE nodeId = @Id"), string.Format("DELETE FROM cmsTagRelationship WHERE nodeId = @Id"), string.Format("DELETE FROM cmsContentTypeAllowedContentType WHERE Id = @Id"), + string.Format("DELETE FROM cmsContentTypeAllowedContentType WHERE AllowedId = @Id"), string.Format("DELETE FROM cmsContentType2ContentType WHERE parentContentTypeId = @Id"), string.Format("DELETE FROM cmsContentType2ContentType WHERE childContentTypeId = @Id"), string.Format("DELETE FROM cmsPropertyType WHERE contentTypeId = @Id"), @@ -191,6 +192,13 @@ namespace Umbraco.Core.Persistence.Repositories //Updates Modified date ((ContentType)entity).UpdatingEntity(); + //Look up parent to get and set the correct Path if ParentId has changed + if (((ICanBeDirty)entity).IsPropertyDirty("ParentId")) + { + var parent = Database.First("WHERE id = @ParentId", new { ParentId = entity.ParentId }); + entity.Path = string.Concat(parent.Path, ",", entity.Id); + } + var factory = new ContentTypeFactory(NodeObjectTypeId); var dto = factory.BuildDto(entity); diff --git a/src/Umbraco.Core/Persistence/Repositories/DataTypeDefinitionRepository.cs b/src/Umbraco.Core/Persistence/Repositories/DataTypeDefinitionRepository.cs index 5ef72413be..6212cf880e 100644 --- a/src/Umbraco.Core/Persistence/Repositories/DataTypeDefinitionRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/DataTypeDefinitionRepository.cs @@ -153,6 +153,13 @@ namespace Umbraco.Core.Persistence.Repositories //Updates Modified date and Version Guid ((DataTypeDefinition)entity).UpdatingEntity(); + //Look up parent to get and set the correct Path if ParentId has changed + if (((ICanBeDirty)entity).IsPropertyDirty("ParentId")) + { + var parent = Database.First("WHERE id = @ParentId", new { ParentId = entity.ParentId }); + entity.Path = string.Concat(parent.Path, ",", entity.Id); + } + var factory = new DataTypeDefinitionFactory(NodeObjectTypeId); //Look up DataTypeDefinition entry to get Primary for updating the DTO var dataTypeDto = Database.SingleOrDefault("WHERE nodeId = @Id", new { Id = entity.Id }); diff --git a/src/Umbraco.Core/Persistence/Repositories/MediaRepository.cs b/src/Umbraco.Core/Persistence/Repositories/MediaRepository.cs index 288ccd43e5..2c244def9a 100644 --- a/src/Umbraco.Core/Persistence/Repositories/MediaRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/MediaRepository.cs @@ -234,6 +234,13 @@ namespace Umbraco.Core.Persistence.Repositories //Updates Modified date ((Models.Media)entity).UpdatingEntity(); + //Look up parent to get and set the correct Path if ParentId has changed + if (((ICanBeDirty)entity).IsPropertyDirty("ParentId")) + { + var parent = Database.First("WHERE id = @ParentId", new { ParentId = entity.ParentId }); + entity.Path = string.Concat(parent.Path, ",", entity.Id); + } + var factory = new MediaFactory(NodeObjectTypeId, entity.Id); //Look up Content entry to get Primary for updating the DTO var contentDto = Database.SingleOrDefault("WHERE nodeId = @Id", new { Id = entity.Id }); diff --git a/src/Umbraco.Core/Persistence/Repositories/MediaTypeRepository.cs b/src/Umbraco.Core/Persistence/Repositories/MediaTypeRepository.cs index 50477a679e..fb0682511c 100644 --- a/src/Umbraco.Core/Persistence/Repositories/MediaTypeRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/MediaTypeRepository.cs @@ -160,6 +160,13 @@ namespace Umbraco.Core.Persistence.Repositories //Updates Modified date ((MediaType)entity).UpdatingEntity(); + //Look up parent to get and set the correct Path if ParentId has changed + if (((ICanBeDirty)entity).IsPropertyDirty("ParentId")) + { + var parent = Database.First("WHERE id = @ParentId", new { ParentId = entity.ParentId }); + entity.Path = string.Concat(parent.Path, ",", entity.Id); + } + var factory = new MediaTypeFactory(NodeObjectTypeId); var dto = factory.BuildDto(entity); diff --git a/src/Umbraco.Core/Persistence/Repositories/TemplateRepository.cs b/src/Umbraco.Core/Persistence/Repositories/TemplateRepository.cs index fb8307d940..0bd21368f0 100644 --- a/src/Umbraco.Core/Persistence/Repositories/TemplateRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/TemplateRepository.cs @@ -226,6 +226,13 @@ namespace Umbraco.Core.Persistence.Repositories } } + //Look up parent to get and set the correct Path if ParentId has changed + if (((ICanBeDirty)entity).IsPropertyDirty("ParentId")) + { + var parent = Database.First("WHERE id = @ParentId", new { ParentId = ((Template)entity).ParentId }); + entity.Path = string.Concat(parent.Path, ",", entity.Id); + } + //Get TemplateDto from db to get the Primary key of the entity var templateDto = Database.SingleOrDefault("WHERE nodeId = @Id", new { Id = entity.Id }); //Save updated entity to db diff --git a/src/Umbraco.Core/Services/ContentService.cs b/src/Umbraco.Core/Services/ContentService.cs index 95d4c14dc2..683680cb7c 100644 --- a/src/Umbraco.Core/Services/ContentService.cs +++ b/src/Umbraco.Core/Services/ContentService.cs @@ -539,17 +539,7 @@ namespace Umbraco.Core.Services { //TODO Refactor this so omitCacheRefresh isn't exposed in the public method, but only in an internal one as its purely there for legacy reasons. - //Look for children and unpublish them if any exists, otherwise just unpublish the passed in Content. - var children = GetChildrenDeep(content.Id); - var hasChildren = children.Any(); - - if (hasChildren) - children.Add(content); - - var unpublished = hasChildren - ? _publishingStrategy.UnPublish(children, userId) - : _publishingStrategy.UnPublish(content, userId); - + var unpublished = _publishingStrategy.UnPublish(content, userId); if (unpublished) { var uow = _uowProvider.GetUnitOfWork(); @@ -557,24 +547,8 @@ namespace Umbraco.Core.Services { repository.AddOrUpdate(content); - if (hasChildren) - { - foreach (var child in children) - { - SetWriter(child, userId); - repository.AddOrUpdate(child); - } - } - - //Remove 'published' xml from the cmsContentXml table for the unpublished content and its (possible) children + //Remove 'published' xml from the cmsContentXml table for the unpublished content uow.Database.Delete("WHERE nodeId = @Id", new {Id = content.Id}); - if (hasChildren) - { - foreach (var child in children) - { - uow.Database.Delete("WHERE nodeId = @Id", new {Id = child.Id}); - } - } uow.Commit(); } @@ -653,6 +627,15 @@ namespace Umbraco.Core.Services if (omitCacheRefresh == false) _publishingStrategy.PublishingFinalized(content); + if (HasChildren(content.Id)) + { + var children = GetChildrenDeep(content.Id); + var shouldBeRepublished = children.Where(child => HasPublishedVersion(child.Id)); + + if (omitCacheRefresh == false) + _publishingStrategy.PublishingFinalized(shouldBeRepublished, false); + } + if (Saved != null) Saved(content, e); diff --git a/src/Umbraco.Web.UI/config/ClientDependency.config b/src/Umbraco.Web.UI/config/ClientDependency.config index f7fdad504a..d6edcff895 100644 --- a/src/Umbraco.Web.UI/config/ClientDependency.config +++ b/src/Umbraco.Web.UI/config/ClientDependency.config @@ -10,14 +10,14 @@ NOTES: * Compression/Combination/Minification is not enabled unless debug="false" is specified on the 'compiliation' element in the web.config * A new version will invalidate both client and server cache and create new persisted files --> - + - - - - + + + + @@ -26,8 +26,8 @@ NOTES: - - + + @@ -41,20 +41,12 @@ NOTES: --> - + - +