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))); diff --git a/templates/Umbraco.Templates.csproj b/templates/Umbraco.Templates.csproj index 1fa34ce842..afc47684f7 100644 --- a/templates/Umbraco.Templates.csproj +++ b/templates/Umbraco.Templates.csproj @@ -51,6 +51,10 @@ + + + + <_TemplateJsonFiles Include="**\.template.config\template.json" Exclude="bin\**;obj\**" /> <_TemplateJsonFiles> @@ -63,7 +67,10 @@ <_PackageFiles Remove="@(_TemplateJsonFiles)" /> <_PackageFiles Include="%(_TemplateJsonFiles.DestinationFile)"> %(RelativeDir) + <_PackageFiles Include="%(_TemplateJsonFiles.DestinationFile)"> + %(_TemplateJsonFiles.RelativeDir) +