From f15682ef60a2a70d945439316a2e17fb9edef045 Mon Sep 17 00:00:00 2001 From: Shannon Date: Mon, 9 Dec 2013 16:35:12 +1100 Subject: [PATCH] Fixes: U4-3820 cached media xml is not cleared from the cmsContentXml table when recycled --- src/Umbraco.Core/Services/MediaService.cs | 8 +++++++- .../XmlPublishedCache/PublishedMediaCache.cs | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Umbraco.Core/Services/MediaService.cs b/src/Umbraco.Core/Services/MediaService.cs index 0dfd65c45f..a18e5a3ad9 100644 --- a/src/Umbraco.Core/Services/MediaService.cs +++ b/src/Umbraco.Core/Services/MediaService.cs @@ -526,13 +526,19 @@ namespace Umbraco.Core.Services var uow = _uowProvider.GetUnitOfWork(); using (var repository = _repositoryFactory.CreateMediaRepository(uow)) - { + { + //Remove 'published' xml from the cmsContentXml table for the unpublished media + uow.Database.Delete("WHERE nodeId = @Id", new { Id = media.Id }); + media.ChangeTrashedState(true, -21); repository.AddOrUpdate(media); //Loop through descendants to update their trash state, but ensuring structure by keeping the ParentId foreach (var descendant in descendants) { + //Remove 'published' xml from the cmsContentXml table for the unpublished media + uow.Database.Delete("WHERE nodeId = @Id", new { Id = descendant.Id }); + descendant.ChangeTrashedState(true, descendant.ParentId); repository.AddOrUpdate(descendant); } diff --git a/src/Umbraco.Web/PublishedCache/XmlPublishedCache/PublishedMediaCache.cs b/src/Umbraco.Web/PublishedCache/XmlPublishedCache/PublishedMediaCache.cs index 765544b3fa..c762874a88 100644 --- a/src/Umbraco.Web/PublishedCache/XmlPublishedCache/PublishedMediaCache.cs +++ b/src/Umbraco.Web/PublishedCache/XmlPublishedCache/PublishedMediaCache.cs @@ -529,7 +529,7 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache IPublishedProperty property = null; // must ignore that one - if (i.Key == "version") continue; + if (i.Key == "version" || i.Key == "isDoc") continue; if (i.Key.InvariantStartsWith("__")) {