U4-7076 - fix xml cache corruption when publishing with children

This commit is contained in:
Stephan
2015-09-08 18:38:20 +02:00
parent 4d012ee1e1
commit b7eb6303ec

View File

@@ -1836,14 +1836,18 @@ namespace Umbraco.Core.Services
//Publish and then update the database with new status
var publishedOutcome = internalStrategy.PublishWithChildrenInternal(list, userId, includeUnpublished).ToArray();
var published = publishedOutcome
.Where(x => x.Success || x.Result.StatusType == PublishStatusType.SuccessAlreadyPublished)
// ensure proper order (for events) - cannot publish a child before its parent!
.OrderBy(x => x.Result.ContentItem.Level)
.ThenBy(x => x.Result.ContentItem.SortOrder);
var uow = UowProvider.GetUnitOfWork();
using (var repository = RepositoryFactory.CreateContentRepository(uow))
{
//NOTE The Publish with subpages-dialog was used more as a republish-type-thing, so we'll have to include PublishStatusType.SuccessAlreadyPublished
//in the updated-list, so the Published event is triggered with the expected set of pages and the xml is updated.
foreach (var item in publishedOutcome.Where(
x => x.Success || x.Result.StatusType == PublishStatusType.SuccessAlreadyPublished))
foreach (var item in published)
{
item.Result.ContentItem.WriterId = userId;
repository.AddOrUpdate(item.Result.ContentItem);