Skip to content

Commit

Permalink
Merge branch 'v15/dev' into contrib
Browse files Browse the repository at this point in the history
  • Loading branch information
nul800sebastiaan committed Oct 28, 2024
2 parents 15f42f9 + e92a1b7 commit 7faceb3
Show file tree
Hide file tree
Showing 134 changed files with 3,915 additions and 986 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<NeutralLanguage>en-US</NeutralLanguage>
<Nullable>enable</Nullable>
<WarningsAsErrors>nullable</WarningsAsErrors>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<TreatWarningsAsErrors Condition="'$(Configuration)' != 'Debug'">true</TreatWarningsAsErrors>
<ImplicitUsings>enable</ImplicitUsings>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<WarnOnPackingNonPackableProject>false</WarnOnPackingNonPackableProject>
Expand Down
4 changes: 2 additions & 2 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<PackageVersion Include="K4os.Compression.LZ4" Version="1.3.8" />
<PackageVersion Include="MailKit" Version="4.8.0" />
<PackageVersion Include="Markdown" Version="2.2.1" />
<PackageVersion Include="MessagePack" Version="2.5.172" />
<PackageVersion Include="MessagePack" Version="2.5.187" />
<PackageVersion Include="MiniProfiler.AspNetCore.Mvc" Version="4.3.8" />
<PackageVersion Include="MiniProfiler.Shared" Version="4.3.8" />
<PackageVersion Include="ncrontab" Version="3.3.3" />
Expand Down Expand Up @@ -86,7 +86,7 @@
<!-- Dazinator.Extensions.FileProviders brings in a vulnerable version of System.Net.Http -->
<PackageVersion Include="System.Net.Http" Version="4.3.4" />
<!-- Examine brings in a vulnerable version of System.Security.Cryptography.Xml -->
<PackageVersion Include="System.Security.Cryptography.Xml" Version="9.0.0-rc.1.24431.7" />
<PackageVersion Include="System.Security.Cryptography.Xml" Version="9.0.0-rc.2.24473.5" />
<!-- Both Dazinator.Extensions.FileProviders and MiniProfiler.AspNetCore.Mvc bring in a vulnerable version of System.Text.RegularExpressions -->
<PackageVersion Include="System.Text.RegularExpressions" Version="4.3.1" />
<!-- Both OpenIddict.AspNetCore, Npoco.SqlServer and Microsoft.EntityFrameworkCore.SqlServer bring in a vulnerable version of Microsoft.IdentityModel.JsonWebTokens -->
Expand Down
5 changes: 3 additions & 2 deletions build/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ stages:
- job: A
displayName: Build Umbraco CMS
pool:
vmImage: 'ubuntu-latest'
vmImage: 'windows-latest'
steps:
- checkout: self
submodules: true
Expand Down Expand Up @@ -284,6 +284,7 @@ stages:
jobs:
# Integration Tests (SQLite)
- job:
timeoutInMinutes: 180
displayName: Integration Tests (SQLite)
strategy:
matrix:
Expand Down Expand Up @@ -513,7 +514,7 @@ stages:
workingDirectory: tests/Umbraco.Tests.AcceptanceTest

# Test
- pwsh: npm run smokeTest --ignore-certificate-errors
- pwsh: npm run smokeTestSqlite --ignore-certificate-errors
displayName: Run Playwright tests
continueOnError: true
workingDirectory: tests/Umbraco.Tests.AcceptanceTest
Expand Down
4 changes: 2 additions & 2 deletions build/nightly-E2E-test-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,9 @@ stages:

# Test
- ${{ if eq(parameters.runSmokeTests, true) }}:
pwsh: npm run smokeTest --ignore-certificate-errors
pwsh: npm run smokeTestSqlite --ignore-certificate-errors
${{ else }}:
pwsh: npm run test --ignore-certificate-errors
pwsh: npm run testSqlite --ignore-certificate-errors
displayName: Run Playwright tests
continueOnError: true
workingDirectory: tests/Umbraco.Tests.AcceptanceTest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public async Task<IActionResult> Item(
return Ok(Enumerable.Empty<DocumentTypeItemResponseModel>());
}

IEnumerable<IContentType> contentTypes = _contentTypeService.GetAll(ids);
IEnumerable<IContentType> contentTypes = _contentTypeService.GetMany(ids);
List<DocumentTypeItemResponseModel> responseModels = _mapper.MapEnumerable<IContentType, DocumentTypeItemResponseModel>(contentTypes);
return await Task.FromResult(Ok(responseModels));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public async Task<IActionResult> Search(CancellationToken cancellationToken, str
return await Task.FromResult(Ok(new PagedModel<DocumentTypeItemResponseModel> { Total = searchResult.Total }));
}

