Skip to content

Commit 02bf616

Browse files
committed
Merge remote-tracking branch 'origin/v8/dev' into v9/feature/merge-v8_29-10-2021
# Conflicts: # src/Umbraco.Core/Persistence/NPocoDatabaseExtensions-Bulk.cs # src/Umbraco.Web.UI.Client/package.json # src/Umbraco.Web.UI.Client/src/views/common/overlays/user/user.html # src/Umbraco.Web.UI.Client/src/views/content/overlays/publish.html # src/Umbraco.Web.UI.Client/src/views/documenttypes/importdocumenttype.html # src/Umbraco.Web.UI/umbraco/config/lang/en.xml # src/Umbraco.Web.UI/umbraco/config/lang/en_us.xml # src/Umbraco.Web.UI/umbraco/config/lang/nl.xml
2 parents e9ae567 + b046098 commit 02bf616

File tree

64 files changed

+678
-505
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+678
-505
lines changed

src/Umbraco.Core/Constants-Sql.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
namespace Umbraco.Cms.Core
2+
{
3+
public static partial class Constants
4+
{
5+
public static class Sql
6+
{
7+
/// <summary>
8+
/// The maximum amount of parameters that can be used in a query.
9+
/// </summary>
10+
/// <remarks>
11+
/// The actual limit is 2100
12+
/// (https://docs.microsoft.com/en-us/sql/sql-server/maximum-capacity-specifications-for-sql-server),
13+
/// but we want to ensure there's room for additional parameters if this value is used to create groups/batches.
14+
/// </remarks>
15+
public const int MaxParameterCount = 2000;
16+
}
17+
}
18+
}

src/Umbraco.Core/Models/Mapping/UserMapDefinition.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ private void Map(IUserGroup source, UserGroupDisplay target, MapperContext conte
251251
// the entity service due to too many Sql parameters.
252252

253253
var list = new List<IEntitySlim>();
254-
foreach (var idGroup in allContentPermissions.Keys.InGroupsOf(2000))
254+
foreach (var idGroup in allContentPermissions.Keys.InGroupsOf(Constants.Sql.MaxParameterCount))
255255
list.AddRange(_entityService.GetAll(UmbracoObjectTypes.Document, idGroup.ToArray()));
256256
contentEntities = list.ToArray();
257257
}

src/Umbraco.Core/Umbraco.Core.csproj

Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,61 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

3-
<PropertyGroup>
4-
<TargetFramework>netstandard2.0</TargetFramework>
5-
<RootNamespace>Umbraco.Cms.Core</RootNamespace>
6-
<Product>Umbraco CMS</Product>
7-
<PackageId>Umbraco.Cms.Core</PackageId>
8-
<Title>Umbraco CMS Core</Title>
9-
<Description>Contains the core assembly needed to run Umbraco Cms. This package only contains the assembly, and can be used for package development. Use the template in the Umbraco.Templates package to setup Umbraco</Description>
10-
<Product>Umbraco CMS</Product>
11-
</PropertyGroup>
3+
<PropertyGroup>
4+
<TargetFramework>netstandard2.0</TargetFramework>
5+
<RootNamespace>Umbraco.Cms.Core</RootNamespace>
6+
<Product>Umbraco CMS</Product>
7+
<PackageId>Umbraco.Cms.Core</PackageId>
8+
<Title>Umbraco CMS Core</Title>
9+
<Description>Contains the core assembly needed to run Umbraco Cms. This package only contains the assembly, and can be used for package development. Use the template in the Umbraco.Templates package to setup Umbraco</Description>
10+
<Product>Umbraco CMS</Product>
11+
</PropertyGroup>
1212

13-
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
14-
<DocumentationFile>bin\Release\Umbraco.Core.xml</DocumentationFile>
15-
</PropertyGroup>
13+
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
14+
<DocumentationFile>bin\Release\Umbraco.Core.xml</DocumentationFile>
15+
</PropertyGroup>
1616

