Merge remote-tracking branch 'origin/v11/dev' into v12/dev

# Conflicts:
#	src/Umbraco.Core/Services/ContentService.cs
This commit is contained in:
Bjarke Berg
2023-09-12 09:50:35 +02:00
5 changed files with 43 additions and 18 deletions

View File

@@ -19,6 +19,9 @@ public class Issuu : OEmbedProviderBase
public override Dictionary<string, string> RequestParams => new()
{
// ApiUrl/?iframe=true
{ "iframe", "true" },
// ApiUrl/?format=xml
{ "format", "xml" },
};

View File

@@ -55,11 +55,12 @@ public abstract class OEmbedProviderBase : IEmbedProvider
if (_httpClient == null)
{
_httpClient = new HttpClient();
_httpClient.DefaultRequestHeaders.UserAgent.TryParseAdd("Umbraco-CMS");
}
using (var request = new HttpRequestMessage(HttpMethod.Get, url))
{
HttpResponseMessage response = _httpClient.SendAsync(request).Result;
HttpResponseMessage response = _httpClient.SendAsync(request).GetAwaiter().GetResult();
return response.Content.ReadAsStringAsync().Result;
}
}

View File

@@ -1951,7 +1951,7 @@ public class ContentService : RepositoryService, IContentService
cultures = new HashSet<string>(); // empty means 'already published'
}
if (edited)
if (isRoot || edited)
{
cultures.Add(c); // <culture> means 'republish this culture'
}
@@ -2106,11 +2106,13 @@ public class ContentService : RepositoryService, IContentService
}
// deal with the branch root - if it fails, abort
PublishResult? result = SaveAndPublishBranchItem(scope, document, shouldPublish, publishCultures, true, publishedDocuments, eventMessages, userId, allLangs);
if (result != null)
var rootPublishNotificationState = new Dictionary<string, object?>();
PublishResult? rootResult = SaveAndPublishBranchItem(scope, document, shouldPublish, publishCultures, true,
publishedDocuments, eventMessages, userId, allLangs, rootPublishNotificationState);
if (rootResult != null)
{
results.Add(result);
if (!result.Success)
results.Add(rootResult);
if (!rootResult.Success)
{
return results;
}
@@ -2123,6 +2125,7 @@ public class ContentService : RepositoryService, IContentService
int count;
var page = 0;
const int pageSize = 100;
PublishResult? result = null;
do
{
count = 0;
@@ -2141,7 +2144,8 @@ public class ContentService : RepositoryService, IContentService
}
// no need to check path here, parent has to be published here
result = SaveAndPublishBranchItem(scope, d, shouldPublish, publishCultures, false, publishedDocuments, eventMessages, userId, allLangs);
result = SaveAndPublishBranchItem(scope, d, shouldPublish, publishCultures, false,
publishedDocuments, eventMessages, userId, allLangs,null);
if (result != null)
{
results.Add(result);
@@ -2165,7 +2169,12 @@ public class ContentService : RepositoryService, IContentService
// (SaveAndPublishBranchOne does *not* do it)
scope.Notifications.Publish(
new ContentTreeChangeNotification(document, TreeChangeTypes.RefreshBranch, eventMessages));
scope.Notifications.Publish(new ContentPublishedNotification(publishedDocuments, eventMessages, true));
if (rootResult?.Success is true)
{
scope.Notifications.Publish(
new ContentPublishedNotification(rootResult!.Content!, eventMessages, true)
.WithState(rootPublishNotificationState));
}
scope.Complete();
}
@@ -2176,6 +2185,9 @@ public class ContentService : RepositoryService, IContentService
// shouldPublish: a function determining whether the document has changes that need to be published
// note - 'force' is handled by 'editing'
// publishValues: a function publishing values (using the appropriate PublishCulture calls)
/// <param name="rootPublishingNotificationState">Only set this when processing a the root of the branch
/// Published notification will not be send when this property is set</param>
/// <returns></returns>
private PublishResult? SaveAndPublishBranchItem(
ICoreScope scope,
IContent document,
@@ -2186,7 +2198,8 @@ public class ContentService : RepositoryService, IContentService
ICollection<IContent> publishedDocuments,
EventMessages evtMsgs,
int userId,
IReadOnlyCollection<ILanguage> allLangs)
IReadOnlyCollection<ILanguage> allLangs,
IDictionary<string, object?>? rootPublishingNotificationState)
{
HashSet<string>? culturesToPublish = shouldPublish(document);
@@ -2215,10 +2228,17 @@ public class ContentService : RepositoryService, IContentService
return new PublishResult(PublishResultType.FailedPublishContentInvalid, evtMsgs, document);
}
PublishResult result = CommitDocumentChangesInternal(scope, document, evtMsgs, allLangs, savingNotification.State, userId, true, isRoot);
if (result.Success)
var notificationState = rootPublishingNotificationState ?? new Dictionary<string, object?>();
PublishResult result = CommitDocumentChangesInternal(scope, document, evtMsgs, allLangs, notificationState, userId, true, isRoot);
if (!result.Success)
{
publishedDocuments.Add(document);
return result;
}
publishedDocuments.Add(document);
if (rootPublishingNotificationState == null)
{
scope.Notifications.Publish(new ContentPublishedNotification(result.Content!, evtMsgs).WithState(notificationState));
}
return result;

