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
/// 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
/// </remarks>
private void RenormalizeDocumentEditedFlags(
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
foreach (IGrouping<bool, DocumentCultureVariationDto> editValue in toUpdate.GroupBy(x => x.Edited))
{
Database.Execute(Sql().Update<DocumentCultureVariationDto>(u => u.Set(x => x.Edited, editValue.Key))
.WhereIn<DocumentCultureVariationDto>(x => x.Id, editValue.Select(x => x.Id)));
// update in batches to account for maximum parameter count
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
// 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 (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))
.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" />
</ItemGroup>
<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>
<_TemplateJsonFiles Include="**\.template.config\template.json" Exclude="bin\**;obj\**" />
<_TemplateJsonFiles>
@@ -63,7 +67,10 @@
<_PackageFiles Remove="@(_TemplateJsonFiles)" />
<_PackageFiles Include="%(_TemplateJsonFiles.DestinationFile)">
<PackagePath>%(RelativeDir)</PackagePath>
<_PackageFiles Include="%(_TemplateJsonFiles.DestinationFile)">
<PackagePath>%(_TemplateJsonFiles.RelativeDir)</PackagePath>
</_PackageFiles>
</ItemGroup>
</Target>
</Project>