From 5f5ec80156cf3cdc5c6651f0547fb6a96bbb68dc Mon Sep 17 00:00:00 2001 From: zl2fxy <19570956+zl2fxy@users.noreply.github.com> Date: Mon, 14 Oct 2024 16:22:10 +0800 Subject: [PATCH 1/2] Update Activity.cs "The node already has a parent." exception when setting JsonNode in Workflows ForEach Task --- .../OrchardCore.Workflows.Abstractions/Activities/Activity.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OrchardCore/OrchardCore.Workflows.Abstractions/Activities/Activity.cs b/src/OrchardCore/OrchardCore.Workflows.Abstractions/Activities/Activity.cs index 6ad51a9ef5f..7dc2b818a6f 100644 --- a/src/OrchardCore/OrchardCore.Workflows.Abstractions/Activities/Activity.cs +++ b/src/OrchardCore/OrchardCore.Workflows.Abstractions/Activities/Activity.cs @@ -146,6 +146,6 @@ protected virtual T GetProperty(Type type, Func defaultValue = null, [Call protected virtual void SetProperty(object value, [CallerMemberName] string name = null) { // Properties[name] = JToken.FromObject(value); - Properties[name] = JNode.FromObject(value); + Properties[name] = JNode.FromObject(value).DeepClone();; } } From 6574d44875ed745a397597c50cfe26f3abf60167 Mon Sep 17 00:00:00 2001 From: zl2fxy <19570956+zl2fxy@users.noreply.github.com> Date: Thu, 17 Oct 2024 10:59:19 +0800 Subject: [PATCH 2/2] Update src/OrchardCore/OrchardCore.Workflows.Abstractions/Activities/Activity.cs Co-authored-by: Georg von Kries --- .../OrchardCore.Workflows.Abstractions/Activities/Activity.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OrchardCore/OrchardCore.Workflows.Abstractions/Activities/Activity.cs b/src/OrchardCore/OrchardCore.Workflows.Abstractions/Activities/Activity.cs index 7dc2b818a6f..36b719b3294 100644 --- a/src/OrchardCore/OrchardCore.Workflows.Abstractions/Activities/Activity.cs +++ b/src/OrchardCore/OrchardCore.Workflows.Abstractions/Activities/Activity.cs @@ -146,6 +146,6 @@ protected virtual T GetProperty(Type type, Func defaultValue = null, [Call protected virtual void SetProperty(object value, [CallerMemberName] string name = null) { // Properties[name] = JToken.FromObject(value); - Properties[name] = JNode.FromObject(value).DeepClone();; + Properties[name] = value is JsonNode node ? node.DeepClone() : JNode.FromObject(value); } }