mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-01-19 17:51:45 +08:00
This commit is contained in:
@@ -160,6 +160,9 @@ namespace Orchard.Indexing.Services {
|
|||||||
.OrderBy(versionRecord => versionRecord.Id)
|
.OrderBy(versionRecord => versionRecord.Id)
|
||||||
.Take(ContentItemsPerLoop)
|
.Take(ContentItemsPerLoop)
|
||||||
.ToList()
|
.ToList()
|
||||||
|
// In some rare cases a ContentItemRecord without a ContentType can end up in the DB.
|
||||||
|
// We need to filter out such records, otherwise they will crash the ContentManager.
|
||||||
|
.Where(x => x.ContentItemRecord != null && x.ContentItemRecord.ContentType != null)
|
||||||
.Select(versionRecord => _contentManager.Get(versionRecord.ContentItemRecord.Id, VersionOptions.VersionRecord(versionRecord.Id)))
|
.Select(versionRecord => _contentManager.Get(versionRecord.ContentItemRecord.Id, VersionOptions.VersionRecord(versionRecord.Id)))
|
||||||
.Distinct()
|
.Distinct()
|
||||||
.ToList();
|
.ToList();
|
||||||
@@ -220,6 +223,9 @@ namespace Orchard.Indexing.Services {
|
|||||||
.OrderBy(x => x.Id)
|
.OrderBy(x => x.Id)
|
||||||
.Take(ContentItemsPerLoop)
|
.Take(ContentItemsPerLoop)
|
||||||
.ToList()
|
.ToList()
|
||||||
|
// In some rare cases a ContentItemRecord without a ContentType can end up in the DB.
|
||||||
|
// We need to filter out such records, otherwise they will crash the ContentManager.
|
||||||
|
.Where(x => x.ContentItemRecord != null && x.ContentItemRecord.ContentType != null)
|
||||||
.GroupBy(x => x.ContentItemRecord.Id)
|
.GroupBy(x => x.ContentItemRecord.Id)
|
||||||
.Select(group => new { TaskId = group.Max(task => task.Id), Delete = group.Last().Action == IndexingTaskRecord.Delete, Id = group.Key, ContentItem = _contentManager.Get(group.Key, VersionOptions.Latest) })
|
.Select(group => new { TaskId = group.Max(task => task.Id), Delete = group.Last().Action == IndexingTaskRecord.Delete, Id = group.Key, ContentItem = _contentManager.Get(group.Key, VersionOptions.Latest) })
|
||||||
.OrderBy(x => x.TaskId)
|
.OrderBy(x => x.TaskId)
|
||||||
|
|||||||
Reference in New Issue
Block a user