Handling null version records in audit trail content provider.

VersionRecord is null in cases where a content item was created in the same request. E.g. creating a comment on the front end.
This commit is contained in:
Sipke Schoorstra
2014-10-27 01:19:15 -07:00
parent 005ec51115
commit d18bbedc42

View File

@@ -27,7 +27,7 @@ namespace Orchard.AuditTrail.Providers.Content {
protected override void Created(CreateContentContext context) {
// At this point the UpdateEditor hasn't been invoked on the content item yet,
// so we don't have access to all of the information we might need (such as Title).
// We set a flag against we check in the Updated method (which is invoked when UpdateEditor is invoked).
// We set a flag which we will check in the Updated method (which is invoked when UpdateEditor is invoked).
_contentItemCreated = true;
}
@@ -93,9 +93,9 @@ namespace Orchard.AuditTrail.Providers.Content {
{"ContentId", content.Id},
{"ContentIdentity", metaData.Identity.ToString()},
{"ContentType", content.ContentItem.ContentType},
{"VersionId", content.ContentItem.VersionRecord.Id},
{"VersionNumber", content.ContentItem.VersionRecord.Number},
{"Published", content.ContentItem.VersionRecord.Published},
{"VersionId", content.ContentItem.Version},
{"VersionNumber", content.ContentItem.VersionRecord != null ? content.ContentItem.VersionRecord.Number : 0},
{"Published", content.ContentItem.VersionRecord != null && content.ContentItem.VersionRecord.Published},
{"Title", metaData.DisplayText}
};