#18505: Fields could not be imported in setup recipes

Work Item: 18505

--HG--
branch : 1.x
This commit is contained in:
Sebastien Ros 2012-03-01 12:06:16 -08:00
parent 4d5ef16ee0
commit a361ad263e
2 changed files with 29 additions and 9 deletions

View File

@ -91,6 +91,7 @@ namespace Orchard.Tests.Modules.Comments.Services {
}
_contentManager.Flush();
Assert.That(_commentService.GetComments().Count(), Is.EqualTo(12));
}
@ -180,11 +181,15 @@ namespace Orchard.Tests.Modules.Comments.Services {
commentIds[i] = commentedItem.As<CommentPart>().Id;
}
_contentManager.Flush();
Assert.That(_commentService.GetComments().Count(), Is.EqualTo(12));
for (int i = 0; i < 12; i++) {
_commentService.DeleteComment(commentIds[i]);
}
_contentManager.Flush();
Assert.That(_commentService.GetComments().Count(), Is.EqualTo(0));
}
}

View File

@ -439,15 +439,18 @@ namespace Orchard.ContentManagement {
}
public virtual void Create(ContentItem contentItem, VersionOptions options) {
// produce root record to determine the model id
contentItem.VersionRecord = new ContentItemVersionRecord {
ContentItemRecord = new ContentItemRecord {
ContentType = AcquireContentTypeRecord(contentItem.ContentType)
},
Number = 1,
Latest = true,
Published = true
};
if (contentItem.VersionRecord == null) {
// produce root record to determine the model id
contentItem.VersionRecord = new ContentItemVersionRecord {
ContentItemRecord = new ContentItemRecord {
ContentType = AcquireContentTypeRecord(contentItem.ContentType)
},
Number = 1,
Latest = true,
Published = true
};
}
// add to the collection manually for the created case
contentItem.VersionRecord.ContentItemRecord.Versions.Add(contentItem.VersionRecord);
@ -574,6 +577,18 @@ namespace Orchard.ContentManagement {
}
}
// create a version record if import handlers need it
if(item.VersionRecord == null) {
item.VersionRecord = new ContentItemVersionRecord {
ContentItemRecord = new ContentItemRecord {
ContentType = AcquireContentTypeRecord(item.ContentType)
},
Number = 1,
Latest = true,
Published = true
};
}
importContentSession.Store(identity, item);
var context = new ImportContentContext(item, element, importContentSession);