mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Fixing AutoFlush exception when creating content items
--HG-- branch : 1.x
This commit is contained in:
@@ -462,7 +462,7 @@ namespace Orchard.ContentManagement {
|
||||
// produce root record to determine the model id
|
||||
contentItem.VersionRecord = new ContentItemVersionRecord {
|
||||
ContentItemRecord = new ContentItemRecord {
|
||||
ContentType = AcquireContentTypeRecord(contentItem.ContentType)
|
||||
|
||||
},
|
||||
Number = 1,
|
||||
Latest = true,
|
||||
@@ -486,15 +486,19 @@ namespace Orchard.ContentManagement {
|
||||
_contentItemRepository.Create(contentItem.Record);
|
||||
_contentItemVersionRepository.Create(contentItem.VersionRecord);
|
||||
|
||||
|
||||
// build a context with the initialized instance to create
|
||||
var context = new CreateContentContext(contentItem);
|
||||
|
||||
|
||||
// invoke handlers to add information to persistent stores
|
||||
Handlers.Invoke(handler => handler.Creating(context), Logger);
|
||||
|
||||
// deferring the assignment of ContentType as loading a Record might force NHibernate to AutoFlush
|
||||
// the ContentPart, and needs the ContentItemRecord to be created before (created in previous statement)
|
||||
contentItem.VersionRecord.ContentItemRecord.ContentType = AcquireContentTypeRecord(contentItem.ContentType);
|
||||
|
||||
Handlers.Invoke(handler => handler.Created(context), Logger);
|
||||
|
||||
|
||||
if (options.IsPublished) {
|
||||
var publishContext = new PublishContentContext(contentItem, null);
|
||||
|
||||
|
Reference in New Issue
Block a user