Queries (<Query>) not imported from export.xml into new site

Topics: Customizing Orchard, Installing Orchard, Troubleshooting
Sep 19, 2012 at 12:51 PM

I've exported data and settings from an existing Orchard site. I followed other suggestions and named the xml file name.recipe.xml and placed it inside of the Orchard.Setup module under Recipes (so that it will show up in the Recipe dropdown list on the setup screen). I chose my recipe when starting a new Orchard site, and it seemed like everything worked perfectly except for the Queries. There are several <Query> tags in my exported xml which all seem to match the ones I had created, but none of them were imported when i cooked that recipe (i.e. - none show up under the "Queries" section of the Admin site). My projections are obviously broken because of this, and menu items don't show because the projections are broken.

I even tried importing the recipe again via the Import/Export module. Still nothing.

Any ideas?

Sep 19, 2012 at 1:18 PM

Turns out, none of my custom content types were ported over at all. It seems like the metadata was, but no content. When I look at the error logs I see a lot of this:

2012-09-19 08:07:50,082 [5] Orchard.ContentManagement.DefaultContentManager - NullReferenceException thrown from IContentHandler by Orchard.Core.Navigation.Handlers.ContentMenuItemPartHandlerSystem.NullReferenceException: Object reference not set to an instance of an object.   at Orchard.ContentManagement.DefaultContentManager.GetItemMetadata(IContent content) in f:\Mine\Orchard.Test.Recipes.1.5.1\src\Orchard\ContentManagement\DefaultContentManager.cs:line 500   at Orchard.Core.Navigation.Handlers.ContentMenuItemPartHandler.GetItemMetadata(GetContentItemMetadataContext context) in f:\Mine\Orchard.Test.Recipes.1.5.1\src\Orchard.Web\Core\Navigation\Handlers\ContentMenuItemPartHandler.cs:line 30   at Orchard.ContentManagement.Handlers.ContentHandler.Orchard.ContentManagement.Handlers.IContentHandler.GetContentItemMetadata(GetContentItemMetadataContext context) in f:\Mine\Orchard.Test.Recipes.1.5.1\src\Orchard\ContentManagement\Handlers\ContentHandler.cs:line 333   at Orchard.ContentManagement.DefaultContentManager.<>c__DisplayClass60.<GetItemMetadata>b__5f(IContentHandler handler) in f:\Mine\Orchard.Test.Recipes.1.5.1\src\Orchard\ContentManagement\DefaultContentManager.cs:line 505   at Orchard.InvokeExtensions.Invoke[TEvents](IEnumerable`1 events, Action`1 dispatch, ILogger logger) in f:\Mine\Orchard.Test.Recipes.1.5.1\src\Orchard\InvokeExtensions.cs:line 17


It's as if Orchard tries to import, but it can't find the underlying types or guids or keys needed to match everything up.


Sep 19, 2012 at 3:51 PM

That sounds likely, yes. Do you have all the necessary modules enables on the target site?

Sep 19, 2012 at 7:09 PM
Edited Sep 19, 2012 at 7:14 PM

Yeah, all of the modules were active. Here's what I ended up doing - it works.

  1. export data from old site (except menus, custom forms, queries, and projections)
  2. save export in Orchard.Setup as a recipe
  3. individually export queries, projections, menus/menu items, custom forms into separate xml documents
  4. copy over themes and modules to new orchard instance
  5. run site setup on new Orchard
  6. choose my custom Recipe
  7. ...site loads
  8. enable all applicable modules
  9. import one by one: queries, projections, menus, custom forms

This ran without errors. Some random settings here and there weren't ported over, but that may have been because the custom modules didn't support exporting. Overall, though, this step-by-step allowed parts to be created in orchard. It made sense a little, because a projection can't know which query it's tied to unless the query exists, etc, but the multiple steps can get confusing if you add more layers of complexity to your site.

Is there a better way to manage that?

Sep 19, 2012 at 9:49 PM

Yes, there is a bug open about recipes not being generated in the right order.

Sep 20, 2012 at 1:53 AM

Ah, ha! Ok, thanks Bertrand. One of these days I'll be comfortable enough to help fix some of these bugs =)