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

View File

@@ -439,6 +439,7 @@ namespace Orchard.ContentManagement {
} }
public virtual void Create(ContentItem contentItem, VersionOptions options) { public virtual void Create(ContentItem contentItem, VersionOptions options) {
if (contentItem.VersionRecord == null) {
// produce root record to determine the model id // produce root record to determine the model id
contentItem.VersionRecord = new ContentItemVersionRecord { contentItem.VersionRecord = new ContentItemVersionRecord {
ContentItemRecord = new ContentItemRecord { ContentItemRecord = new ContentItemRecord {
@@ -448,6 +449,8 @@ namespace Orchard.ContentManagement {
Latest = true, Latest = true,
Published = true Published = true
}; };
}
// add to the collection manually for the created case // add to the collection manually for the created case
contentItem.VersionRecord.ContentItemRecord.Versions.Add(contentItem.VersionRecord); 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); importContentSession.Store(identity, item);
var context = new ImportContentContext(item, element, importContentSession); var context = new ImportContentContext(item, element, importContentSession);