IEnumerable<IContentType> contentTypes = _contentTypeService.GetAll(searchResult.Items.Select(item => item.Key).ToArray().EmptyNull());
IEnumerable<IContentType> contentTypes = _contentTypeService.GetMany(searchResult.Items.Select(item => item.Key).ToArray().EmptyNull());
var result = new PagedModel<DocumentTypeItemResponseModel>
{
Items = _mapper.MapEnumerable<IContentType, DocumentTypeItemResponseModel>(contentTypes),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public DocumentTypeTreeControllerBase(IEntityService entityService, IContentType
protected override DocumentTypeTreeItemResponseModel[] MapTreeItemViewModels(Guid? parentKey, IEntitySlim[] entities)
{
var contentTypes = _contentTypeService
.GetAll(entities.Select(entity => entity.Id).ToArray())
.GetMany(entities.Select(entity => entity.Id).ToArray())
.ToDictionary(contentType => contentType.Id);

return entities.Select(entity =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public async Task<IActionResult> Item(
return Ok(Enumerable.Empty<MediaTypeItemResponseModel>());
}

IEnumerable<IMediaType> mediaTypes = _mediaTypeService.GetAll(ids);
IEnumerable<IMediaType> mediaTypes = _mediaTypeService.GetMany(ids);
List<MediaTypeItemResponseModel> responseModels = _mapper.MapEnumerable<IMediaType, MediaTypeItemResponseModel>(mediaTypes);
return await Task.FromResult(Ok(responseModels));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public async Task<IActionResult> Search(CancellationToken cancellationToken, str
return await Task.FromResult(Ok(new PagedModel<MediaTypeItemResponseModel> { Total = searchResult.Total }));
}

IEnumerable<IMediaType> mediaTypes = _mediaTypeService.GetAll(searchResult.Items.Select(item => item.Key).ToArray().EmptyNull());
IEnumerable<IMediaType> mediaTypes = _mediaTypeService.GetMany(searchResult.Items.Select(item => item.Key).ToArray().EmptyNull());
var result = new PagedModel<MediaTypeItemResponseModel>
{
Items = _mapper.MapEnumerable<IMediaType, MediaTypeItemResponseModel>(mediaTypes),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public MediaTypeTreeControllerBase(IEntityService entityService, IMediaTypeServi
protected override MediaTypeTreeItemResponseModel[] MapTreeItemViewModels(Guid? parentKey, IEntitySlim[] entities)
{
var mediaTypes = _mediaTypeService
.GetAll(entities.Select(entity => entity.Id).ToArray())
.GetMany(entities.Select(entity => entity.Id).ToArray())
.ToDictionary(contentType => contentType.Id);

return entities.Select(entity =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public async Task<IActionResult> Item(
return Ok(Enumerable.Empty<MemberTypeItemResponseModel>());
}

IEnumerable<IMemberType> memberTypes = _memberTypeService.GetAll(ids);
IEnumerable<IMemberType> memberTypes = _memberTypeService.GetMany(ids);
List<MemberTypeItemResponseModel> responseModels = _mapper.MapEnumerable<IMemberType, MemberTypeItemResponseModel>(memberTypes);
return Ok(responseModels);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public async Task<IActionResult> Search(CancellationToken cancellationToken, str
return await Task.FromResult(Ok(new PagedModel<MemberTypeItemResponseModel> { Total = searchResult.Total }));
}

IEnumerable<IMemberType> memberTypes = _memberTypeService.GetAll(searchResult.Items.Select(item => item.Key).ToArray());
IEnumerable<IMemberType> memberTypes = _memberTypeService.GetMany(searchResult.Items.Select(item => item.Key).ToArray());
var result = new PagedModel<MemberTypeItemResponseModel>
{
Items = _mapper.MapEnumerable<IMemberType, MemberTypeItemResponseModel>(memberTypes),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public MemberTypeTreeControllerBase(IEntityService entityService, IMemberTypeSer
protected override MemberTypeTreeItemResponseModel[] MapTreeItemViewModels(Guid? parentKey, IEntitySlim[] entities)
{
var memberTypes = _memberTypeService
.GetAll(entities.Select(entity => entity.Id).ToArray())
.GetMany(entities.Select(entity => entity.Id).ToArray())
.ToDictionary(contentType => contentType.Id);

return entities.Select(entity =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public async Task<ActionResult<TemplateQueryResultResponseModel>> Execute(
timer.Stop();

var contentTypeIconsByKey = _contentTypeService
.GetAll(results.Select(content => content.ContentType.Key).Distinct())
.GetMany(results.Select(content => content.ContentType.Key).Distinct())
.ToDictionary(contentType => contentType.Key, contentType => contentType.Icon);

return await Task.FromResult(Ok(new TemplateQueryResultResponseModel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ public IEnumerable<DataTypeReferenceResponseModel> CreateDataTypeReferenceViewMo
{
var getContentTypesByObjectType = new Dictionary<string, Func<IEnumerable<Guid>, IEnumerable<IContentTypeBase>>>
{
{ UmbracoObjectTypes.DocumentType.GetUdiType(), keys => _contentTypeService.GetAll(keys) },
{ UmbracoObjectTypes.MediaType.GetUdiType(), keys => _mediaTypeService.GetAll(keys) },
{ UmbracoObjectTypes.MemberType.GetUdiType(), keys => _memberTypeService.GetAll(keys) }
{ UmbracoObjectTypes.DocumentType.GetUdiType(), keys => _contentTypeService.GetMany(keys) },
{ UmbracoObjectTypes.MediaType.GetUdiType(), keys => _mediaTypeService.GetMany(keys) },
{ UmbracoObjectTypes.MemberType.GetUdiType(), keys => _memberTypeService.GetMany(keys) }
};

foreach (IGrouping<string, KeyValuePair<Udi, IEnumerable<string>>> usagesByEntityType in dataTypeUsages.GroupBy(u => u.Key.EntityType))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,45 @@ namespace Umbraco.Cms.Persistence.EFCore.Scoping;

public class AmbientEFCoreScopeStack<TDbContext> : IAmbientEFCoreScopeStack<TDbContext> where TDbContext : DbContext
{

private static Lock _lock = new();
private static AsyncLocal<ConcurrentStack<IEfCoreScope<TDbContext>>> _stack = new();

public IEfCoreScope<TDbContext>? AmbientScope
{
get
{
if (_stack.Value?.TryPeek(out IEfCoreScope<TDbContext>? ambientScope) ?? false)
lock (_lock)
{
return ambientScope;
}
if (_stack.Value?.TryPeek(out IEfCoreScope<TDbContext>? ambientScope) ?? false)
{
return ambientScope;
}

return null;
return null;
}
}
}

public IEfCoreScope<TDbContext> Pop()
{
if (_stack.Value?.TryPop(out IEfCoreScope<TDbContext>? ambientScope) ?? false)
lock (_lock)
{
return ambientScope;
}
if (_stack.Value?.TryPop(out IEfCoreScope<TDbContext>? ambientScope) ?? false)
{
return ambientScope;
}

throw new InvalidOperationException("No AmbientScope was found.");
throw new InvalidOperationException("No AmbientScope was found.");
}
}

public void Push(IEfCoreScope<TDbContext> scope)
{
_stack.Value ??= new ConcurrentStack<IEfCoreScope<TDbContext>>();
lock (_lock)
{
_stack.Value ??= new ConcurrentStack<IEfCoreScope<TDbContext>>();

_stack.Value.Push(scope);
_stack.Value.Push(scope);
}
}
}
3 changes: 2 additions & 1 deletion src/Umbraco.Cms.StaticAssets/Umbraco.Cms.StaticAssets.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<Description>Contains the static assets needed to run Umbraco CMS.</Description>
<AddRazorSupportForMvc>true</AddRazorSupportForMvc>
<StaticWebAssetBasePath>/</StaticWebAssetBasePath>
<CompressionEnabled>false</CompressionEnabled> <!-- Disable compression. E.g. for umbraco backoffice files. These files should be precompressed by node and not let dotnet handle it -->
</PropertyGroup>

<PropertyGroup>
Expand Down Expand Up @@ -76,4 +77,4 @@
</ItemGroup>
<RemoveDir Directories="@(LoginDirectories)" />
</Target>
</Project>
</Project>
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using Microsoft.Extensions.DependencyInjection;
using Umbraco.Cms.Core.DependencyInjection;
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Notifications;
Expand All @@ -22,6 +20,7 @@ public sealed class ContentCacheRefresher : PayloadCacheRefresherBase<ContentCac
private readonly IDocumentNavigationQueryService _documentNavigationQueryService;
private readonly IDocumentNavigationManagementService _documentNavigationManagementService;
private readonly IContentService _contentService;
private readonly IPublishStatusManagementService _publishStatusManagementService;
private readonly IIdKeyMap _idKeyMap;

public ContentCacheRefresher(
Expand All @@ -35,7 +34,8 @@ public ContentCacheRefresher(
IDomainCacheService domainCacheService,
IDocumentNavigationQueryService documentNavigationQueryService,
IDocumentNavigationManagementService documentNavigationManagementService,
IContentService contentService)
IContentService contentService,
IPublishStatusManagementService publishStatusManagementService)
: base(appCaches, serializer, eventAggregator, factory)
{
_idKeyMap = idKeyMap;
Expand All @@ -45,6 +45,7 @@ public ContentCacheRefresher(
_documentNavigationQueryService = documentNavigationQueryService;
_documentNavigationManagementService = documentNavigationManagementService;
_contentService = contentService;
_publishStatusManagementService = publishStatusManagementService;
}

#region Indirect
Expand Down Expand Up @@ -109,6 +110,7 @@ public override void Refresh(JsonPayload[] payloads)
HandleRouting(payload);

HandleNavigation(payload);
HandlePublishedAsync(payload, CancellationToken.None).GetAwaiter().GetResult();
_idKeyMap.ClearCache(payload.Id);
if (payload.Key.HasValue)
{
Expand Down Expand Up @@ -143,6 +145,13 @@ public override void Refresh(JsonPayload[] payloads)

private void HandleNavigation(JsonPayload payload)
{

if (payload.ChangeTypes.HasType(TreeChangeTypes.RefreshAll))
{
_documentNavigationManagementService.RebuildAsync();
_documentNavigationManagementService.RebuildBinAsync();
}

if (payload.Key is null)
{
return;
Expand All @@ -154,15 +163,9 @@ private void HandleNavigation(JsonPayload payload)
_documentNavigationManagementService.RemoveFromBin(payload.Key.Value);
}

if (payload.ChangeTypes.HasType(TreeChangeTypes.RefreshAll))
{
_documentNavigationManagementService.RebuildAsync();
_documentNavigationManagementService.RebuildBinAsync();
}

if (payload.ChangeTypes.HasType(TreeChangeTypes.RefreshNode))
{
IContent? content = _contentService.GetById(payload.Id);
IContent? content = _contentService.GetById(payload.Key.Value);

if (content is null)
{
Expand All @@ -174,7 +177,7 @@ private void HandleNavigation(JsonPayload payload)

if (payload.ChangeTypes.HasType(TreeChangeTypes.RefreshBranch))
{
IContent? content = _contentService.GetById(payload.Id);
IContent? content = _contentService.GetById(payload.Key.Value);

if (content is null)
{
Expand All @@ -194,7 +197,7 @@ private void HandleNavigationForSingleContent(IContent content)
// First creation
if (ExistsInNavigation(content.Key) is false && ExistsInNavigationBin(content.Key) is false)
{
_documentNavigationManagementService.Add(content.Key, GetParentKey(content));
_documentNavigationManagementService.Add(content.Key, GetParentKey(content), content.SortOrder);
if (content.Trashed)
{
// If created as trashed, move to bin
Expand All @@ -210,14 +213,20 @@ private void HandleNavigationForSingleContent(IContent content)
}
else
{
if (_documentNavigationQueryService.TryGetParentKey(content.Key, out Guid? oldParentKey) is false)
{
return;
}

// It must have been saved. Check if parent is different
if (_documentNavigationQueryService.TryGetParentKey(content.Key, out var oldParentKey))
Guid? newParentKey = GetParentKey(content);
if (oldParentKey != newParentKey)
{
_documentNavigationManagementService.Move(content.Key, newParentKey);
}
else
{
Guid? newParentKey = GetParentKey(content);
if (oldParentKey != newParentKey)
{
_documentNavigationManagementService.Move(content.Key, newParentKey);
}
_documentNavigationManagementService.UpdateSortOrder(content.Key, content.SortOrder);
}
}
}
Expand All @@ -237,6 +246,32 @@ private void HandleNavigationForSingleContent(IContent content)

private bool ExistsInNavigationBin(Guid contentKey) => _documentNavigationQueryService.TryGetParentKeyInBin(contentKey, out _);

private async Task HandlePublishedAsync(JsonPayload payload, CancellationToken cancellationToken)
{

if (payload.ChangeTypes.HasType(TreeChangeTypes.RefreshAll))
{
await _publishStatusManagementService.InitializeAsync(cancellationToken);
}

if (payload.Key.HasValue is false)
{
return;
}

if (payload.ChangeTypes.HasType(TreeChangeTypes.Remove))
{
await _publishStatusManagementService.RemoveAsync(payload.Key.Value, cancellationToken);
}
else if (payload.ChangeTypes.HasType(TreeChangeTypes.RefreshNode))
{
await _publishStatusManagementService.AddOrUpdateStatusAsync(payload.Key.Value, cancellationToken);
}
else if (payload.ChangeTypes.HasType(TreeChangeTypes.RefreshBranch))
{
await _publishStatusManagementService.AddOrUpdateStatusWithDescendantsAsync(payload.Key.Value, cancellationToken);
}
}
private void HandleRouting(JsonPayload payload)
{
if(payload.ChangeTypes.HasType(TreeChangeTypes.Remove))
Expand Down
Loading

0 comments on commit 7faceb3

Please sign in to comment.