17-
<ItemGroup>
18-
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="5.0.0" />
19-
<PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="5.0.10" />
20-
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="5.0.0" />
21-
<PackageReference Include="Microsoft.Extensions.Logging" Version="5.0.0" />
22-
<PackageReference Include="Microsoft.Extensions.Options" Version="5.0.0" />
23-
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="5.0.0" />
24-
<PackageReference Include="Microsoft.Extensions.Options.DataAnnotations" Version="5.0.0" />
25-
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0">
26-
<PrivateAssets>all</PrivateAssets>
27-
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
28-
</PackageReference>
29-
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
30-
<PackageReference Include="System.Reflection.Emit.Lightweight" Version="4.7.0" />
31-
<PackageReference Include="System.Runtime.Caching" Version="5.0.0" />
32-
<PackageReference Include="Umbraco.Code" Version="1.2.0">
33-
<PrivateAssets>all</PrivateAssets>
34-
</PackageReference>
35-
</ItemGroup>
17+
<ItemGroup>
18+
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="5.0.0"/>
19+
<PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="5.0.10"/>
20+
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="5.0.0"/>
21+
<PackageReference Include="Microsoft.Extensions.Logging" Version="5.0.0"/>
22+
<PackageReference Include="Microsoft.Extensions.Options" Version="5.0.0"/>
23+
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="5.0.0"/>
24+
<PackageReference Include="Microsoft.Extensions.Options.DataAnnotations" Version="5.0.0"/>
25+
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0">
26+
<PrivateAssets>all</PrivateAssets>
27+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
28+
</PackageReference>
29+
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0"/>
30+
<PackageReference Include="System.Reflection.Emit.Lightweight" Version="4.7.0"/>
31+
<PackageReference Include="System.Runtime.Caching" Version="5.0.0"/>
32+
<PackageReference Include="Umbraco.Code" Version="1.2.0">
33+
<PrivateAssets>all</PrivateAssets>
34+
</PackageReference>
35+
</ItemGroup>
3636

37-
<ItemGroup>
38-
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
39-
<_Parameter1>Umbraco.Tests</_Parameter1>
40-
</AssemblyAttribute>
41-
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
42-
<_Parameter1>Umbraco.Tests.Common</_Parameter1>
43-
</AssemblyAttribute>
44-
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
45-
<_Parameter1>Umbraco.Tests.UnitTests</_Parameter1>
46-
</AssemblyAttribute>
47-
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
48-
<_Parameter1>Umbraco.Tests.Benchmarks</_Parameter1>
49-
</AssemblyAttribute>
50-
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
51-
<_Parameter1>Umbraco.Tests.Integration</_Parameter1>
52-
</AssemblyAttribute>
53-
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
54-
<_Parameter1>DynamicProxyGenAssembly2</_Parameter1>
55-
</AssemblyAttribute>
56-
</ItemGroup>
37+
<ItemGroup>
38+
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
39+
<_Parameter1>Umbraco.Tests</_Parameter1>
40+
</AssemblyAttribute>
41+
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
42+
<_Parameter1>Umbraco.Tests.Common</_Parameter1>
43+
</AssemblyAttribute>
44+
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
45+
<_Parameter1>Umbraco.Tests.UnitTests</_Parameter1>
46+
</AssemblyAttribute>
47+
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
48+
<_Parameter1>Umbraco.Tests.Benchmarks</_Parameter1>
49+
</AssemblyAttribute>
50+
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
51+
<_Parameter1>Umbraco.Tests.Integration</_Parameter1>
52+
</AssemblyAttribute>
53+
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
54+
<_Parameter1>DynamicProxyGenAssembly2</_Parameter1>
55+
</AssemblyAttribute>
56+
</ItemGroup>
5757

58-
<ItemGroup>
59-
<EmbeddedResource Include="EmbeddedResources\**\*" />
60-
</ItemGroup>
58+
<ItemGroup>
59+
<EmbeddedResource Include="EmbeddedResources\**\*"/>
60+
</ItemGroup>
6161
</Project>

src/Umbraco.Infrastructure/Persistence/Repositories/Implement/AuditEntryRepository.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ protected override IEnumerable<IAuditEntry> PerformGetAll(params int[] ids)
5353

5454
var entries = new List<IAuditEntry>();
5555

