removes CommitDocumentChanges from the public interface

This commit is contained in:
Shannon
2019-02-05 01:22:52 +11:00
parent c20e597115
commit 09255019b2
3 changed files with 23 additions and 21 deletions

View File

@@ -363,21 +363,6 @@ namespace Umbraco.Core.Services
/// <returns></returns>
PublishResult SaveAndPublish(IContent content, string[] cultures, int userId = 0, bool raiseEvents = true);
/// <summary>
/// Expert: Saves a document and publishes/unpublishes any pending publishing changes made to the document.
/// </summary>
/// <remarks>
/// <para>Pending publishing/unpublishing changes on a document are made with calls to <see cref="IContent.PublishCulture"/> and
/// <see cref="IContent.UnpublishCulture"/>.</para>
/// <para>When publishing or unpublishing a single culture, or all cultures, use <see cref="SaveAndPublish"/>
/// and <see cref="Unpublish"/>. But if the flexibility to both publish and unpublish in a single operation is required
/// then this method needs to be used in combination with <see cref="IContent.PublishCulture"/> and <see cref="IContent.UnpublishCulture"/>
/// on the content itself - this prepares the content, but does not commit anything - and then, invoke
/// <see cref="CommitDocumentChanges"/> to actually commit the changes to the database.</para>
/// <para>The document is *always* saved, even when publishing fails.</para>
/// </remarks>
PublishResult CommitDocumentChanges(IContent content, int userId = 0, bool raiseEvents = true);
/// <summary>
/// Saves and publishes a document branch.
/// </summary>

View File

@@ -965,8 +965,21 @@ namespace Umbraco.Core.Services.Implement
return CommitDocumentChanges(content, userId);
}
/// <inheritdoc />
public PublishResult CommitDocumentChanges(IContent content, int userId = 0, bool raiseEvents = true)
/// <summary>
/// Saves a document and publishes/unpublishes any pending publishing changes made to the document.
/// </summary>
/// <remarks>
/// <para>This is the underlying logic for both publishing and unpublishing any document</para>
/// <para>Pending publishing/unpublishing changes on a document are made with calls to <see cref="IContent.PublishCulture"/> and
/// <see cref="IContent.UnpublishCulture"/>.</para>
/// <para>When publishing or unpublishing a single culture, or all cultures, use <see cref="SaveAndPublish"/>
/// and <see cref="Unpublish"/>. But if the flexibility to both publish and unpublish in a single operation is required
/// then this method needs to be used in combination with <see cref="IContent.PublishCulture"/> and <see cref="IContent.UnpublishCulture"/>
/// on the content itself - this prepares the content, but does not commit anything - and then, invoke
/// <see cref="CommitDocumentChanges"/> to actually commit the changes to the database.</para>
/// <para>The document is *always* saved, even when publishing fails.</para>
/// </remarks>
internal PublishResult CommitDocumentChanges(IContent content, int userId = 0, bool raiseEvents = true)
{
using (var scope = ScopeProvider.CreateScope())
{

View File

@@ -1035,6 +1035,8 @@ namespace Umbraco.Tests.Services
[Test]
public void Can_Publish_And_Unpublish_Cultures_In_Single_Operation()
{
//TODO: This is using an internal API - we aren't exposing this publicly (at least for now) but we'll keep the test around
var langFr = new Language("fr");
var langDa = new Language("da");
ServiceContext.LocalizationService.Save(langFr);
@@ -1049,7 +1051,7 @@ namespace Umbraco.Tests.Services
content.SetCultureName("name-da", langDa.IsoCode);
content.PublishCulture(langFr.IsoCode);
var result = ServiceContext.ContentService.CommitDocumentChanges(content);
var result = ((ContentService)ServiceContext.ContentService).CommitDocumentChanges(content);
Assert.IsTrue(result.Success);
content = ServiceContext.ContentService.GetById(content.Id);
Assert.IsTrue(content.IsCulturePublished(langFr.IsoCode));
@@ -1058,7 +1060,7 @@ namespace Umbraco.Tests.Services
content.UnpublishCulture(langFr.IsoCode);
content.PublishCulture(langDa.IsoCode);
result = ServiceContext.ContentService.CommitDocumentChanges(content);
result = ((ContentService)ServiceContext.ContentService).CommitDocumentChanges(content);
Assert.IsTrue(result.Success);
Assert.AreEqual(PublishResultType.SuccessMixedCulture, result.Result);
@@ -2893,8 +2895,10 @@ namespace Umbraco.Tests.Services
// act
// that HAS to be SavePublishing, because SaveAndPublish would just republish everything!
contentService.CommitDocumentChanges(content);
//TODO: This is using an internal API - the test can't pass without this but we want to keep the test here
// will need stephane to have a look at this test at some stage since there is a lot of logic here that we
// want to keep on testing but don't need the public API to do these more complicated things.
((ContentService)contentService).CommitDocumentChanges(content);
// content has been re-published,
// everything is back to what it was before being unpublished