Site upgrade to Orchard 1.4

New Orchard 1.4 brings new Autoroute feature, built-in Projector module, must have set of field types (finally) and the number of bug fixes.

It comes with breaking change by removing Route part, which means that you have to use special module to migrate your existing site content to version 1.4.

Content migration and Title module

After standard migration steps I enabled UpgradeTo14 module. It also enabled Autoroute and Alias features automatically and “Migrate to 1.4” option appeared in navigation menu.

Enabling UpgradeTo14 module

First attempt to migrate data failed with generic error message:

Some content items could not be imported. Please refer to the corresponding Report.

In the Reports section I found another curt error:

Information     Adding parts to Blog     2012-05-01 15:21
Error     Migrating content item 35 failed with: Object reference not set to an instance of an object.     2012-05-01 15:21

Other strange symptoms were missing Blog section in navigation menu and generic names of the pages, something like “Page”.

Finally in log files I found this:

2012-05-01 15:30:29,253 [7] Orchard.UI.Navigation.NavigationManager - Unexpected error while querying a navigation provider. It was ignored. The menu provided by the provider may not be complete.
NHibernate.QueryException: could not resolve property: TitlePartRecord of: Orchard.ContentManagement.Records.ContentItemVersionRecord
   at NHibernate.Persister.Entity.AbstractPropertyMapping.ToType(String propertyName)
   at NHibernate.Loader.Criteria.CriteriaQueryTranslator.GetPathInfo(String path)
   at NHibernate.Loader.Criteria.CriteriaQueryTranslator.CreateCriteriaEntityNameMap()
   at NHibernate.Loader.Criteria.CriteriaQueryTranslator..ctor(ISessionFactoryImplementor factory, CriteriaImpl criteria, String rootEntityName, String rootSQLAlias)
   at NHibernate.Loader.Criteria.CriteriaLoader..ctor(IOuterJoinLoadable persister, ISessionFactoryImplementor factory, CriteriaImpl rootCriteria, String rootEntityName, IDictionary`2 enabledFilters)
   at NHibernate.Impl.SessionImpl.List(CriteriaImpl criteria, IList results)
   at NHibernate.Impl.CriteriaImpl.List(IList results)
   at NHibernate.Impl.CriteriaImpl.List[T]()
   at Orchard.ContentManagement.DefaultContentQuery.ContentQuery`1.Orchard.ContentManagement.IContentQuery.List() in c:\Users\sebros\My Projects\Orchard\src\Orchard\ContentManagement\DefaultContentQuery.cs:line 191 at Orchard.Blogs.Services.BlogService.Get(VersionOptions versionOptions) at Orchard.Blogs.AdminMenu.BuildMenu(NavigationItemBuilder menu) at Orchard.UI.Navigation.NavigationBuilder.Add(LocalizedString caption, String position, Action`1 itemBuilder, IEnumerable`1 classes) in c:\Users\sebros\My Projects\Orchard\src\Orchard\UI\Navigation\NavigationBuilder.cs:line 17 at Orchard.Blogs.AdminMenu.GetNavigation(NavigationBuilder builder) at Orchard.UI.Navigation.NavigationManager.d__14.MoveNext() in c:\Users\sebros\My Projects\Orchard\src\Orchard\UI\Navigation\NavigationManager.cs:line 115 

It turned out that Title feature was disabled on my site:

Title module is disabled

That’s why site content didn’t get correct titles during data migration and Blog section could not be displayed in the menu. So Title feature was enabled and second migration attempt was a great success. After upgrading all required modules my site was up and running.

To avoid this problem UpgradeTo14 module should have Title module in its dependency list. In that case Title feature would be enabled automatically. This was fixed in Orchard 1.4.1.

Route part dependencies

Since Route was removed, you have to check if your site modules and themes depend on Route part.

In my case it was trivial. I noticed that blog post titles rendering had changed. Using Shape Tracing I found that titles are rendered from Parts_Title_Summary shape by Title module template.

Tracing Parts_Title_Summary rendering

With Orchard 1.3 I had overridden title rendering in Parts.RoutableTitle.Summary template in my theme. Original template was implemented in Route module I believe.

Now I had to override title rendering in Parts.Title.Summary template.

Titles rendering templates

Security exceptions when accessing the upgraded site

I got the 404 “The resource cannot be found.” error page when accessing the site after upgrade from version 1.4 to 1.4.1.

Log file contained the bunch of errors like this:

2012-05-14 17:36:39,477 [7] Orchard.Environment.Extensions.ExtensionManager - Error loading extension 'Orchard.Messaging'
System.TypeLoadException: Inheritance security rules violated by type: 'Orchard.Messaging.Drivers.MessageSettingsPartDriver'. Derived types must either match the security accessibility of the base type or be less accessible.
   at System.Reflection.RuntimeAssembly.GetExportedTypes(RuntimeAssembly assembly, ObjectHandleOnStack retTypes)
   at System.Reflection.RuntimeAssembly.GetExportedTypes()
   at Orchard.Environment.Extensions.Loaders.DynamicExtensionLoader.LoadWorker(ExtensionDescriptor descriptor) in d:\Builds\OrchardFull\src\Orchard\Environment\Extensions\Loaders\DynamicExtensionLoader.cs:line 198
   at Orchard.Environment.Extensions.ExtensionManager.BuildEntry(ExtensionDescriptor descriptor) in d:\Builds\OrchardFull\src\Orchard\Environment\Extensions\ExtensionManager.cs:line 161
   at Orchard.Environment.Extensions.ExtensionManager.<>c__DisplayClass1c.b__16(AcquireContext`1 ctx) in d:\Builds\OrchardFull\src\Orchard\Environment\Extensions\ExtensionManager.cs:line 110 at Orchard.Caching.Cache`2.CreateEntry(TKey k, Func`2 acquire) in d:\Builds\OrchardFull\src\Orchard\Caching\Cache.cs:line 57 at Orchard.Caching.Cache`2.AddEntry(TKey k, Func`2 acquire) in d:\Builds\OrchardFull\src\Orchard\Caching\Cache.cs:line 27 at System.Collections.Concurrent.ConcurrentDictionary`2.AddOrUpdate(TKey key, Func`2 addValueFactory, Func`3 updateValueFactory) at Orchard.Caching.Cache`2.Get(TKey key, Func`2 acquire) in d:\Builds\OrchardFull\src\Orchard\Caching\Cache.cs:line 17 at Orchard.Environment.Extensions.ExtensionManager.LoadFeature(FeatureDescriptor featureDescriptor) in d:\Builds\OrchardFull\src\Orchard\Environment\Extensions\ExtensionManager.cs:line 109 

The cause and the solution for the issue are briefly described by Piotr Szmyd.

Replacing the [assembly: SecurityTransparent] by the [assembly: SecurityRules(SecurityRuleSet.Level2)] in the AssemblyInfo.cs files in module folders has solved this problem.

Dude, where are my comments?

That was another strange thing happened after upgrade from version 1.4 to 1.4.1: comments disappeared from blog post pages and in admin menu. Everything looked fine locally, but as soon as the site was upgraded on hosting, the comments magically vanished without a trace.

It turned out that this is related to mentioned security rules and the solution was simple: [assembly:SecurityRules(SecurityRuleSet.Level2)] declaration should be removed in in the AssemblyInfo.cs file of Orchard.Comments module. This issue was fixed in Orchard 1.4.2.

Bug fixes

It’s great to see the number of bugs fixed in Core and modules.

For instance, now my homepage renders own meta keywords and description instead of taking it from one of the latest blog post.

Or another example: in Orchard 1.3 blog post date in the RSS feed used to be the date of last modification of that blog post. It means that if you edited some old blog post it would appear in the top of RSS feed as new one. Now the date displayed in the feed is the date of the first blog post publication, it is the same as date on site page.

My new stuff

After upgrade to version 1.4 I decided to add couple of nice features to the site.

Now I use SyntaxHighlighter by Alex Gorbatchev.

Comments rendering was slightly updated. Now it displays Gravatar images using sender email. I hope it will improve our interaction.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.