Skip to content

Commit d5831fe

Browse files
Merge branch 'v13/dev' into v13/contrib
2 parents 71afa21 + 2736a51 commit d5831fe

92 files changed

Lines changed: 1356 additions & 460 deletions

File tree

Some content is hidden

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

Directory.Packages.props

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,25 @@
1212
</ItemGroup>
1313
<!-- Microsoft packages -->
1414
<ItemGroup>
15-
<PackageVersion Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="8.0.1" />
16-
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="8.0.1" />
15+
<PackageVersion Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="8.0.6" />
16+
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="8.0.6" />
1717
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.8.0" />
18-
<PackageVersion Include="Microsoft.Data.Sqlite" Version="8.0.1" />
19-
<PackageVersion Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.1" />
20-
<PackageVersion Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.1" />
21-
<PackageVersion Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.1" />
18+
<PackageVersion Include="Microsoft.Data.Sqlite" Version="8.0.6" />
19+
<PackageVersion Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.6" />
20+
<PackageVersion Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.6" />
21+
<PackageVersion Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.6" />
2222
<PackageVersion Include="Microsoft.Extensions.Caching.Abstractions" Version="8.0.0" />
2323
<PackageVersion Include="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0" />
2424
<PackageVersion Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
2525
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
26-
<PackageVersion Include="Microsoft.Extensions.FileProviders.Embedded" Version="8.0.1" />
26+
<PackageVersion Include="Microsoft.Extensions.FileProviders.Embedded" Version="8.0.6" />
2727
<PackageVersion Include="Microsoft.Extensions.FileProviders.Physical" Version="8.0.0" />
2828
<PackageVersion Include="Microsoft.Extensions.Hosting.Abstractions" Version="8.0.0" />
2929
<PackageVersion Include="Microsoft.Extensions.Http" Version="8.0.0" />
30-
<PackageVersion Include="Microsoft.Extensions.Identity.Core" Version="8.0.1" />
31-
<PackageVersion Include="Microsoft.Extensions.Identity.Stores" Version="8.0.1" />
30+
<PackageVersion Include="Microsoft.Extensions.Identity.Core" Version="8.0.6" />
31+
<PackageVersion Include="Microsoft.Extensions.Identity.Stores" Version="8.0.6" />
3232
<PackageVersion Include="Microsoft.Extensions.Logging" Version="8.0.0" />
33-
<PackageVersion Include="Microsoft.Extensions.Options" Version="8.0.1" />
33+
<PackageVersion Include="Microsoft.Extensions.Options" Version="8.0.2" />
3434
<PackageVersion Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="8.0.0" />
3535
<PackageVersion Include="Microsoft.Extensions.Options.DataAnnotations" Version="8.0.0" />
3636
<PackageVersion Include="System.Runtime.Caching" Version="8.0.0" />
@@ -45,13 +45,13 @@
4545
<PackageVersion Include="Asp.Versioning.Mvc" Version="7.1.1" />
4646
<PackageVersion Include="Asp.Versioning.Mvc.ApiExplorer" Version="7.1.0" />
4747
<PackageVersion Include="Dazinator.Extensions.FileProviders" Version="2.0.0" />
48-
<PackageVersion Include="Examine" Version="3.2.0" />
49-
<PackageVersion Include="Examine.Core" Version="3.2.0" />
50-
<PackageVersion Include="HtmlAgilityPack" Version="1.11.57" />
51-
<PackageVersion Include="K4os.Compression.LZ4" Version="1.3.6" />
52-
<PackageVersion Include="MailKit" Version="4.3.0" />
48+
<PackageVersion Include="Examine" Version="3.2.1" />
49+
<PackageVersion Include="Examine.Core" Version="3.2.1" />
50+
<PackageVersion Include="HtmlAgilityPack" Version="1.11.61" />
51+
<PackageVersion Include="K4os.Compression.LZ4" Version="1.3.8" />
52+
<PackageVersion Include="MailKit" Version="4.6.0" />
5353
<PackageVersion Include="Markdown" Version="2.2.1" />
54-
<PackageVersion Include="MessagePack" Version="2.5.140" />
54+
<PackageVersion Include="MessagePack" Version="2.5.168" />
5555
<PackageVersion Include="MiniProfiler.AspNetCore.Mvc" Version="4.3.8" />
5656
<PackageVersion Include="MiniProfiler.Shared" Version="4.3.8" />
5757
<PackageVersion Include="ncrontab" Version="3.3.3" />
@@ -73,21 +73,21 @@
7373
<PackageVersion Include="Serilog.Sinks.Async" Version="1.5.0" />
7474
<PackageVersion Include="Serilog.Sinks.File" Version="5.0.0" />
7575
<PackageVersion Include="Serilog.Sinks.Map" Version="1.0.2" />
76-
<PackageVersion Include="SixLabors.ImageSharp" Version="3.1.3" />
77-
<PackageVersion Include="SixLabors.ImageSharp.Web" Version="3.1.0" />
78-
<PackageVersion Include="Smidge.InMemory" Version="4.3.0" />
79-
<PackageVersion Include="Smidge.Nuglify" Version="4.3.0" />
80-
<PackageVersion Include="Swashbuckle.AspNetCore" Version="6.5.0" />
76+
<PackageVersion Include="SixLabors.ImageSharp" Version="3.1.4" />
77+
<PackageVersion Include="SixLabors.ImageSharp.Web" Version="3.1.2" />
78+
<PackageVersion Include="Smidge.InMemory" Version="4.4.0" />
79+
<PackageVersion Include="Smidge.Nuglify" Version="4.4.0" />
80+
<PackageVersion Include="Swashbuckle.AspNetCore" Version="6.6.2" />
8181
</ItemGroup>
8282
<!-- Transitive pinned versions (only required because our direct dependencies have vulnerable versions of transitive dependencies) -->
8383
<ItemGroup>
8484
<!-- Both Microsoft.EntityFrameworkCore.SqlServer and NPoco.SqlServer bring in a vulnerable version of Azure.Identity -->
85-
<PackageVersion Include="Azure.Identity" Version="1.10.4" />
85+
<PackageVersion Include="Azure.Identity" Version="1.12.0" />
8686
<!-- Dazinator.Extensions.FileProviders brings in a vulnerable version of System.Net.Http -->
8787
<PackageVersion Include="System.Net.Http" Version="4.3.4" />
8888
<!-- Examine brings in a vulnerable version of System.Security.Cryptography.Xml -->
89-
<PackageVersion Include="System.Security.Cryptography.Xml" Version="8.0.0" />
89+
<PackageVersion Include="System.Security.Cryptography.Xml" Version="8.0.1" />
9090
<!-- Both Dazinator.Extensions.FileProviders and MiniProfiler.AspNetCore.Mvc bring in a vulnerable version of System.Text.RegularExpressions -->
9191
<PackageVersion Include="System.Text.RegularExpressions" Version="4.3.1" />
9292
</ItemGroup>
93-
</Project>
93+
</Project>

