mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 03:25:23 +08:00
#19003: Fixing import/export when alias already exists on a different content type
Work Item: 19003 --HG-- branch : 1.x
This commit is contained in:
@@ -580,7 +580,7 @@ namespace Orchard.ContentManagement {
|
||||
var identity = elementId.Value;
|
||||
var status = element.Attribute("Status");
|
||||
|
||||
var item = importContentSession.Get(identity);
|
||||
var item = importContentSession.Get(identity, XmlConvert.DecodeName(element.Name.LocalName));
|
||||
if (item == null) {
|
||||
item = New(XmlConvert.DecodeName(element.Name.LocalName));
|
||||
if (status != null && status.Value == "Draft") {
|
||||
|
@@ -24,12 +24,20 @@ namespace Orchard.ContentManagement {
|
||||
_contentTypes[contentIdentity] = contentType;
|
||||
}
|
||||
|
||||
public ContentItem Get(string id) {
|
||||
public ContentItem Get(string id, string contentTypeHint = null) {
|
||||
var contentIdentity = new ContentIdentity(id);
|
||||
|
||||
// lookup in local cache
|
||||
if (_identities.ContainsKey(contentIdentity))
|
||||
return _contentManager.Get(_identities[contentIdentity], VersionOptions.DraftRequired);
|
||||
if (_identities.ContainsKey(contentIdentity)) {
|
||||
var result = _contentManager.Get(_identities[contentIdentity], VersionOptions.DraftRequired);
|
||||
|
||||
// if two identities are conflicting, then ensure that there types are the same
|
||||
// e.g., importing a blog as home page (alias=) and the current home page is a page, the blog
|
||||
// won't be imported, and blog posts will be attached to the page
|
||||
if (contentTypeHint == null || result.ContentType == contentTypeHint) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
// no result ? then check if there are some more content items to load from the db
|
||||
if(_lastIndex != int.MaxValue) {
|
||||
@@ -79,8 +87,8 @@ namespace Orchard.ContentManagement {
|
||||
}
|
||||
|
||||
var contentItem = _contentManager.Create(_contentTypes[contentIdentity], VersionOptions.Draft);
|
||||
_identities.Add(contentIdentity, contentItem.Id);
|
||||
_contentItemIds.Add(contentItem.Id, contentIdentity);
|
||||
_identities[contentIdentity] = contentItem.Id;
|
||||
_contentItemIds[contentItem.Id] = contentIdentity;
|
||||
|
||||
return contentItem;
|
||||
}
|
||||
|
Reference in New Issue
Block a user