Merge remote-tracking branch 'origin/v13/dev' into v14/dev

# Conflicts:
#	Directory.Packages.props
#	src/Umbraco.Infrastructure/Migrations/Upgrade/V_10_0_0/AddMemberPropertiesAsColumns.cs
#	src/Umbraco.Infrastructure/Migrations/Upgrade/V_10_2_0/AddHasAccessToAllLanguagesColumn.cs
#	src/Umbraco.Infrastructure/Migrations/Upgrade/V_10_2_0/AddUserGroup2LanguageTable.cs
#	src/Umbraco.Infrastructure/Migrations/Upgrade/V_10_3_0/AddBlockGridPartialViews.cs
#	src/Umbraco.Infrastructure/Migrations/Upgrade/V_10_4_0/AddBlockGridPartialViews.cs
#	src/Umbraco.Infrastructure/Migrations/Upgrade/V_10_5_0/AddPrimaryKeyConstrainToContentVersionCleanupDtos.cs
#	src/Umbraco.Infrastructure/Migrations/Upgrade/V_10_7_0/MigrateTagsFromNVarcharToNText.cs
#	src/Umbraco.Infrastructure/Migrations/Upgrade/V_11_3_0/AddDomainSortOrder.cs
#	src/Umbraco.Infrastructure/Migrations/Upgrade/V_11_4_0/AlterKeyValueDataType.cs
#	src/Umbraco.Infrastructure/Migrations/Upgrade/V_12_0_0/ResetCache.cs
#	src/Umbraco.Infrastructure/Migrations/Upgrade/V_12_0_0/UseNvarcharInsteadOfNText.cs
#	src/Umbraco.Infrastructure/Migrations/Upgrade/V_12_1_0/AddOpenIddict.cs
#	src/Umbraco.Infrastructure/Migrations/Upgrade/V_12_1_0/TablesIndexesImprovement.cs
#	src/Umbraco.Web.UI.Docs/README.md
#	src/Umbraco.Web.UI.Docs/gulpfile.js
This commit is contained in:
Bjarke Berg
2024-02-01 11:24:43 +01:00
15 changed files with 273 additions and 84 deletions

View File

@@ -12,25 +12,25 @@
</ItemGroup>
<!-- Microsoft packages -->
<ItemGroup>
<PackageVersion Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="8.0.0" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="8.0.0" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="8.0.1" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="8.0.1" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.8.0" />
<PackageVersion Include="Microsoft.Data.Sqlite" Version="8.0.0" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.0" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.0" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Caching.Memory" Version="8.0.0" />
<PackageVersion Include="Microsoft.Data.Sqlite" Version="8.0.1" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.1" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.1" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.1" />
<PackageVersion Include="Microsoft.Extensions.Caching.Memory" Version="8.0.1" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.FileProviders.Embedded" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.FileProviders.Embedded" Version="8.0.1" />
<PackageVersion Include="Microsoft.Extensions.FileProviders.Physical" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Hosting.Abstractions" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Http" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Identity.Core" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Identity.Stores" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Identity.Core" Version="8.0.1" />
<PackageVersion Include="Microsoft.Extensions.Identity.Stores" Version="8.0.1" />
<PackageVersion Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Options" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Options" Version="8.0.1" />
<PackageVersion Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Options.DataAnnotations" Version="8.0.0" />
</ItemGroup>
@@ -44,9 +44,9 @@
<PackageVersion Include="Asp.Versioning.Mvc" Version="8.0.0" />
<PackageVersion Include="Asp.Versioning.Mvc.ApiExplorer" Version="8.0.0" />
<PackageVersion Include="Dazinator.Extensions.FileProviders" Version="2.0.0" />
<PackageVersion Include="Examine" Version="3.1.0" />
<PackageVersion Include="Examine.Core" Version="3.1.0" />
<PackageVersion Include="HtmlAgilityPack" Version="1.11.54" />
<PackageVersion Include="Examine" Version="3.2.0" />
<PackageVersion Include="Examine.Core" Version="3.2.0" />
<PackageVersion Include="HtmlAgilityPack" Version="1.11.57" />
<PackageVersion Include="JsonPatch.Net" Version="2.1.0" />
<PackageVersion Include="K4os.Compression.LZ4" Version="1.3.6" />
<PackageVersion Include="MailKit" Version="4.3.0" />
@@ -62,7 +62,7 @@
<PackageVersion Include="OpenIddict.AspNetCore" Version="4.10.1" />
<PackageVersion Include="OpenIddict.EntityFrameworkCore" Version="4.10.1" />
<PackageVersion Include="Serilog" Version="3.1.1" />
<PackageVersion Include="Serilog.AspNetCore" Version="8.0.0" />
<PackageVersion Include="Serilog.AspNetCore" Version="8.0.1" />
<PackageVersion Include="Serilog.Enrichers.Process" Version="2.0.2" />
<PackageVersion Include="Serilog.Enrichers.Thread" Version="3.1.0" />
<PackageVersion Include="Serilog.Expressions" Version="4.0.0" />
@@ -73,12 +73,11 @@
<PackageVersion Include="Serilog.Sinks.Async" Version="1.5.0" />
<PackageVersion Include="Serilog.Sinks.File" Version="5.0.0" />
<PackageVersion Include="Serilog.Sinks.Map" Version="1.0.2" />
<PackageVersion Include="SixLabors.ImageSharp" Version="3.1.0" />
<PackageVersion Include="SixLabors.ImageSharp" Version="3.1.2" />
<PackageVersion Include="SixLabors.ImageSharp.Web" Version="3.1.0" />
<PackageVersion Include="Smidge.InMemory" Version="4.3.0" />
<PackageVersion Include="Smidge.Nuglify" Version="4.3.0" />
<PackageVersion Include="Swashbuckle.AspNetCore" Version="6.5.0" />
<PackageVersion Include="Swashbuckle.AspNetCore" Version="6.5.0" />
</ItemGroup>
<!-- Transitive pinned versions (only required because our direct dependencies have vulnerable versions of transitive dependencies) -->
<ItemGroup>

