#18463: Fixing import calling Publish before exexuting import handlers

--HG--
branch : 1.x
This commit is contained in:
Sebastien Ros 2012-02-23 13:42:22 -08:00
parent d3326d575e
commit c80bc78feb
5 changed files with 38 additions and 11 deletions

View File

@ -1,4 +1,4 @@
31a28f2e874a590c327b4e8ad9078f872ca46007 src/Orchard.Web/Modules/Orchard.Autoroute
7311808eaa63f7e07bc1e3b686d17947c06400ea src/Orchard.Web/Modules/Orchard.Autoroute
c54cb640d6bc14c51b9fb9bd78231bb0facec067 src/Orchard.Web/Modules/Orchard.Forms
204bdef384f41bb5e463bed6b98a056945a7d839 src/Orchard.Web/Modules/Orchard.Rules
ce578373f907c0a55fd91229a344f0755f290174 src/Orchard.Web/Modules/Orchard.TaskLease

View File

@ -38,12 +38,6 @@ namespace Orchard.Recipes.RecipeHandlers {
var item = importContentSession.Get(identity);
if (item == null) {
item = _orchardServices.ContentManager.New(element.Name.LocalName);
if (status != null && status.Value == "Draft") {
_orchardServices.ContentManager.Create(item, VersionOptions.Draft);
}
else {
_orchardServices.ContentManager.Create(item);
}
}
else {
item = _orchardServices.ContentManager.Get(item.Id, VersionOptions.DraftRequired);

View File

@ -55,4 +55,23 @@
menuitem create /MenuPosition:"1" /MenuText:"Home" /Url:"" /OnMainMenu:true
theme activate "The Theme Machine"
</Command>
<Data>
<Page Id="/alias=about-us" Status="Published">
<CommonPart Owner="/User.UserName=admin" CreatedUtc="2012-02-14T19:22:13Z" PublishedUtc="2012-02-14T19:22:13Z" ModifiedUtc="2012-02-14T19:22:13Z" />
<BodyPart Text="&lt;p&gt;This is the about page.&lt;/p&gt;" />
<AutoroutePart UseCustomPattern="false" Alias="about-us" />
<MenuPart MenuText="About Us" MenuPosition="2" OnMainMenu="true" />
<TagsPart Tags="" />
<TitlePart Title="About Us" />
</Page>
<Page Status="Published" Id="/alias=contact-us">
<CommonPart ModifiedUtc="2012-02-22T19:20:20Z" PublishedUtc="2012-02-22T19:20:20Z" CreatedUtc="2012-02-22T19:20:20Z" Owner="/User.UserName=admin"/>
<BodyPart Text="&lt;p&gt;This is the Contact Us page.&lt;/p&gt;"/>
<AutoroutePart UseCustomPattern="false" Alias="contact-us"/>
<MenuPart OnMainMenu="true" MenuText="Contact Us" MenuPosition="3"/>
<TagsPart Tags=""/>
<TitlePart Title="Contact Us"/>
</Page>
</Data>
</Orchard>

View File

@ -572,19 +572,30 @@ namespace Orchard.ContentManagement {
Create(item);
}
}
else {
item = Get(item.Id, VersionOptions.DraftRequired);
}
importContentSession.Store(identity, item);
var context = new ImportContentContext(item, element, importContentSession);
foreach (var contentHandler in Handlers) {
contentHandler.Importing(context);
}
foreach (var contentHandler in Handlers) {
contentHandler.Imported(context);
}
var savedItem = Get(item.Id, VersionOptions.DraftRequired);
// the item has been pre-created in the first pass of the import, create it in db
if(savedItem == null) {
if (status != null && status.Value == "Draft") {
Create(item, VersionOptions.Draft);
}
else {
Create(item);
}
}
if (status == null || status.Value == Published) {
Publish(item);
}

View File

@ -70,7 +70,10 @@ namespace Orchard.ContentManagement {
_contentItemIds.Remove(item.Id);
}
_identities.Add(contentIdentity, item);
_contentItemIds.Add(item.Id, contentIdentity);
if (!_contentItemIds.ContainsKey(item.Id)) {
_contentItemIds.Add(item.Id, contentIdentity);
}
}
}