56-
foreach (var group in ids.InGroupsOf(2000))
56+
foreach (var group in ids.InGroupsOf(Constants.Sql.MaxParameterCount))
5757
{
5858
var sql = Sql()
5959
.Select<AuditEntryDto>()

src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ContentRepositoryBase.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ protected IDictionary<int, PropertyCollection> GetPropertyCollections<T>(List<Te
657657
// in the table?
658658

659659
// get all PropertyDataDto for all definitions / versions
660-
var allPropertyDataDtos = Database.FetchByGroups<PropertyDataDto, int>(versions, 2000, batch =>
660+
var allPropertyDataDtos = Database.FetchByGroups<PropertyDataDto, int>(versions, Constants.Sql.MaxParameterCount, batch =>
661661
SqlContext.Sql()
662662
.Select<PropertyDataDto>()
663663
.From<PropertyDataDto>()
@@ -666,7 +666,7 @@ protected IDictionary<int, PropertyCollection> GetPropertyCollections<T>(List<Te
666666

667667
// get PropertyDataDto distinct PropertyTypeDto
668668
var allPropertyTypeIds = allPropertyDataDtos.Select(x => x.PropertyTypeId).Distinct().ToList();
669-
var allPropertyTypeDtos = Database.FetchByGroups<PropertyTypeDto, int>(allPropertyTypeIds, 2000, batch =>
669+
var allPropertyTypeDtos = Database.FetchByGroups<PropertyTypeDto, int>(allPropertyTypeIds, Constants.Sql.MaxParameterCount, batch =>
670670
SqlContext.Sql()
671671
.Select<PropertyTypeDto>(r => r.Select(x => x.DataTypeDto))
672672
.From<PropertyTypeDto>()

src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ContentTypeRepositoryBase.cs

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,7 @@ private void CopyTagData(int? sourceLanguageId, int? targetLanguageId, IReadOnly
795795
// note: important to use SqlNullableEquals for nullable types, cannot directly compare language identifiers
796796

797797
var whereInArgsCount = propertyTypeIds.Count + (contentTypeIds?.Count ?? 0);
798-
if (whereInArgsCount > 2000)
798+
if (whereInArgsCount > Constants.Sql.MaxParameterCount)
799799
throw new NotSupportedException("Too many property/content types.");
800800

801801
// delete existing relations (for target language)
@@ -933,7 +933,7 @@ private void CopyPropertyData(int? sourceLanguageId, int? targetLanguageId, IRea
933933
// note: important to use SqlNullableEquals for nullable types, cannot directly compare language identifiers
934934
//
935935
var whereInArgsCount = propertyTypeIds.Count + (contentTypeIds?.Count ?? 0);
936-
if (whereInArgsCount > 2000)
936+
if (whereInArgsCount > Constants.Sql.MaxParameterCount)
937937
throw new NotSupportedException("Too many property/content types.");
938938

939939
//first clear out any existing property data that might already exists under the target language
@@ -1032,7 +1032,7 @@ private void RenormalizeDocumentEditedFlags(IReadOnlyCollection<int> propertyTyp
10321032
//based on the current variance of each item to see if it's 'edited' value should be true/false.
10331033

10341034
var whereInArgsCount = propertyTypeIds.Count + (contentTypeIds?.Count ?? 0);
1035-
if (whereInArgsCount > 2000)
1035+
if (whereInArgsCount > Constants.Sql.MaxParameterCount)
10361036
throw new NotSupportedException("Too many property/content types.");
10371037

10381038
var propertySql = Sql()
@@ -1121,14 +1121,20 @@ private void RenormalizeDocumentEditedFlags(IReadOnlyCollection<int> propertyTyp
11211121
}
11221122
}
11231123

1124-
//lookup all matching rows in umbracoDocumentCultureVariation
1125-
var docCultureVariationsToUpdate = editedLanguageVersions.InGroupsOf(2000)
1126-
.SelectMany(_ => Database.Fetch<DocumentCultureVariationDto>(
1127-
Sql().Select<DocumentCultureVariationDto>().From<DocumentCultureVariationDto>()
1128-
.WhereIn<DocumentCultureVariationDto>(x => x.LanguageId, editedLanguageVersions.Keys.Select(x => x.langId).ToList())
1129-
.WhereIn<DocumentCultureVariationDto>(x => x.NodeId, editedLanguageVersions.Keys.Select(x => x.nodeId))))
1130-
//convert to dictionary with the same key type
1131-
.ToDictionary(x => (x.NodeId, (int?)x.LanguageId), x => x);
1124+
// lookup all matching rows in umbracoDocumentCultureVariation
1125+
// fetch in batches to account for maximum parameter count (distinct languages can't exceed 2000)
1126+
var languageIds = editedLanguageVersions.Keys.Select(x => x.langId).Distinct().ToArray();
1127+
var nodeIds = editedLanguageVersions.Keys.Select(x => x.nodeId).Distinct();
1128+
var docCultureVariationsToUpdate = nodeIds.InGroupsOf(Constants.Sql.MaxParameterCount - languageIds.Length)
1129+
.SelectMany(group =>
1130+
{
1131+
var sql = Sql().Select<DocumentCultureVariationDto>().From<DocumentCultureVariationDto>()
1132+
.WhereIn<DocumentCultureVariationDto>(x => x.LanguageId, languageIds)
1133+
.WhereIn<DocumentCultureVariationDto>(x => x.NodeId, group);
1134+
1135+
return Database.Fetch<DocumentCultureVariationDto>(sql);
1136+
})
1137+
.ToDictionary(x => (x.NodeId, (int?)x.LanguageId), x => x); //convert to dictionary with the same key type
11321138

11331139
var toUpdate = new List<DocumentCultureVariationDto>();
11341140
foreach (var ev in editedLanguageVersions)

src/Umbraco.Infrastructure/Persistence/Repositories/Implement/DictionaryRepository.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -263,13 +263,12 @@ public IEnumerable<IDictionaryItem> GetDictionaryItemDescendants(Guid? parentId)
263263

264264
Func<Guid[], IEnumerable<IEnumerable<IDictionaryItem>>> getItemsFromParents = guids =>
265265
{
266-
//needs to be in groups of 2000 because we are doing an IN clause and there's a max parameter count that can be used.
267-
return guids.InGroupsOf(2000)
268-
.Select(@group =>
266+
return guids.InGroupsOf(Constants.Sql.MaxParameterCount)
267+
.Select(group =>
269268
{
270269
var sqlClause = GetBaseQuery(false)
271270
.Where<DictionaryDto>(x => x.Parent != null)
272-
.Where($"{SqlSyntax.GetQuotedColumnName("parent")} IN (@parentIds)", new { parentIds = @group });
271+
.WhereIn<DictionaryDto>(x => x.Parent, group);
273272

274273
var translator = new SqlTranslator<IDictionaryItem>(sqlClause, Query<IDictionaryItem>());
275274
var sql = translator.Translate();

src/Umbraco.Infrastructure/Persistence/Repositories/Implement/DocumentRepository.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1390,7 +1390,7 @@ private IDictionary<int, ContentScheduleCollection> GetContentSchedule(params in
13901390
{
13911391
var result = new Dictionary<int, ContentScheduleCollection>();
13921392

1393-
var scheduleDtos = Database.FetchByGroups<ContentScheduleDto, int>(contentIds, 2000, batch => Sql()
1393+
var scheduleDtos = Database.FetchByGroups<ContentScheduleDto, int>(contentIds, Constants.Sql.MaxParameterCount, batch => Sql()
13941394
.Select<ContentScheduleDto>()
13951395
.From<ContentScheduleDto>()
13961396
.WhereIn<ContentScheduleDto>(x => x.NodeId, batch));
@@ -1440,7 +1440,7 @@ private IDictionary<int, List<ContentVariation>> GetContentVariations<T>(List<Te
14401440
if (versions.Count == 0)
14411441
return new Dictionary<int, List<ContentVariation>>();
14421442

1443-
var dtos = Database.FetchByGroups<ContentVersionCultureVariationDto, int>(versions, 2000, batch
1443+
var dtos = Database.FetchByGroups<ContentVersionCultureVariationDto, int>(versions, Constants.Sql.MaxParameterCount, batch
14441444
=> Sql()
14451445
.Select<ContentVersionCultureVariationDto>()
14461446
.From<ContentVersionCultureVariationDto>()
@@ -1469,7 +1469,7 @@ private IDictionary<int, List<DocumentVariation>> GetDocumentVariations<T>(List<
14691469
{
14701470
var ids = temps.Select(x => x.Id);
14711471

1472-
var dtos = Database.FetchByGroups<DocumentCultureVariationDto, int>(ids, 2000, batch =>
1472+
var dtos = Database.FetchByGroups<DocumentCultureVariationDto, int>(ids, Constants.Sql.MaxParameterCount, batch =>
14731473
Sql()
14741474
.Select<DocumentCultureVariationDto>()
14751475
.From<DocumentCultureVariationDto>()

src/Umbraco.Infrastructure/Persistence/Repositories/Implement/EntityContainerRepository.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ protected override IEnumerable<EntityContainer> PerformGetAll(params int[] ids)
6262
{
6363
if (ids.Any())
6464
{
65-
return Database.FetchByGroups<NodeDto, int>(ids, 2000, batch =>
65+
return Database.FetchByGroups<NodeDto, int>(ids, Constants.Sql.MaxParameterCount, batch =>
6666
GetBaseQuery(false)
6767
.Where<NodeDto>(x => x.NodeObjectType == NodeObjectTypeId)
6868
.WhereIn<NodeDto>(x => x.NodeId, batch))

src/Umbraco.Infrastructure/Persistence/Repositories/Implement/EntityRepository.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ private IEnumerable<DocumentEntitySlim> BuildVariants(IEnumerable<DocumentEntity
279279
if (v == null) return entitiesList;
280280

281281
// fetch all variant info dtos
282-
var dtos = Database.FetchByGroups<VariantInfoDto, int>(v.Select(x => x.Id), 2000, GetVariantInfos);
282+
var dtos = Database.FetchByGroups<VariantInfoDto, int>(v.Select(x => x.Id), Constants.Sql.MaxParameterCount, GetVariantInfos);
283283

284284
// group by node id (each group contains all languages)
285285
var xdtos = dtos.GroupBy(x => x.NodeId).ToDictionary(x => x.Key, x => x);

0 commit comments

Comments
 (0)