View File

@@ -36,19 +36,14 @@ public class UmbracoDbContext : DbContext
/// </summary>
/// <param name="options"></param>
public UmbracoDbContext(DbContextOptions<UmbracoDbContext> options)
: base(ConfigureOptions(options, out IOptionsMonitor<ConnectionStrings>? connectionStringsOptionsMonitor))
: base(ConfigureOptions(options))
{
connectionStringsOptionsMonitor.OnChange(c =>
{
ILogger<UmbracoDbContext> logger = StaticServiceProvider.Instance.GetRequiredService<ILogger<UmbracoDbContext>>();
logger.LogWarning("Connection string changed, disposing context");
Dispose();
});
}
private static DbContextOptions<UmbracoDbContext> ConfigureOptions(DbContextOptions<UmbracoDbContext> options, out IOptionsMonitor<ConnectionStrings> connectionStringsOptionsMonitor)
private static DbContextOptions<UmbracoDbContext> ConfigureOptions(DbContextOptions<UmbracoDbContext> options)
{
connectionStringsOptionsMonitor = StaticServiceProvider.Instance.GetRequiredService<IOptionsMonitor<ConnectionStrings>>();
IOptionsMonitor<ConnectionStrings> connectionStringsOptionsMonitor = StaticServiceProvider.Instance.GetRequiredService<IOptionsMonitor<ConnectionStrings>>();
ConnectionStrings connectionStrings = connectionStringsOptionsMonitor.CurrentValue;

View File

@@ -118,15 +118,35 @@ public static class DistributedCacheExtensions
#region ContentCacheRefresher
public static void RefreshAllContentCache(this DistributedCache dc)
{
ContentCacheRefresher.JsonPayload[] payloads = new[]
{
new ContentCacheRefresher.JsonPayload()
{
ChangeTypes = TreeChangeTypes.RefreshAll
}
};
// note: refresh all content cache does refresh content types too
=> dc.RefreshByPayload(ContentCacheRefresher.UniqueId, new ContentCacheRefresher.JsonPayload(0, null, TreeChangeTypes.RefreshAll).Yield());
dc.RefreshByPayload(ContentCacheRefresher.UniqueId, payloads);
}
[Obsolete("Use the overload accepting IEnumerable instead to avoid allocating arrays. This overload will be removed in Umbraco 13.")]
public static void RefreshContentCache(this DistributedCache dc, TreeChange<IContent>[] changes)
=> dc.RefreshContentCache(changes.AsEnumerable());
public static void RefreshContentCache(this DistributedCache dc, IEnumerable<TreeChange<IContent>> changes)
=> dc.RefreshByPayload(ContentCacheRefresher.UniqueId, changes.DistinctBy(x => (x.Item.Id, x.Item.Key, x.ChangeTypes)).Select(x => new ContentCacheRefresher.JsonPayload(x.Item.Id, x.Item.Key, x.ChangeTypes)));
{
IEnumerable<ContentCacheRefresher.JsonPayload> payloads = changes.Select(x => new ContentCacheRefresher.JsonPayload()
{
Id = x.Item.Id,
Key = x.Item.Key,
ChangeTypes = x.ChangeTypes,
Blueprint = x.Item.Blueprint
});
dc.RefreshByPayload(ContentCacheRefresher.UniqueId, payloads);
}
#endregion

View File

@@ -84,8 +84,8 @@ public sealed class ContentCacheRefresher : PayloadCacheRefresherBase<ContentCac
isolatedCache.ClearOfType<IContent>((k, v) => v.Path?.Contains(pathid) ?? false);
}
// if the item is being completely removed, we need to refresh the domains cache if any domain was assigned to the content
if (payload.ChangeTypes.HasTypesAny(TreeChangeTypes.Remove))
// if the item is not a blueprint and is being completely removed, we need to refresh the domains cache if any domain was assigned to the content
if (payload.Blueprint is false && payload.ChangeTypes.HasTypesAny(TreeChangeTypes.Remove))
{
idsRemoved.Add(payload.Id);
}
@@ -120,7 +120,11 @@ public sealed class ContentCacheRefresher : PayloadCacheRefresherBase<ContentCac
// should rename it, and then, this is only for Deploy, and then, ???
// if (Suspendable.PageCacheRefresher.CanUpdateDocumentCache)
// ...
NotifyPublishedSnapshotService(_publishedSnapshotService, AppCaches, payloads);
if (payloads.Any(x => x.Blueprint is false))
{
// Only notify if the payload contains actual (non-blueprint) contents
NotifyPublishedSnapshotService(_publishedSnapshotService, AppCaches, payloads);
}
base.Refresh(payloads);
}
@@ -157,8 +161,13 @@ public sealed class ContentCacheRefresher : PayloadCacheRefresherBase<ContentCac
}
}
// TODO (V14): Change into a record
public class JsonPayload
{
public JsonPayload()
{ }
[Obsolete("Use the default constructor and property initializers.")]
public JsonPayload(int id, Guid? key, TreeChangeTypes changeTypes)
{
Id = id;
@@ -166,11 +175,13 @@ public sealed class ContentCacheRefresher : PayloadCacheRefresherBase<ContentCac
ChangeTypes = changeTypes;
}
public int Id { get; }
public int Id { get; init; }
public Guid? Key { get; }
public Guid? Key { get; init; }
public TreeChangeTypes ChangeTypes { get; }
public TreeChangeTypes ChangeTypes { get; init; }
public bool Blueprint { get; init; }
}
#endregion

