Skip to content

Commit dfc695d

Browse files
committed
Merge remote-tracking branch 'origin/v9/dev' into v9/feature/language-keys-cleanup
2 parents b837bf4 + e727f0f commit dfc695d

File tree

32 files changed

+476
-130
lines changed

32 files changed

+476
-130
lines changed

.devcontainer/Dockerfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,8 @@ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
4242
# Needing to set unsafe-perm as root is the user setup
4343
# https://docs.npmjs.com/cli/v6/using-npm/config#unsafe-perm
4444
# Default: false if running as root, true otherwise (we are ROOT)
45-
RUN npm -g config set user vscode && npm -g config set unsafe-perm
45+
RUN npm -g config set user vscode && npm -g config set unsafe-perm
46+
47+
# Generate and trust a local developer certificate for Kestrel
48+
# This is needed for Kestrel to bind on https
49+
RUN dotnet dev-certs https --trust

.devcontainer/docker-compose.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ version: '3'
22

33
services:
44
app:
5-
build:
5+
build:
66
context: .
77
dockerfile: Dockerfile
88
args:
@@ -18,7 +18,7 @@ services:
1818

1919
volumes:
2020
- ..:/workspace:cached
21-
21+
2222
# Overrides default command so things don't shut down after the process ends.
2323
command: sleep infinity
2424

@@ -28,7 +28,7 @@ services:
2828
# Uncomment the next line to use a non-root user for all processes.
2929
# user: vscode
3030

31-
# Use "forwardPorts" in **devcontainer.json** to forward an app port locally.
31+
# Use "forwardPorts" in **devcontainer.json** to forward an app port locally.
3232
# (Adding the "ports" property to this file will not forward from a Codespace.)
3333

3434
# DotNetCore ENV Variables
@@ -41,7 +41,7 @@ services:
4141
- Umbraco__CMS__Unattended__UnattendedUserPassword=password1234
4242
- Umbraco__CMS__Global__Smtp__Host=smtp4dev
4343
- Umbraco__CMS__Global__Smtp__Port=25
44-
- Umbraco__CMS__Global__Smtp__From=warren-env@umbraco.com
44+
- Umbraco__CMS__Global__Smtp__From=noreply@umbraco.test
4545

4646
db:
4747
image: mcr.microsoft.com/mssql/server:2019-latest

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
* text=auto
12
*.doc diff=astextplain
23
*.DOC diff=astextplain
34
*.docx diff=astextplain
@@ -44,6 +45,7 @@
4445
*.json text=auto
4546
*.xml text=auto
4647
*.resx text=auto
48+
*.yml text eol=lf core.whitespace whitespace=tab-in-indent,trailing-space,tabwidth=2
4749

4850
*.csproj text=auto merge=union
4951
*.vbproj text=auto merge=union
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0"?>
2+
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
3+
<runtime xdt:Transform="InsertIfMissing" />
4+
<runtime>
5+
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1" xdt:Transform="InsertIfMissing" />
6+
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
7+
<dependentAssembly xdt:Locator="Condition(./_defaultNamespace:assemblyIdentity/@name='System.Collections.Immutable')" xdt:Transform="Remove" />
8+
<dependentAssembly xdt:Locator="Condition(./_defaultNamespace:assemblyIdentity/@name='System.Buffers')" xdt:Transform="Remove" />
9+
<dependentAssembly xdt:Locator="Condition(./_defaultNamespace:assemblyIdentity/@name='System.Memory')" xdt:Transform="Remove" />
10+
<dependentAssembly xdt:Locator="Condition(./_defaultNamespace:assemblyIdentity/@name='System.Numerics.Vectors')" xdt:Transform="Remove" />
11+
<dependentAssembly xdt:Transform="Insert">
12+
<assemblyIdentity name="System.Collections.Immutable" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
13+
<bindingRedirect oldVersion="0.0.0.0-1.2.5.0" newVersion="1.2.5.0" />
14+
</dependentAssembly>
15+
<dependentAssembly xdt:Transform="Insert">
16+
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" />
17+
<bindingRedirect oldVersion="4.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
18+
</dependentAssembly>
19+
<dependentAssembly xdt:Transform="Insert">
20+
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" />
21+
<bindingRedirect oldVersion="4.0.0.0-4.0.1.1" newVersion="4.0.1.1" />
22+
</dependentAssembly>
23+
<dependentAssembly xdt:Transform="Insert">
24+
<assemblyIdentity name="System.Numerics.Vectors" publicKeyToken="b03f5f7f11d50a3a" />
25+
<bindingRedirect oldVersion="4.0.0.0-4.1.4.0" newVersion="4.1.4.0" />
26+
</dependentAssembly>
27+
</assemblyBinding>
28+
</runtime>
29+
</configuration>

