#19541: Adding null check for Owner in CommonPartHandler OnIndexing

Work Item: 19541

--HG--
branch : 1.x
This commit is contained in:
Zoltán Lehóczky
2013-04-13 21:54:57 +02:00
parent 0cedb4f258
commit f7049cd811

View File

@@ -48,13 +48,15 @@ namespace Orchard.Core.Common.Handlers {
OnPublishing<CommonPart>(AssignPublishingDates);
OnIndexing<CommonPart>((context, commonPart) => context.DocumentIndex
.Add("type", commonPart.ContentItem.ContentType).Analyze().Store()
.Add("author", commonPart.Owner.UserName).Analyze().Store()
.Add("created", commonPart.CreatedUtc ?? _clock.UtcNow).Store()
.Add("published", commonPart.PublishedUtc ?? _clock.UtcNow).Store()
.Add("modified", commonPart.ModifiedUtc ?? _clock.UtcNow).Store()
);
OnIndexing<CommonPart>((context, commonPart) => {
context.DocumentIndex
.Add("type", commonPart.ContentItem.ContentType).Analyze().Store()
.Add("created", commonPart.CreatedUtc ?? _clock.UtcNow).Store()
.Add("published", commonPart.PublishedUtc ?? _clock.UtcNow).Store()
.Add("modified", commonPart.ModifiedUtc ?? _clock.UtcNow).Store();
if (commonPart.Owner != null) context.DocumentIndex.Add("author", commonPart.Owner.UserName).Analyze().Store();
});
}