View File

@@ -134,8 +134,14 @@ public sealed class LanguageCacheRefresher : PayloadCacheRefresherBase<LanguageC
ContentCacheRefresher.RefreshContentTypes(AppCaches); // we need to evict all IContent items
// now refresh all nucache
ContentCacheRefresher.JsonPayload[] clearContentPayload =
new[] { new ContentCacheRefresher.JsonPayload(0, null, TreeChangeTypes.RefreshAll) };
ContentCacheRefresher.JsonPayload[] clearContentPayload = new[]
{
new ContentCacheRefresher.JsonPayload()
{
ChangeTypes = TreeChangeTypes.RefreshAll
}
};
ContentCacheRefresher.NotifyPublishedSnapshotService(_publishedSnapshotService, AppCaches, clearContentPayload);
}

View File

@@ -53,13 +53,15 @@ public sealed class ContentIndexingNotificationHandler :
foreach (ContentCacheRefresher.JsonPayload payload in (ContentCacheRefresher.JsonPayload[])args.MessageObject)
{
if (payload.Blueprint)
{
// Skip blueprints
continue;
}
if (payload.ChangeTypes.HasType(TreeChangeTypes.Remove))
{
if (deleteBatch == null)
{
deleteBatch = new HashSet<int>();
}
deleteBatch ??= new HashSet<int>();
deleteBatch.Add(payload.Id);
}
else if (payload.ChangeTypes.HasType(TreeChangeTypes.RefreshAll))

View File

@@ -220,7 +220,16 @@ internal class PublishedSnapshotService : IPublishedSnapshotService
// they require.
using (_contentStore.GetScopedWriteLock(_scopeProvider))
{
NotifyLocked(new[] { new ContentCacheRefresher.JsonPayload(0, null, TreeChangeTypes.RefreshAll) }, out _, out _);
NotifyLocked(
new[]
{
new ContentCacheRefresher.JsonPayload()
{
ChangeTypes = TreeChangeTypes.RefreshAll
}
},
out _,
out _);
}
using (_mediaStore.GetScopedWriteLock(_scopeProvider))
@@ -885,6 +894,12 @@ internal class PublishedSnapshotService : IPublishedSnapshotService
_logger.LogDebug("Notified {ChangeTypes} for content {ContentId}", payload.ChangeTypes, payload.Id);
}
if (payload.Blueprint)
{
// Skip blueprints
continue;
}
if (payload.ChangeTypes.HasType(TreeChangeTypes.RefreshAll))
{
using (IScope scope = _scopeProvider.CreateScope())

View File

@@ -18,7 +18,7 @@ namespace Umbraco.Cms.Web.BackOffice.Filters;
/// Validates the incoming <see cref="ContentItemSave" /> model along with if the user is allowed to perform the
/// operation
/// </summary>
internal sealed class ContentSaveValidationAttribute : TypeFilterAttribute
public sealed class ContentSaveValidationAttribute : TypeFilterAttribute
{
public ContentSaveValidationAttribute(bool skipUserAccessValidation = false)
: base(typeof(ContentSaveValidationFilter))

View File

@@ -7,7 +7,7 @@ using Umbraco.Cms.Core.Services;
namespace Umbraco.Cms.Web.BackOffice.ModelBinders;
internal class BlueprintItemBinder : ContentItemBinder
public class BlueprintItemBinder : ContentItemBinder
{
private readonly IContentService _contentService;

View File

@@ -13,7 +13,7 @@ namespace Umbraco.Cms.Web.BackOffice.ModelBinders;
/// <summary>
/// The model binder for <see cref="T:Umbraco.Web.Models.ContentEditing.ContentItemSave" />
/// </summary>
internal class ContentItemBinder : IModelBinder
public class ContentItemBinder : IModelBinder
{
private readonly IContentService _contentService;
private readonly IContentTypeService _contentTypeService;

View File

@@ -367,7 +367,6 @@
* @name load
* @methodOf umbraco.services.blockEditorModelObject
* @description Load the scaffolding models for the given configuration, these are needed to provide useful models for each block.
* @param {Object} blockObject BlockObject to receive data values from.
* @returns {Promise} A Promise object which resolves when all scaffold models are loaded.
*/
load: function () {
@@ -398,9 +397,15 @@
scaffoldKeys = scaffoldKeys.filter((value, index, self) => self.indexOf(value) === index);
if(scaffoldKeys.length > 0) {
var currentPage = editorState.getCurrent();
var currentPageId = currentPage ? (currentPage.id > 0 ? currentPage.id : currentPage.parentId) : null || -20;
// We need to know if we are in the document type editor or content editor.
// If we are in the document type editor, we need to use -20 as the current page id.
// If we are in the content editor, we need to use the current page id or parent id if the current page is new.
// We can recognize a content editor context by checking if the current editor state has a contentTypeKey.
const currentEditorState = editorState.getCurrent();
const currentPageId = currentEditorState.contentTypeKey ? currentEditorState.id || currentEditorState.parentId || -20 : -20;
// Load all scaffolds for the block types.
// The currentPageId is used to determine the access level for the current user.
tasks.push(contentResource.getScaffoldByKeys(currentPageId, scaffoldKeys).then(scaffolds => {
Object.values(scaffolds).forEach(scaffold => {
// self.scaffolds might not exists anymore, this happens if this instance has been destroyed before the load is complete.

View File

@@ -0,0 +1 @@
10.15

View File

@@ -4,8 +4,8 @@
<Import Project="$([MSBuild]::GetPathOfFileAbove(Directory.Packages.props, $(MSBuildThisFileDirectory)..))" />
<ItemGroup>
<!-- Microsoft packages -->
<PackageVersion Include="BenchmarkDotNet" Version="0.13.11" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="8.0.0" />
<PackageVersion Include="BenchmarkDotNet" Version="0.13.12" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="8.0.1" />
<PackageVersion Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageVersion Include="System.Data.DataSetExtensions" Version="4.5.0" />

View File

@@ -18,8 +18,10 @@ public class RefresherTests
{
new MediaCacheRefresher.JsonPayload(1234, Guid.NewGuid(), TreeChangeTypes.None),
};
var json = JsonConvert.SerializeObject(source);
var payload = JsonConvert.DeserializeObject<MediaCacheRefresher.JsonPayload[]>(json);
Assert.AreEqual(source[0].Id, payload[0].Id);
Assert.AreEqual(source[0].Key, payload[0].Key);
Assert.AreEqual(source[0].ChangeTypes, payload[0].ChangeTypes);
@@ -30,13 +32,21 @@ public class RefresherTests
{
ContentCacheRefresher.JsonPayload[] source =
{
new ContentCacheRefresher.JsonPayload(1234, Guid.NewGuid(), TreeChangeTypes.None),
new ContentCacheRefresher.JsonPayload()
{
Id = 1234,
Key = Guid.NewGuid(),
ChangeTypes = TreeChangeTypes.None
}
};
var json = JsonConvert.SerializeObject(source);
var payload = JsonConvert.DeserializeObject<ContentCacheRefresher.JsonPayload[]>(json);
Assert.AreEqual(source[0].Id, payload[0].Id);
Assert.AreEqual(source[0].Key, payload[0].Key);
Assert.AreEqual(source[0].ChangeTypes, payload[0].ChangeTypes);
Assert.AreEqual(source[0].Blueprint, payload[0].Blueprint);
}
[Test]
@@ -46,8 +56,10 @@ public class RefresherTests
{
new ContentTypeCacheRefresher.JsonPayload("xxx", 1234, ContentTypeChangeTypes.None),
};
var json = JsonConvert.SerializeObject(source);
var payload = JsonConvert.DeserializeObject<ContentTypeCacheRefresher.JsonPayload[]>(json);
Assert.AreEqual(source[0].ItemType, payload[0].ItemType);
Assert.AreEqual(source[0].Id, payload[0].Id);
Assert.AreEqual(source[0].ChangeTypes, payload[0].ChangeTypes);
@@ -60,8 +72,10 @@ public class RefresherTests
{
new DataTypeCacheRefresher.JsonPayload(1234, Guid.NewGuid(), true),
};
var json = JsonConvert.SerializeObject(source);
var payload = JsonConvert.DeserializeObject<DataTypeCacheRefresher.JsonPayload[]>(json);
Assert.AreEqual(source[0].Id, payload[0].Id);
Assert.AreEqual(source[0].Key, payload[0].Key);
Assert.AreEqual(source[0].Removed, payload[0].Removed);
@@ -70,10 +84,14 @@ public class RefresherTests
[Test]
public void DomainCacheRefresherCanDeserializeJsonPayload()
{
DomainCacheRefresher.JsonPayload[]
source = { new DomainCacheRefresher.JsonPayload(1234, DomainChangeTypes.None) };
DomainCacheRefresher.JsonPayload[] source =
{
new DomainCacheRefresher.JsonPayload(1234, DomainChangeTypes.None)
};
var json = JsonConvert.SerializeObject(source);
var payload = JsonConvert.DeserializeObject<DomainCacheRefresher.JsonPayload[]>(json);
Assert.AreEqual(source[0].Id, payload[0].Id);
Assert.AreEqual(source[0].ChangeType, payload[0].ChangeType);
}

View File

@@ -358,7 +358,16 @@ public class PublishedSnapshotServiceCollectionTests : PublishedSnapshotServiceT
// notify
SnapshotService.Notify(
new[] { new ContentCacheRefresher.JsonPayload(10, Guid.Empty, TreeChangeTypes.RefreshBranch) }, out _, out _);
new[]
{
new ContentCacheRefresher.JsonPayload()
{
Id = 10,
ChangeTypes = TreeChangeTypes.RefreshBranch
}
},
out _,
out _);
// changes that *I* make are immediately visible on the current snapshot
var documents = snapshot.Content.GetAtRoot().ToArray();
@@ -392,7 +401,16 @@ public class PublishedSnapshotServiceCollectionTests : PublishedSnapshotServiceT
// notify
SnapshotService.Notify(
new[] { new ContentCacheRefresher.JsonPayload(1, Guid.Empty, TreeChangeTypes.RefreshBranch) }, out _, out _);
new[]
{
new ContentCacheRefresher.JsonPayload()
{
Id = 1,
ChangeTypes = TreeChangeTypes.RefreshBranch
}
},
out _,
out _);
// changes that *I* make are immediately visible on the current snapshot
var documents = snapshot.Content.GetAtRoot().ToArray();
@@ -450,7 +468,11 @@ public class PublishedSnapshotServiceCollectionTests : PublishedSnapshotServiceT
SnapshotService.Notify(
new[]
{
new ContentCacheRefresher.JsonPayload(kit.Node.ParentContentId, Guid.Empty, TreeChangeTypes.RefreshBranch),
new ContentCacheRefresher.JsonPayload()
{
Id = kit.Node.ParentContentId,
ChangeTypes = TreeChangeTypes.RefreshBranch
}
},
out _,
out _);
@@ -516,11 +538,19 @@ public class PublishedSnapshotServiceCollectionTests : PublishedSnapshotServiceT
// notify
SnapshotService.Notify(
new[]
{
// removal must come first
new ContentCacheRefresher.JsonPayload(2, Guid.Empty, TreeChangeTypes.RefreshBranch),
new ContentCacheRefresher.JsonPayload(1, Guid.Empty, TreeChangeTypes.RefreshBranch),
},
{
// removal must come first
new ContentCacheRefresher.JsonPayload()
{
Id = 2,
ChangeTypes = TreeChangeTypes.RefreshBranch
},
new ContentCacheRefresher.JsonPayload()
{
Id = 1,
ChangeTypes = TreeChangeTypes.RefreshBranch
}
},
out _,
out _);
@@ -571,7 +601,16 @@ public class PublishedSnapshotServiceCollectionTests : PublishedSnapshotServiceT
// notify - which ensures there are 2 generations in the cache meaning each LinkedNode has a Next value.
SnapshotService.Notify(
new[] { new ContentCacheRefresher.JsonPayload(4, Guid.Empty, TreeChangeTypes.RefreshBranch) }, out _, out _);
new[]
{
new ContentCacheRefresher.JsonPayload()
{
Id = 4,
ChangeTypes = TreeChangeTypes.RefreshBranch
}
},
out _,
out _);
// refresh the branch again, this used to show the issue where a null ref exception would occur
// because in the ClearBranchLocked logic, when SetValueLocked was called within a recursive call
@@ -579,7 +618,16 @@ public class PublishedSnapshotServiceCollectionTests : PublishedSnapshotServiceT
// this value before recursing.
Assert.DoesNotThrow(() =>
SnapshotService.Notify(
new[] { new ContentCacheRefresher.JsonPayload(4, Guid.Empty, TreeChangeTypes.RefreshBranch) }, out _, out _));
new[]
{
new ContentCacheRefresher.JsonPayload()
{
Id = 4,
ChangeTypes = TreeChangeTypes.RefreshBranch
}
},
out _,
out _));
}
[Test]
@@ -759,11 +807,23 @@ public class PublishedSnapshotServiceCollectionTests : PublishedSnapshotServiceT
// notify
SnapshotService.Notify(
new[]
{
new ContentCacheRefresher.JsonPayload(3, Guid.Empty, TreeChangeTypes.Remove), // remove last
new ContentCacheRefresher.JsonPayload(5, Guid.Empty, TreeChangeTypes.Remove), // remove middle
new ContentCacheRefresher.JsonPayload(9, Guid.Empty, TreeChangeTypes.Remove), // remove first
},
{
new ContentCacheRefresher.JsonPayload() // remove last
{
Id = 3,
ChangeTypes = TreeChangeTypes.Remove
},
new ContentCacheRefresher.JsonPayload() // remove middle
{
Id = 5,
ChangeTypes = TreeChangeTypes.Remove
},
new ContentCacheRefresher.JsonPayload() // remove first
{
Id = 9,
ChangeTypes = TreeChangeTypes.Remove
}
},
out _,
out _);
@@ -779,11 +839,23 @@ public class PublishedSnapshotServiceCollectionTests : PublishedSnapshotServiceT
// notify
SnapshotService.Notify(
new[]
{
new ContentCacheRefresher.JsonPayload(1, Guid.Empty, TreeChangeTypes.Remove), // remove first
new ContentCacheRefresher.JsonPayload(8, Guid.Empty, TreeChangeTypes.Remove), // remove
new ContentCacheRefresher.JsonPayload(7, Guid.Empty, TreeChangeTypes.Remove), // remove
},
{
new ContentCacheRefresher.JsonPayload() // remove first
{
Id = 1,
ChangeTypes = TreeChangeTypes.Remove
},
new ContentCacheRefresher.JsonPayload() // remove
{
Id = 8,
ChangeTypes = TreeChangeTypes.Remove
},
new ContentCacheRefresher.JsonPayload() // remove
{
Id = 7,
ChangeTypes = TreeChangeTypes.Remove
}
},
out _,
out _);
@@ -823,8 +895,16 @@ public class PublishedSnapshotServiceCollectionTests : PublishedSnapshotServiceT
SnapshotService.Notify(
new[]
{
new ContentCacheRefresher.JsonPayload(1, Guid.Empty, TreeChangeTypes.RefreshBranch),
new ContentCacheRefresher.JsonPayload(2, Guid.Empty, TreeChangeTypes.RefreshNode),
new ContentCacheRefresher.JsonPayload()
{
Id = 1,
ChangeTypes = TreeChangeTypes.RefreshBranch
},
new ContentCacheRefresher.JsonPayload()
{
Id = 2,
ChangeTypes = TreeChangeTypes.RefreshNode
}
},
out _,
out _);
@@ -887,7 +967,17 @@ public class PublishedSnapshotServiceCollectionTests : PublishedSnapshotServiceT
var parentNode = parentNodes[0];
AssertLinkedNode(parentNode.contentNode, -1, -1, -1, 2, 2);
SnapshotService.Notify(new[] { new ContentCacheRefresher.JsonPayload(2, Guid.Empty, TreeChangeTypes.Remove) }, out _, out _);
SnapshotService.Notify(
new[]
{
new ContentCacheRefresher.JsonPayload()
{
Id = 2,
ChangeTypes = TreeChangeTypes.Remove
}
},
out _,
out _);
parentNodes = contentStore.Test.GetValues(1);
parentNode = parentNodes[0];
@@ -944,9 +1034,13 @@ public class PublishedSnapshotServiceCollectionTests : PublishedSnapshotServiceT
SnapshotService.Notify(
new[]
{
new ContentCacheRefresher.JsonPayload(3, Guid.Empty, TreeChangeTypes.Remove), // remove middle child
},
{
new ContentCacheRefresher.JsonPayload() // remove middle child
{
Id = 3,
ChangeTypes = TreeChangeTypes.Remove
}
},
out _,
out _);
@@ -1013,7 +1107,16 @@ public class PublishedSnapshotServiceCollectionTests : PublishedSnapshotServiceT
Assert.IsFalse(contentStore.Test.NextGen);
SnapshotService.Notify(
new[] { new ContentCacheRefresher.JsonPayload(1, Guid.Empty, TreeChangeTypes.RefreshNode) }, out _, out _);
new[]
{
new ContentCacheRefresher.JsonPayload()
{
Id = 1,
ChangeTypes = TreeChangeTypes.RefreshNode
}
},
out _,
out _);
Assert.AreEqual(2, contentStore.Test.LiveGen);
Assert.IsTrue(contentStore.Test.NextGen);
@@ -1084,7 +1187,17 @@ public class PublishedSnapshotServiceCollectionTests : PublishedSnapshotServiceT
published ? rootKit.PublishedData : null);
NuCacheContentService.ContentKits[1] = kit;
SnapshotService.Notify(new[] { new ContentCacheRefresher.JsonPayload(1, Guid.Empty, changeType) }, out _, out _);
SnapshotService.Notify(
new[]
{
new ContentCacheRefresher.JsonPayload()
{
Id = 1,
ChangeTypes = changeType
}
},
out _,
out _);
Assert.AreEqual(assertGen, contentStore.Test.LiveGen);
Assert.IsTrue(contentStore.Test.NextGen);
@@ -1162,9 +1275,13 @@ public class PublishedSnapshotServiceCollectionTests : PublishedSnapshotServiceT
SnapshotService.Notify(
new[]
{
new ContentCacheRefresher.JsonPayload(3, Guid.Empty, TreeChangeTypes.RefreshBranch), // remove middle child
},
{
new ContentCacheRefresher.JsonPayload() // remove middle child
{
Id = 3,
ChangeTypes = TreeChangeTypes.RefreshBranch
}
},
out _,
out _);