build/build.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292
$src = "$($this.SolutionRoot)\src"
9393
$log = "$($this.BuildTemp)\belle.log"
9494

95+
9596
Write-Host "Compile Belle"
9697
Write-Host "Logging to $log"
9798

@@ -555,7 +556,6 @@
555556
# run
556557
if (-not $get)
557558
{
558-
cd
559559
if ($command.Length -eq 0)
560560
{
561561
$command = @( "Build" )
Lines changed: 13 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
23
<PropertyGroup>
34
<TargetFramework>net5.0</TargetFramework>
45
<RootNamespace Condition="'$(name)' != '$(name{-VALUE-FORMS-}safe_namespace)'">Umbraco.Cms.Web.UI</RootNamespace>
6+
<DefaultItemExcludes>$(DefaultItemExcludes);App_Plugins/**;</DefaultItemExcludes>
7+
<DefaultItemExcludes>$(DefaultItemExcludes);umbraco/**;</DefaultItemExcludes>
8+
<DefaultItemExcludes>$(DefaultItemExcludes);wwwroot/media/**;</DefaultItemExcludes>
59
</PropertyGroup>
610

711
<ItemGroup>
@@ -10,47 +14,24 @@
1014
<PackageReference Include="Umbraco.SqlServerCE" Version="4.0.0.1" Condition="'$(UseSqlCe)' == 'true'" />
1115
</ItemGroup>
1216

13-
<Import Project="..\PackageTestSiteName\build\PackageTestSiteName.targets" Condition="'$(PackageTestSiteName)' != ''"/>
17+
<Import Project="..\PackageTestSiteName\build\PackageTestSiteName.targets" Condition="'$(PackageTestSiteName)' != ''" />
18+
1419
<ItemGroup Condition="'$(PackageTestSiteName)' != ''">
15-
<ProjectReference Include="..\PackageTestSiteName\PackageTestSiteName.csproj"/>
20+
<ProjectReference Include="..\PackageTestSiteName\PackageTestSiteName.csproj" />
1621
</ItemGroup>
1722

1823
<ItemGroup>
19-
<Content Remove="umbraco\Data\**" />
20-
<Content Remove="umbraco\logs\**" />
21-
<Content Remove="umbraco\MediaCache\**" />
22-
</ItemGroup>
23-
<ItemGroup>
24-
<Compile Remove="umbraco\Data\**" />
25-
<Compile Remove="umbraco\logs\**" />
26-
<Compile Remove="umbraco\MediaCache\**" />
27-
</ItemGroup>
28-
<ItemGroup>
29-
<EmbeddedResource Remove="umbraco\Data\**" />
30-
<EmbeddedResource Remove="umbraco\logs\**" />
31-
<EmbeddedResource Remove="umbraco\MediaCache\**" />
32-
</ItemGroup>
33-
<ItemGroup>
34-
<None Include="config\**\*.*">
35-
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
36-
<CopyToPublishDirectory>Always</CopyToPublishDirectory>
37-
</None>
38-
<None Include="umbraco\**\*.*">
39-
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
40-
<CopyToPublishDirectory>Always</CopyToPublishDirectory>
41-
</None>
42-
<None Include="App_Plugins\**\*.*">
43-
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
44-
<CopyToPublishDirectory>Always</CopyToPublishDirectory>
45-
</None>
46-
<None Remove="umbraco\Data\**" />
47-
<None Remove="umbraco\logs\**" />
48-
<None Remove="umbraco\MediaCache\**" />
24+
<Content Include="App_Plugins/**" CopyToOutputDirectory="Always" />
25+
<Content Include="umbraco/**" CopyToOutputDirectory="Always" />
26+
<Content Remove="umbraco/Data/**" />
27+
<Content Remove="umbraco/Logs/**" />
28+
<Content Remove="umbraco/mediacache/**"/>
4929
</ItemGroup>
5030

5131
<!-- Set this to true if ModelsBuilder mode is not InMemoryAuto-->
5232
<PropertyGroup>
5333
<RazorCompileOnBuild>false</RazorCompileOnBuild>
5434
<RazorCompileOnPublish>false</RazorCompileOnPublish>
5535
</PropertyGroup>
36+
5637
</Project>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using System.Collections.Generic;
2+
using Umbraco.Cms.Core.Models;
3+
using Umbraco.Cms.Core.PropertyEditors;
4+
5+
namespace Umbraco.Cms.Core.Cache
6+
{
7+
public interface IValueEditorCache
8+
{
9+
public IDataValueEditor GetValueEditor(IDataEditor dataEditor, IDataType dataType);
10+
public void ClearCache(IEnumerable<int> dataTypeIds);
11+
}
12+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
using System.Collections.Generic;
2+
using Umbraco.Cms.Core.Models;
3+
using Umbraco.Cms.Core.PropertyEditors;
4+
5+
namespace Umbraco.Cms.Core.Cache
6+
{
7+
public class ValueEditorCache : IValueEditorCache
8+
{
9+
private readonly Dictionary<string, Dictionary<int, IDataValueEditor>> _valueEditorCache;
10+
private readonly object _dictionaryLocker;
11+
12+
public ValueEditorCache()
13+
{
14+
_valueEditorCache = new Dictionary<string, Dictionary<int, IDataValueEditor>>();
15+
_dictionaryLocker = new object();
16+
}
17+
18+
public IDataValueEditor GetValueEditor(IDataEditor editor, IDataType dataType)
19+
{
20+
// Lock just in case multiple threads uses the cache at the same time.
21+
lock (_dictionaryLocker)
22+
{
23+
// We try and get the dictionary based on the IDataEditor alias,
24+
// this is here just in case a data type can have more than one value data editor.
25+
// If this is not the case this could be simplified quite a bit, by just using the inner dictionary only.
26+
IDataValueEditor valueEditor;
27+
if (_valueEditorCache.TryGetValue(editor.Alias, out Dictionary<int, IDataValueEditor> dataEditorCache))
28+
{
29+
if (dataEditorCache.TryGetValue(dataType.Id, out valueEditor))
30+
{
31+
return valueEditor;
32+
}
33+
34+
valueEditor = editor.GetValueEditor(dataType.Configuration);
35+
dataEditorCache[dataType.Id] = valueEditor;
36+
return valueEditor;
37+
}
38+
39+
valueEditor = editor.GetValueEditor(dataType.Configuration);
40+
_valueEditorCache[editor.Alias] = new Dictionary<int, IDataValueEditor> { [dataType.Id] = valueEditor };
41+
return valueEditor;
42+
}
43+
}
44+
45+
public void ClearCache(IEnumerable<int> dataTypeIds)
46+
{
47+
lock (_dictionaryLocker)
48+
{
49+
// If a datatype is saved or deleted we have to clear any value editors based on their ID from the cache,
50+
// since it could mean that their configuration has changed.
51+
foreach (var id in dataTypeIds)
52+
{
53+
foreach (Dictionary<int, IDataValueEditor> editors in _valueEditorCache.Values)
54+
{
55+
editors.Remove(id);
56+
}
57+
}
58+
}
59+
}
60+
}
61+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using Umbraco.Cms.Core.Events;
5+
using Umbraco.Cms.Core.Notifications;
6+
using Umbraco.Cms.Core.Serialization;
7+
8+
namespace Umbraco.Cms.Core.Cache
9+
{
10+
public sealed class ValueEditorCacheRefresher : PayloadCacheRefresherBase<DataTypeCacheRefresherNotification, DataTypeCacheRefresher.JsonPayload>
11+
{
12+
private readonly IValueEditorCache _valueEditorCache;
13+
14+
public ValueEditorCacheRefresher(
15+
AppCaches appCaches,
16+
IJsonSerializer serializer,
17+
IEventAggregator eventAggregator,
18+
ICacheRefresherNotificationFactory factory,
19+
IValueEditorCache valueEditorCache) : base(appCaches, serializer, eventAggregator, factory)
20+
{
21+
_valueEditorCache = valueEditorCache;
22+
}
23+
24+
public static readonly Guid UniqueId = Guid.Parse("D28A1DBB-2308-4918-9A92-2F8689B6CBFE");
25+
public override Guid RefresherUniqueId => UniqueId;
26+
public override string Name => "ValueEditorCacheRefresher";
27+
28+
public override void Refresh(DataTypeCacheRefresher.JsonPayload[] payloads)
29+
{
30+
IEnumerable<int> ids = payloads.Select(x => x.Id);
31+
_valueEditorCache.ClearCache(ids);
32+
}
33+
34+
// these events should never trigger
35+
// everything should be PAYLOAD/JSON
36+
37+
public override void RefreshAll()
38+
{
39+
throw new NotSupportedException();
40+
}
41+
42+
public override void Refresh(int id)
43+
{
44+
throw new NotSupportedException();
45+
}
46+
47+
public override void Refresh(Guid id)
48+
{
49+
throw new NotSupportedException();
50+
}
51+
52+
public override void Remove(int id)
53+
{
54+
throw new NotSupportedException();
55+
}
56+
}
57+
}

src/Umbraco.Core/DependencyInjection/UmbracoBuilder.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,9 @@ private void AddCoreServices()
253253

254254
// register a basic/noop published snapshot service to be replaced
255255
Services.AddSingleton<IPublishedSnapshotService, InternalPublishedSnapshotService>();
256+
257+
// Register ValueEditorCache used for validation
258+
Services.AddSingleton<IValueEditorCache, ValueEditorCache>();
256259
}
257260
}
258261
}

0 commit comments

Comments
 (0)