From e10cb56502c8bcf684a0b8cb091624b2613054cd Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Thu, 27 Dec 2012 16:08:24 -0100 Subject: [PATCH] Previous fix didn't work if you don't Save() the document +don't publish copies. --- src/Umbraco.Core/Services/ContentService.cs | 8 ++++++-- .../umbraco/ActionHandlers/umbEnsureUniqueName.cs | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Umbraco.Core/Services/ContentService.cs b/src/Umbraco.Core/Services/ContentService.cs index 8c97ce0984..8df5013228 100644 --- a/src/Umbraco.Core/Services/ContentService.cs +++ b/src/Umbraco.Core/Services/ContentService.cs @@ -976,10 +976,14 @@ namespace Umbraco.Core.Services /// Optional Id of the User copying the Content /// The newly created object public IContent Copy(IContent content, int parentId, bool relateToOriginal, int userId = -1) - { + { var copy = ((Content)content).Clone(); copy.ParentId = parentId; + // A copy should never be set to published + // automatically even if the original was + this.UnPublish(copy); + if (Copying.IsRaisedEventCancelled(new CopyEventArgs(content, copy, parentId), this)) return null; @@ -987,7 +991,7 @@ namespace Umbraco.Core.Services using (var repository = _repositoryFactory.CreateContentRepository(uow)) { SetWriter(content, userId); - + repository.AddOrUpdate(copy); uow.Commit(); diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/ActionHandlers/umbEnsureUniqueName.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/ActionHandlers/umbEnsureUniqueName.cs index 4c57614846..9964506b2d 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/ActionHandlers/umbEnsureUniqueName.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/ActionHandlers/umbEnsureUniqueName.cs @@ -67,6 +67,7 @@ namespace umbraco.ActionHandlers LogHelper.Debug("Title changed from '" + documentObject.Text + "' to '" + currentName + "' for document id" + documentObject.Id); documentObject.Text = currentName; + documentObject.Save(); return true; }