View File

@@ -37,6 +37,7 @@ public static class PublishedModelUtility
switch (itemType)
{
case PublishedItemType.Content:
case PublishedItemType.Element:
return publishedSnapshot.Content?.GetContentType(alias);
case PublishedItemType.Media:
return publishedSnapshot.Media?.GetContentType(alias);

View File

@@ -90,7 +90,7 @@ public class ContentServicePublishBranchTests : UmbracoIntegrationTest
AssertPublishResults(
r,
x => x.Result,
PublishResultType.SuccessPublishAlready,
PublishResultType.SuccessPublish, // During branch publishing, the change detection of the root branch runs AFTER the check to process the branchItem => root is always saved&Published as the intent requires it.
PublishResultType.SuccessPublishAlready,
PublishResultType.SuccessPublishAlready);
@@ -137,7 +137,7 @@ public class ContentServicePublishBranchTests : UmbracoIntegrationTest
AssertPublishResults(
r,
x => x.Result,
PublishResultType.SuccessPublishAlready,
PublishResultType.SuccessPublish, // During branch publishing, the change detection of the root branch runs AFTER the check to process the branchItem => root is always saved&Published as the intent requires it.
PublishResultType.SuccessPublishAlready,
PublishResultType.SuccessPublishAlready,
PublishResultType.SuccessPublish,
@@ -182,7 +182,7 @@ public class ContentServicePublishBranchTests : UmbracoIntegrationTest
var r = ContentService.SaveAndPublishBranch(vRoot, false)
.ToArray(); // no culture specified so "*" is used, so all cultures
Assert.AreEqual(PublishResultType.SuccessPublishAlready, r[0].Result);
Assert.AreEqual(PublishResultType.SuccessPublishCulture, r[0].Result); // During branch publishing, the change detection of the root branch runs AFTER the check to process the branchItem => root is always saved&Published as the intent requires it.
Assert.AreEqual(PublishResultType.SuccessPublishCulture, r[1].Result);
}
@@ -218,7 +218,7 @@ public class ContentServicePublishBranchTests : UmbracoIntegrationTest
var saveResult = ContentService.Save(iv1);
var r = ContentService.SaveAndPublishBranch(vRoot, false, "de").ToArray();
Assert.AreEqual(PublishResultType.SuccessPublishAlready, r[0].Result);
Assert.AreEqual(PublishResultType.SuccessPublishCulture, r[0].Result); // During branch publishing, the change detection of the root branch runs AFTER the check to process the branchItem => root is always saved&Published as the intent requires it.
Assert.AreEqual(PublishResultType.SuccessPublishCulture, r[1].Result);
}
@@ -378,7 +378,7 @@ public class ContentServicePublishBranchTests : UmbracoIntegrationTest
AssertPublishResults(
r,
x => x.Result,
PublishResultType.SuccessPublishAlready,
PublishResultType.SuccessPublish, // During branch publishing, the change detection of the root branch runs AFTER the check to process the branchItem => root is always saved&Published as the intent requires it.
PublishResultType.SuccessPublish,
PublishResultType.SuccessPublishCulture);
@@ -404,7 +404,7 @@ public class ContentServicePublishBranchTests : UmbracoIntegrationTest
AssertPublishResults(
r,
x => x.Result,
PublishResultType.SuccessPublishAlready,
PublishResultType.SuccessPublish, // During branch publishing, the change detection of the root branch runs AFTER the check to process the branchItem => root is always saved&Published as the intent requires it.
PublishResultType.SuccessPublish,
PublishResultType.SuccessPublishCulture);