diff --git a/src/Umbraco.Core/Models/Content.cs b/src/Umbraco.Core/Models/Content.cs
index b1c3a00734..6805eb3504 100644
--- a/src/Umbraco.Core/Models/Content.cs
+++ b/src/Umbraco.Core/Models/Content.cs
@@ -337,7 +337,7 @@ namespace Umbraco.Core.Models
if (other.ContentTypeId != ContentTypeId)
throw new InvalidOperationException("Cannot copy values from a different content type.");
- var published = VersionId > PublishedVersionId;
+ var published = CopyingFromSelf(other);
// note: use property.SetValue(), don't assign pvalue.EditValue, else change tracking fails
@@ -370,7 +370,7 @@ namespace Umbraco.Core.Models
if (other.ContentTypeId != ContentTypeId)
throw new InvalidOperationException("Cannot copy values from a different content type.");
- var published = VersionId > PublishedVersionId;
+ var published = CopyingFromSelf(other);
// note: use property.SetValue(), don't assign pvalue.EditValue, else change tracking fails
diff --git a/src/Umbraco.Core/Services/ContentService.cs b/src/Umbraco.Core/Services/ContentService.cs
index 6d92cce235..fbcc2cdf57 100644
--- a/src/Umbraco.Core/Services/ContentService.cs
+++ b/src/Umbraco.Core/Services/ContentService.cs
@@ -1828,74 +1828,6 @@ namespace Umbraco.Core.Services
return true;
}
- ///
- /// Rollback an object to a previous version.
- /// This will create a new version, which is a copy of all the old data.
- ///
- ///
- /// The way data is stored actually only allows us to rollback on properties
- /// and not data like Name and Alias of the Content.
- ///
- /// Id of the being rolled back
- /// Id of the version to rollback to
- /// Optional Id of the User issueing the rollback of the Content
- /// The newly created object
- public IContent Rollback(int id, int versionId, int userId = 0)
- {
- using (var uow = UowProvider.CreateUnitOfWork())
- {
- uow.WriteLock(Constants.Locks.ContentTree);
- var repository = uow.CreateRepository();
-
- var currContent = repository.Get(id);
- var origContent = repository.GetVersion(versionId);
-
- var rollbackEventArgs = new RollbackEventArgs(origContent);
- if (uow.Events.DispatchCancelable(RollingBack, this, rollbackEventArgs))
- {
- uow.Complete();
- return origContent;
- }
-
- // orig content versions
- // pk < published pk = normal, rollback to an older version
- // pk = published pk = normal, rollback to currently published version
- // pk > published pk = special, rollback to current 'edit' version
- //
- // in that last case, we want to copy the published values
- // what-if there's no 'published' version for now?
- // fixme WE DON'T WANT TO DO THIS HERE!
- var copyPublished = origContent.VersionId > origContent.PublishedVersionId;
- //((Content) currContent).CopyAllValues(origContent, copyPublished);
- ((Content) currContent).CopyAllValues(origContent);
- currContent.WriterId = userId;
-
- // builtin values
- if (copyPublished)
- {
- currContent.Name = origContent.PublishName;
- currContent.Template = origContent.PublishTemplate;
- }
- else
- {
- currContent.Name = origContent.Name;
- currContent.Template = origContent.Template;
- }
-
- // save the values
- repository.AddOrUpdate(currContent);
-
- rollbackEventArgs.CanCancel = false;
- uow.Events.Dispatch(RolledBack, this, rollbackEventArgs);
- uow.Events.Dispatch(TreeChanged, this, new TreeChange(currContent, TreeChangeTypes.RefreshNode).ToEventArgs());
- Audit(uow, AuditType.RollBack, "Content rollback performed by user", currContent.WriterId, currContent.Id);
-
- uow.Complete();
-
- return currContent;
- }
- }
-
///
/// Sorts a collection of objects by updating the SortOrder according
/// to the ordering of items in the passed in .
diff --git a/src/Umbraco.Core/Services/IContentService.cs b/src/Umbraco.Core/Services/IContentService.cs
index c8d35104a1..ebc063fbe7 100644
--- a/src/Umbraco.Core/Services/IContentService.cs
+++ b/src/Umbraco.Core/Services/IContentService.cs
@@ -373,12 +373,6 @@ namespace Umbraco.Core.Services
///
IEnumerable PerformScheduledPublish();
- // fixme missing the differnt type of properties - should we do it manually?
- ///
- /// Rolls a document back a previous version.
- ///
- IContent Rollback(int id, int versionId, int userId = 0);
-
#endregion
#region Permissions
diff --git a/src/Umbraco.Tests/Services/ContentServiceTests.cs b/src/Umbraco.Tests/Services/ContentServiceTests.cs
index 193b00bd26..ecb6596fb0 100644
--- a/src/Umbraco.Tests/Services/ContentServiceTests.cs
+++ b/src/Umbraco.Tests/Services/ContentServiceTests.cs
@@ -28,7 +28,7 @@ namespace Umbraco.Tests.Services
/// This is more of an integration test as it involves multiple layers
/// as well as configuration.
///
- [TestFixture, RequiresSTA]
+ [TestFixture]
[UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest, PublishedRepositoryEvents = true)]
public class ContentServiceTests : TestWithSomeContentBase
{
@@ -2056,7 +2056,11 @@ namespace Umbraco.Tests.Services
// version3, third and current published version
// rollback all values to version1
- var rollback = contentService.Rollback(NodeDto.NodeIdSeed + 4, version1);
+ var rollback = contentService.GetById(NodeDto.NodeIdSeed + 4);
+ var rollto = contentService.GetVersion(version1);
+ rollback.CopyValues(rollto);
+ rollback.Name = rollto.Name; // must do it explicitely
+ contentService.Save(rollback);
Assert.IsNotNull(rollback);
Assert.IsTrue(rollback.Published);
@@ -2074,7 +2078,11 @@ namespace Umbraco.Tests.Services
// rollback all values to current version
// special because... current has edits... this really is equivalent to rolling back to version2
- var rollback2 = contentService.Rollback(NodeDto.NodeIdSeed + 4, version3);
+ var rollback2 = contentService.GetById(NodeDto.NodeIdSeed + 4);
+ var rollto2 = contentService.GetVersion(version3);
+ rollback2.CopyValues(rollto2);
+ rollback2.Name = rollto2.PublishName; // must do it explicitely AND must pick the publish one!
+ contentService.Save(rollback2);
Assert.IsTrue(rollback2.Published);
Assert.IsFalse(rollback2.Edited); // all changes cleared!
@@ -2093,7 +2101,10 @@ namespace Umbraco.Tests.Services
content.SetValue("author", "Bob Doe");
contentService.Save(content);
Assert.IsTrue(content.Edited);
- content = contentService.Rollback(content.Id, content.VersionId);
+ rollto = contentService.GetVersion(content.VersionId);
+ content.CopyValues(rollto);
+ content.Name = rollto.PublishName; // must do it explicitely AND must pick the publish one!
+ contentService.Save(content);
Assert.IsFalse(content.Edited);
Assert.AreEqual("Text Page 2 ReReUpdated", content.Name);
Assert.AreEqual("Jane Doe", content.GetValue("author"));