From 812b414d965cb4b8de32c1a61c594f903fdcf76e Mon Sep 17 00:00:00 2001 From: Sven Geusens Date: Thu, 21 Dec 2023 09:43:37 +0100 Subject: [PATCH 1/4] Batched more update calls to avoid Sql paramater count error (#15487) Co-authored-by: Sven Geusens --- .../Implement/ContentTypeRepositoryBase.cs | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ContentTypeRepositoryBase.cs b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ContentTypeRepositoryBase.cs index 59aa92bb82..e9d6348e45 100644 --- a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ContentTypeRepositoryBase.cs +++ b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ContentTypeRepositoryBase.cs @@ -1223,8 +1223,11 @@ AND umbracoNode.id <> @id", /// If this is not done, then in some cases the "edited" value for a particular culture for a document will remain true /// when it should be false /// if the property was changed to invariant. In order to do this we need to recalculate this value based on the values - /// stored for each - /// property, culture and current/published version. + /// stored for each property, culture and current/published version. + /// + /// Some of the sql statements in this function have a tendency to take a lot of parameters (nodeIds) + /// as the WhereIn Npoco method translates all the nodeIds being passed in as parameters when using the SqlClient provider. + /// this results in to many parameters (>2100) error => We need to batch the calls /// private void RenormalizeDocumentEditedFlags( IReadOnlyCollection propertyTypeIds, @@ -1380,16 +1383,19 @@ AND umbracoNode.id <> @id", // Now bulk update the table DocumentCultureVariationDto, once for edited = true, another for edited = false foreach (IGrouping editValue in toUpdate.GroupBy(x => x.Edited)) { - Database.Execute(Sql().Update(u => u.Set(x => x.Edited, editValue.Key)) - .WhereIn(x => x.Id, editValue.Select(x => x.Id))); + // update in batches to account for maximum parameter count + foreach (IEnumerable batchedValues in editValue.InGroupsOf(Constants.Sql.MaxParameterCount)) + { + Database.Execute(Sql().Update(u => u.Set(x => x.Edited, editValue.Key)) + .WhereIn(x => x.Id, batchedValues.Select(x => x.Id))); + } } // Now bulk update the umbracoDocument table - // we need to do this in batches as the WhereIn Npoco method translates to all the nodeIds being passed in as parameters when using the SqlClient provider - // this results in to many parameters (>2100) being passed to the client when there are a lot of documents being normalized foreach (IGrouping> groupByValue in editedDocument.GroupBy(x => x.Value)) { - foreach (IEnumerable> batch in groupByValue.InGroupsOf(2000)) + // update in batches to account for maximum parameter count + foreach (IEnumerable> batch in groupByValue.InGroupsOf(Constants.Sql.MaxParameterCount)) { Database.Execute(Sql().Update(u => u.Set(x => x.Edited, groupByValue.Key)) .WhereIn(x => x.NodeId, batch.Select(x => x.Key))); From b648126d196aeae4a3a2601fc4a0849142c9f2ce Mon Sep 17 00:00:00 2001 From: Bjarke Berg Date: Fri, 22 Dec 2023 12:59:13 +0100 Subject: [PATCH 2/4] Use wildcard as default valid --- templates/UmbracoPackage/.template.config/template.json | 2 +- templates/UmbracoProject/.template.config/template.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/UmbracoPackage/.template.config/template.json b/templates/UmbracoPackage/.template.config/template.json index d5aeaf7a82..e2607d0ee7 100644 --- a/templates/UmbracoPackage/.template.config/template.json +++ b/templates/UmbracoPackage/.template.config/template.json @@ -41,7 +41,7 @@ "description": "The version of Umbraco.Cms to add as PackageReference.", "type": "parameter", "datatype": "string", - "defaultValue": "10.0.0-rc1", + "defaultValue": "*", "replaces": "UMBRACO_VERSION_FROM_TEMPLATE" }, "Namespace": { diff --git a/templates/UmbracoProject/.template.config/template.json b/templates/UmbracoProject/.template.config/template.json index 6476fb1568..7e99eed512 100644 --- a/templates/UmbracoProject/.template.config/template.json +++ b/templates/UmbracoProject/.template.config/template.json @@ -51,7 +51,7 @@ "description": "The version of Umbraco.Cms to add as PackageReference.", "type": "parameter", "datatype": "string", - "defaultValue": "10.0.0-rc1", + "defaultValue": "*", "replaces": "UMBRACO_VERSION_FROM_TEMPLATE" }, "UseHttpsRedirect": { From 64f2447c0e0af3e25eb8e9ca815e6838464a743e Mon Sep 17 00:00:00 2001 From: Bjarke Berg Date: Fri, 22 Dec 2023 13:15:13 +0100 Subject: [PATCH 3/4] Added script to update default version --- templates/Umbraco.Templates.csproj | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/templates/Umbraco.Templates.csproj b/templates/Umbraco.Templates.csproj index 6a0d70646f..4543023507 100644 --- a/templates/Umbraco.Templates.csproj +++ b/templates/Umbraco.Templates.csproj @@ -43,4 +43,25 @@ UmbracoProject\wwwroot + + + + + + + + <_TemplateJsonFiles Include="**\.template.config\template.json" Exclude="bin\**;obj\**" /> + <_TemplateJsonFiles> + $(IntermediateOutputPath)%(RelativeDir)%(Filename)%(Extension) + + + + + + <_PackageFiles Remove="@(_TemplateJsonFiles)" /> + <_PackageFiles Include="%(_TemplateJsonFiles.DestinationFile)"> + %(RelativeDir) + + + From a2ad95d965af9533fa21c7ec55fe52705a9a20f3 Mon Sep 17 00:00:00 2001 From: Bjarke Berg Date: Fri, 22 Dec 2023 13:49:57 +0100 Subject: [PATCH 4/4] Change content --- templates/Umbraco.Templates.csproj | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/templates/Umbraco.Templates.csproj b/templates/Umbraco.Templates.csproj index 4543023507..a19e4ed6f2 100644 --- a/templates/Umbraco.Templates.csproj +++ b/templates/Umbraco.Templates.csproj @@ -48,7 +48,10 @@ - + + + + <_TemplateJsonFiles Include="**\.template.config\template.json" Exclude="bin\**;obj\**" /> <_TemplateJsonFiles> @@ -58,10 +61,10 @@ - <_PackageFiles Remove="@(_TemplateJsonFiles)" /> <_PackageFiles Include="%(_TemplateJsonFiles.DestinationFile)"> - %(RelativeDir) + %(_TemplateJsonFiles.RelativeDir) +