src/Umbraco.Cms.Api.Delivery/Json/DeliveryApiJsonTypeResolver.cs

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,36 @@ public override JsonTypeInfo GetTypeInfo(Type type, JsonSerializerOptions option
1212
{
1313
JsonTypeInfo jsonTypeInfo = base.GetTypeInfo(type, options);
1414

15+
Type[] derivedTypes = GetDerivedTypes(jsonTypeInfo);
16+
if (derivedTypes.Length > 0)
17+
{
18+
ConfigureJsonPolymorphismOptions(jsonTypeInfo, derivedTypes);
19+
}
20+
21+
return jsonTypeInfo;
22+
}
23+
24+
protected virtual Type[] GetDerivedTypes(JsonTypeInfo jsonTypeInfo)
25+
{
1526
if (jsonTypeInfo.Type == typeof(IApiContent))
1627
{
17-
ConfigureJsonPolymorphismOptions(jsonTypeInfo, typeof(ApiContent));
28+
return new[] { typeof(ApiContent) };
1829
}
19-
else if (jsonTypeInfo.Type == typeof(IApiContentResponse))
30+
31+
if (jsonTypeInfo.Type == typeof(IApiContentResponse))
2032
{
21-
ConfigureJsonPolymorphismOptions(jsonTypeInfo, typeof(ApiContentResponse));
33+
return new[] { typeof(ApiContentResponse) };
2234
}
23-
else if (jsonTypeInfo.Type == typeof(IRichTextElement))
35+
36+
if (jsonTypeInfo.Type == typeof(IRichTextElement))
2437
{
25-
ConfigureJsonPolymorphismOptions(jsonTypeInfo, typeof(RichTextRootElement), typeof(RichTextGenericElement), typeof(RichTextTextElement));
38+
return new[] { typeof(RichTextRootElement), typeof(RichTextGenericElement), typeof(RichTextTextElement) };
2639
}
2740

28-
return jsonTypeInfo;
41+
return Array.Empty<Type>();
2942
}
3043

31-
private void ConfigureJsonPolymorphismOptions(JsonTypeInfo jsonTypeInfo, params Type[] derivedTypes)
44+
protected void ConfigureJsonPolymorphismOptions(JsonTypeInfo jsonTypeInfo, params Type[] derivedTypes)
3245
{
3346
jsonTypeInfo.PolymorphismOptions = new JsonPolymorphismOptions
3447
{

src/Umbraco.Cms.Api.Delivery/Services/RequestHeaderHandler.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,5 @@ internal abstract class RequestHeaderHandler
88

99
protected RequestHeaderHandler(IHttpContextAccessor httpContextAccessor) => _httpContextAccessor = httpContextAccessor;
1010

11-
protected string? GetHeaderValue(string headerName)
12-
{
13-
HttpContext httpContext = _httpContextAccessor.HttpContext ??
14-
throw new InvalidOperationException("Could not obtain an HTTP context");
15-
16-
return httpContext.Request.Headers[headerName];
17-
}
11+
protected string? GetHeaderValue(string headerName) => _httpContextAccessor.HttpContext?.Request.Headers[headerName];
1812
}

src/Umbraco.Cms.Imaging.ImageSharp/Umbraco.Cms.Imaging.ImageSharp.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<ItemGroup>
88
<PackageReference Include="SixLabors.ImageSharp" />
9-
<PackageReference Include="SixLabors.ImageSharp.Web" />
9+
<PackageReference Include="SixLabors.ImageSharp.Web" />
1010
</ItemGroup>
1111

1212
<ItemGroup>

src/Umbraco.Cms.Imaging.ImageSharp2/Umbraco.Cms.Imaging.ImageSharp2.csproj

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@
55
</PropertyGroup>
66

77
<ItemGroup>
8-
<PackageReference Include="SixLabors.ImageSharp" VersionOverride="[2.1.7, 3)" />
8+
<PackageReference Include="SixLabors.ImageSharp" VersionOverride="[2.1.8, 3)" />
99
<PackageReference Include="SixLabors.ImageSharp.Web" VersionOverride="[2.0.2, 3)" />
10-
<PackageReference Include="SixLabors.ImageSharp" Version="2.1.7" />
11-
<PackageReference Include="SixLabors.ImageSharp.Web" Version="2.0.2" />
1210
</ItemGroup>
1311

1412
<ItemGroup>

src/Umbraco.Cms.Persistence.EFCore/Locking/SqlServerEFCoreDistributedLockingMechanism.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ namespace Umbraco.Cms.Persistence.EFCore.Locking;
1616
internal class SqlServerEFCoreDistributedLockingMechanism<T> : IDistributedLockingMechanism
1717
where T : DbContext
1818
{
19-
private readonly IOptionsMonitor<ConnectionStrings> _connectionStrings;
20-
private readonly IOptionsMonitor<GlobalSettings> _globalSettings;
19+
private ConnectionStrings _connectionStrings;
20+
private GlobalSettings _globalSettings;
2121
private readonly ILogger<SqlServerEFCoreDistributedLockingMechanism<T>> _logger;
2222
private readonly Lazy<IEFCoreScopeAccessor<T>> _scopeAccessor; // Hooray it's a circular dependency.
2323

@@ -32,27 +32,29 @@ public SqlServerEFCoreDistributedLockingMechanism(
3232
{
3333
_logger = logger;
3434
_scopeAccessor = scopeAccessor;
35-
_globalSettings = globalSettings;
36-
_connectionStrings = connectionStrings;
35+
_globalSettings = globalSettings.CurrentValue;
36+
_connectionStrings = connectionStrings.CurrentValue;
37+
globalSettings.OnChange(x=>_globalSettings = x);
38+
connectionStrings.OnChange(x=>_connectionStrings = x);
3739
}
3840

3941
public bool HasActiveRelatedScope => _scopeAccessor.Value.AmbientScope is not null;
4042

4143
/// <inheritdoc />
42-
public bool Enabled => _connectionStrings.CurrentValue.IsConnectionStringConfigured() &&
43-
string.Equals(_connectionStrings.CurrentValue.ProviderName, "Microsoft.Data.SqlClient", StringComparison.InvariantCultureIgnoreCase) && _scopeAccessor.Value.AmbientScope is not null;
44+
public bool Enabled => _connectionStrings.IsConnectionStringConfigured() &&
45+
string.Equals(_connectionStrings.ProviderName, "Microsoft.Data.SqlClient", StringComparison.InvariantCultureIgnoreCase) && _scopeAccessor.Value.AmbientScope is not null;
4446

4547
/// <inheritdoc />
4648
public IDistributedLock ReadLock(int lockId, TimeSpan? obtainLockTimeout = null)
4749
{
48-
obtainLockTimeout ??= _globalSettings.CurrentValue.DistributedLockingReadLockDefaultTimeout;
50+
obtainLockTimeout ??= _globalSettings.DistributedLockingReadLockDefaultTimeout;
4951
return new SqlServerDistributedLock(this, lockId, DistributedLockType.ReadLock, obtainLockTimeout.Value);
5052
}
5153

5254
/// <inheritdoc />
5355
public IDistributedLock WriteLock(int lockId, TimeSpan? obtainLockTimeout = null)
5456
{
55-
obtainLockTimeout ??= _globalSettings.CurrentValue.DistributedLockingWriteLockDefaultTimeout;
57+
obtainLockTimeout ??= _globalSettings.DistributedLockingWriteLockDefaultTimeout;
5658
return new SqlServerDistributedLock(this, lockId, DistributedLockType.WriteLock, obtainLockTimeout.Value);
5759
}
5860

@@ -168,9 +170,7 @@ private void ObtainWriteLock()
168170
"A transaction with minimum ReadCommitted isolation level is required.");
169171
}
170172

171-
await dbContext.Database.ExecuteSqlRawAsync($"SET LOCK_TIMEOUT {(int)_timeout.TotalMilliseconds};");
172-
173-
var rowsAffected = await dbContext.Database.ExecuteSqlAsync(@$"UPDATE umbracoLock WITH (REPEATABLEREAD) SET value = (CASE WHEN (value=1) THEN -1 ELSE 1 END) WHERE id={LockId}");
173+
var rowsAffected = await dbContext.Database.ExecuteSqlRawAsync(@$"SET LOCK_TIMEOUT {(int)_timeout.TotalMilliseconds};UPDATE umbracoLock WITH (REPEATABLEREAD) SET value = (CASE WHEN (value=1) THEN -1 ELSE 1 END) WHERE id={LockId}");
174174

175175
if (rowsAffected == 0)
176176
{

src/Umbraco.Cms.Persistence.EFCore/Locking/SqliteEFCoreDistributedLockingMechanism.cs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ namespace Umbraco.Cms.Persistence.EFCore.Locking;
1616
internal class SqliteEFCoreDistributedLockingMechanism<T> : IDistributedLockingMechanism
1717
where T : DbContext
1818
{
19-
private readonly IOptionsMonitor<ConnectionStrings> _connectionStrings;
20-
private readonly IOptionsMonitor<GlobalSettings> _globalSettings;
19+
private ConnectionStrings _connectionStrings;
20+
private GlobalSettings _globalSettings;
2121
private readonly ILogger<SqliteEFCoreDistributedLockingMechanism<T>> _logger;
2222
private readonly Lazy<IEFCoreScopeAccessor<T>> _efCoreScopeAccessor;
2323

@@ -29,27 +29,29 @@ public SqliteEFCoreDistributedLockingMechanism(
2929
{
3030
_logger = logger;
3131
_efCoreScopeAccessor = efCoreScopeAccessor;
32-
_connectionStrings = connectionStrings;
33-
_globalSettings = globalSettings;
32+
_globalSettings = globalSettings.CurrentValue;
33+
_connectionStrings = connectionStrings.CurrentValue;
34+
globalSettings.OnChange(x=>_globalSettings = x);
35+
connectionStrings.OnChange(x=>_connectionStrings = x);
3436
}
3537

3638
public bool HasActiveRelatedScope => _efCoreScopeAccessor.Value.AmbientScope is not null;
3739

3840
/// <inheritdoc />
39-
public bool Enabled => _connectionStrings.CurrentValue.IsConnectionStringConfigured() &&
40-
string.Equals(_connectionStrings.CurrentValue.ProviderName, "Microsoft.Data.Sqlite", StringComparison.InvariantCultureIgnoreCase) && _efCoreScopeAccessor.Value.AmbientScope is not null;
41+
public bool Enabled => _connectionStrings.IsConnectionStringConfigured() &&
42+
string.Equals(_connectionStrings.ProviderName, "Microsoft.Data.Sqlite", StringComparison.InvariantCultureIgnoreCase) && _efCoreScopeAccessor.Value.AmbientScope is not null;
4143

4244
// With journal_mode=wal we can always read a snapshot.
4345
public IDistributedLock ReadLock(int lockId, TimeSpan? obtainLockTimeout = null)
4446
{
45-
obtainLockTimeout ??= _globalSettings.CurrentValue.DistributedLockingReadLockDefaultTimeout;
47+
obtainLockTimeout ??= _globalSettings.DistributedLockingReadLockDefaultTimeout;
4648
return new SqliteDistributedLock(this, lockId, DistributedLockType.ReadLock, obtainLockTimeout.Value);
4749
}
4850

4951
// With journal_mode=wal only a single write transaction can exist at a time.
5052
public IDistributedLock WriteLock(int lockId, TimeSpan? obtainLockTimeout = null)
5153
{
52-
obtainLockTimeout ??= _globalSettings.CurrentValue.DistributedLockingWriteLockDefaultTimeout;
54+
obtainLockTimeout ??= _globalSettings.DistributedLockingWriteLockDefaultTimeout;
5355
return new SqliteDistributedLock(this, lockId, DistributedLockType.WriteLock, obtainLockTimeout.Value);
5456
}
5557

src/Umbraco.Cms.Persistence.SqlServer/Services/SqlServerDistributedLockingMechanism.cs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ namespace Umbraco.Cms.Persistence.SqlServer.Services;
1717
/// </summary>
1818
public class SqlServerDistributedLockingMechanism : IDistributedLockingMechanism
1919
{
20-
private readonly IOptionsMonitor<ConnectionStrings> _connectionStrings;
21-
private readonly IOptionsMonitor<GlobalSettings> _globalSettings;
20+
private ConnectionStrings _connectionStrings;
21+
private GlobalSettings _globalSettings;
2222
private readonly ILogger<SqlServerDistributedLockingMechanism> _logger;
2323
private readonly Lazy<IScopeAccessor> _scopeAccessor; // Hooray it's a circular dependency.
2424

@@ -33,25 +33,28 @@ public SqlServerDistributedLockingMechanism(
3333
{
3434
_logger = logger;
3535
_scopeAccessor = scopeAccessor;
36-
_globalSettings = globalSettings;
37-
_connectionStrings = connectionStrings;
36+
_globalSettings = globalSettings.CurrentValue;
37+
_connectionStrings = connectionStrings.CurrentValue;
38+
globalSettings.OnChange(x => _globalSettings = x);
39+
connectionStrings.OnChange(x => _connectionStrings = x);
40+
3841
}
3942

4043
/// <inheritdoc />
41-
public bool Enabled => _connectionStrings.CurrentValue.IsConnectionStringConfigured() &&
42-
string.Equals(_connectionStrings.CurrentValue.ProviderName,Constants.ProviderName, StringComparison.InvariantCultureIgnoreCase);
44+
public bool Enabled => _connectionStrings.IsConnectionStringConfigured() &&
45+
string.Equals(_connectionStrings.ProviderName,Constants.ProviderName, StringComparison.InvariantCultureIgnoreCase);
4346

4447
/// <inheritdoc />
4548
public IDistributedLock ReadLock(int lockId, TimeSpan? obtainLockTimeout = null)
4649
{
47-
obtainLockTimeout ??= _globalSettings.CurrentValue.DistributedLockingReadLockDefaultTimeout;
50+
obtainLockTimeout ??= _globalSettings.DistributedLockingReadLockDefaultTimeout;
4851
return new SqlServerDistributedLock(this, lockId, DistributedLockType.ReadLock, obtainLockTimeout.Value);
4952
}
5053

5154
/// <inheritdoc />
5255
public IDistributedLock WriteLock(int lockId, TimeSpan? obtainLockTimeout = null)
5356
{
54-
obtainLockTimeout ??= _globalSettings.CurrentValue.DistributedLockingWriteLockDefaultTimeout;
57+
obtainLockTimeout ??= _globalSettings.DistributedLockingWriteLockDefaultTimeout;
5558
return new SqlServerDistributedLock(this, lockId, DistributedLockType.WriteLock, obtainLockTimeout.Value);
5659
}
5760

0 commit comments

Comments
 (0)