From a67b3cfa00d31ebce3c9fc8d702a83b545bccf9a Mon Sep 17 00:00:00 2001 From: ElenaRepository <50620495+ElenaRepository@users.noreply.github.com> Date: Thu, 5 Dec 2019 21:04:56 +0100 Subject: [PATCH] Fix bug field index part handler (#8294) --- .../Orchard.Projections/Handlers/FieldIndexPartHandler.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Orchard.Web/Modules/Orchard.Projections/Handlers/FieldIndexPartHandler.cs b/src/Orchard.Web/Modules/Orchard.Projections/Handlers/FieldIndexPartHandler.cs index faa2ca07c..e5100c7f3 100644 --- a/src/Orchard.Web/Modules/Orchard.Projections/Handlers/FieldIndexPartHandler.cs +++ b/src/Orchard.Web/Modules/Orchard.Projections/Handlers/FieldIndexPartHandler.cs @@ -48,7 +48,10 @@ namespace Orchard.Projections.Handlers { } } private void Updated(UpdateContentContext context, FieldIndexPart fieldIndexPart) { - if (context.UpdatingItemVersionRecord.Latest) { // updates projection draft indexes only if it is the latest version + // there are two different item types: saved in memory and saved to db + // those saved in memory don't have correctly the populated record and this generate NullReferenceException + if (context.UpdatingItemVersionRecord != null && context.UpdatingItemVersionRecord.Latest) { + // updates projection draft indexes only if it is the latest version DescribeValuesToindex(fieldIndexPart, (indexServiceContext) => { _draftFieldIndexService.Set(fieldIndexPart, indexServiceContext.LocalPart.PartDefinition.Name, @@ -113,4 +116,4 @@ namespace Orchard.Projections.Handlers { } } -} \ No newline at end of file +}