Workaround for failing entity tree children (#15887)
* Workaround for failing entity tree children * Fix typo from original PR * Expose and actually use GetPagedTrashedChildren on EntityService (the default implementation on the interface is currently used). * Ensure that ID/Key mapping for recycle bins work
This commit is contained in:
@@ -359,8 +359,27 @@ public class EntityService : RepositoryService, IEntityService
|
||||
=> GetPagedChildren(id, objectType, pageIndex, pageSize, false, filter, ordering, out totalRecords);
|
||||
|
||||
public IEnumerable<IEntitySlim> GetPagedChildren(
|
||||
Guid? key,
|
||||
UmbracoObjectTypes objectType,
|
||||
Guid? parentKey,
|
||||
UmbracoObjectTypes childObjectType,
|
||||
int skip,
|
||||
int take,
|
||||
out long totalRecords,
|
||||
IQuery<IUmbracoEntity>? filter = null,
|
||||
Ordering? ordering = null)
|
||||
=> GetPagedChildren(
|
||||
parentKey,
|
||||
new[] { childObjectType },
|
||||
childObjectType,
|
||||
skip,
|
||||
take,
|
||||
out totalRecords,
|
||||
filter,
|
||||
ordering);
|
||||
|
||||
public IEnumerable<IEntitySlim> GetPagedChildren(
|
||||
Guid? parentKey,
|
||||
IEnumerable<UmbracoObjectTypes> parentObjectTypes,
|
||||
UmbracoObjectTypes childObjectType,
|
||||
int skip,
|
||||
int take,
|
||||
out long totalRecords,
|
||||
@@ -369,7 +388,9 @@ public class EntityService : RepositoryService, IEntityService
|
||||
{
|
||||
using ICoreScope scope = ScopeProvider.CreateCoreScope();
|
||||
|
||||
if (ResolveKey(key, objectType, out int parentId) is false)
|
||||
var parentId = 0;
|
||||
var parentIdResolved = parentObjectTypes.Any(parentObjectType => ResolveKey(parentKey, parentObjectType, out parentId));
|
||||
if (parentIdResolved is false)
|
||||
{
|
||||
totalRecords = 0;
|
||||
return Enumerable.Empty<IEntitySlim>();
|
||||
@@ -379,7 +400,7 @@ public class EntityService : RepositoryService, IEntityService
|
||||
|
||||
IEnumerable<IEntitySlim> children = GetPagedChildren(
|
||||
parentId,
|
||||
objectType,
|
||||
childObjectType,
|
||||
pageNumber,
|
||||
pageSize,
|
||||
out totalRecords,
|
||||
@@ -401,7 +422,7 @@ public class EntityService : RepositoryService, IEntityService
|
||||
Ordering? ordering = null)
|
||||
=> GetPagedChildren(id, objectType, pageIndex, pageSize, true, filter, ordering, out totalRecords);
|
||||
|
||||
IEnumerable<IEntitySlim> GetPagedTrashedChildren(
|
||||
public IEnumerable<IEntitySlim> GetPagedTrashedChildren(
|
||||
Guid? key,
|
||||
UmbracoObjectTypes objectType,
|
||||
int skip,
|
||||
|
||||
@@ -202,8 +202,27 @@ public interface IEntityService
|
||||
IEnumerable<IEntitySlim> GetDescendants(int id, UmbracoObjectTypes objectType);
|
||||
|
||||
IEnumerable<IEntitySlim> GetPagedChildren(
|
||||
Guid? key,
|
||||
UmbracoObjectTypes objectType,
|
||||
Guid? parentKey,
|
||||
UmbracoObjectTypes childObjectType,
|
||||
int skip,
|
||||
int take,
|
||||
out long totalRecords,
|
||||
IQuery<IUmbracoEntity>? filter = null,
|
||||
Ordering? ordering = null)
|
||||
=> GetPagedChildren(
|
||||
parentKey,
|
||||
new[] { childObjectType },
|
||||
childObjectType,
|
||||
skip,
|
||||
take,
|
||||
out totalRecords,
|
||||
filter,
|
||||
ordering);
|
||||
|
||||
IEnumerable<IEntitySlim> GetPagedChildren(
|
||||
Guid? parentKey,
|
||||
IEnumerable<UmbracoObjectTypes> parentObjectTypes,
|
||||
UmbracoObjectTypes childObjectType,
|
||||
int skip,
|
||||
int take,
|
||||
out long totalRecords,
|
||||
|
||||
@@ -115,6 +115,16 @@ public class IdKeyMap : IIdKeyMap, IDisposable
|
||||
|
||||
public Attempt<int> GetIdForKey(Guid key, UmbracoObjectTypes umbracoObjectType)
|
||||
{
|
||||
if (key == Constants.System.RecycleBinContentKey && umbracoObjectType == UmbracoObjectTypes.Document)
|
||||
{
|
||||
return Attempt.Succeed(Constants.System.RecycleBinContent);
|
||||
}
|
||||
|
||||
if (key == Constants.System.RecycleBinMediaKey && umbracoObjectType == UmbracoObjectTypes.Media)
|
||||
{
|
||||
return Attempt.Succeed(Constants.System.RecycleBinMedia);
|
||||
}
|
||||
|
||||
bool empty;
|
||||
|
||||
try
|
||||
@@ -232,6 +242,16 @@ public class IdKeyMap : IIdKeyMap, IDisposable
|
||||
|
||||
public Attempt<Guid> GetKeyForId(int id, UmbracoObjectTypes umbracoObjectType)
|
||||
{
|
||||
if (id == Constants.System.RecycleBinContent && umbracoObjectType == UmbracoObjectTypes.Document)
|
||||
{
|
||||
return Attempt.Succeed(Constants.System.RecycleBinContentKey);
|
||||
}
|
||||
|
||||
if (id == Constants.System.RecycleBinMedia && umbracoObjectType == UmbracoObjectTypes.Media)
|
||||
{
|
||||
return Attempt.Succeed(Constants.System.RecycleBinMediaKey);
|
||||
}
|
||||
|
||||
bool empty;
|
||||
|
||||
try
|
||||
|
||||
Reference in New Issue
Block a user