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

This commit is contained in:
Bjarke Berg
2023-12-22 14:05:12 +01:00
2 changed files with 20 additions and 7 deletions

View File

@@ -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 /// 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 /// 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 /// 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 /// stored for each property, culture and current/published version.
/// 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
/// </remarks> /// </remarks>
private void RenormalizeDocumentEditedFlags( private void RenormalizeDocumentEditedFlags(
IReadOnlyCollection<int> propertyTypeIds, IReadOnlyCollection<int> propertyTypeIds,
@@ -1380,16 +1383,19 @@ AND umbracoNode.id <> @id",
// Now bulk update the table DocumentCultureVariationDto, once for edited = true, another for edited = false // Now bulk update the table DocumentCultureVariationDto, once for edited = true, another for edited = false
foreach (IGrouping<bool, DocumentCultureVariationDto> editValue in toUpdate.GroupBy(x => x.Edited)) foreach (IGrouping<bool, DocumentCultureVariationDto> editValue in toUpdate.GroupBy(x => x.Edited))
{ {
Database.Execute(Sql().Update<DocumentCultureVariationDto>(u => u.Set(x => x.Edited, editValue.Key)) // update in batches to account for maximum parameter count
.WhereIn<DocumentCultureVariationDto>(x => x.Id, editValue.Select(x => x.Id))); foreach (IEnumerable<DocumentCultureVariationDto> batchedValues in editValue.InGroupsOf(Constants.Sql.MaxParameterCount))
{
Database.Execute(Sql().Update<DocumentCultureVariationDto>(u => u.Set(x => x.Edited, editValue.Key))
.WhereIn<DocumentCultureVariationDto>(x => x.Id, batchedValues.Select(x => x.Id)));
}
} }
// Now bulk update the umbracoDocument table // 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<bool, KeyValuePair<int, bool>> groupByValue in editedDocument.GroupBy(x => x.Value)) foreach (IGrouping<bool, KeyValuePair<int, bool>> groupByValue in editedDocument.GroupBy(x => x.Value))
{ {
foreach (IEnumerable<KeyValuePair<int, bool>> batch in groupByValue.InGroupsOf(2000)) // update in batches to account for maximum parameter count
foreach (IEnumerable<KeyValuePair<int, bool>> batch in groupByValue.InGroupsOf(Constants.Sql.MaxParameterCount))
{ {
Database.Execute(Sql().Update<DocumentDto>(u => u.Set(x => x.Edited, groupByValue.Key)) Database.Execute(Sql().Update<DocumentDto>(u => u.Set(x => x.Edited, groupByValue.Key))
.WhereIn<DocumentDto>(x => x.NodeId, batch.Select(x => x.Key))); .WhereIn<DocumentDto>(x => x.NodeId, batch.Select(x => x.Key)));

View File

@@ -51,6 +51,10 @@
<PackageReference Include="Umbraco.JsonSchema.Extensions" Version="0.3.0" PrivateAssets="all" /> <PackageReference Include="Umbraco.JsonSchema.Extensions" Version="0.3.0" PrivateAssets="all" />
</ItemGroup> </ItemGroup>
<Target Name="GetUpdatedTemplateJsonPackageFiles" BeforeTargets="GenerateNuspec" AfterTargets="GetBuildVersion;GetUmbracoBuildVersion"> <Target Name="GetUpdatedTemplateJsonPackageFiles" BeforeTargets="GenerateNuspec" AfterTargets="GetBuildVersion;GetUmbracoBuildVersion">
<ItemGroup>
<Content Update="**\.template.config\template.json" Pack="false" />
</ItemGroup>
<Target Name="GetUpdatedTemplateJsonPackageFiles" BeforeTargets="GenerateNuspec" AfterTargets="GetUmbracoBuildVersion">
<ItemGroup> <ItemGroup>
<_TemplateJsonFiles Include="**\.template.config\template.json" Exclude="bin\**;obj\**" /> <_TemplateJsonFiles Include="**\.template.config\template.json" Exclude="bin\**;obj\**" />
<_TemplateJsonFiles> <_TemplateJsonFiles>
@@ -63,7 +67,10 @@
<_PackageFiles Remove="@(_TemplateJsonFiles)" /> <_PackageFiles Remove="@(_TemplateJsonFiles)" />
<_PackageFiles Include="%(_TemplateJsonFiles.DestinationFile)"> <_PackageFiles Include="%(_TemplateJsonFiles.DestinationFile)">
<PackagePath>%(RelativeDir)</PackagePath> <PackagePath>%(RelativeDir)</PackagePath>
<_PackageFiles Include="%(_TemplateJsonFiles.DestinationFile)">
<PackagePath>%(_TemplateJsonFiles.RelativeDir)</PackagePath>
</_PackageFiles> </_PackageFiles>
</ItemGroup> </ItemGroup>
</Target> </Target>
</Project> </Project>