Enabling Custom Forms module results in error in log

Topics: Administration, Core
Oct 21, 2014 at 10:40 PM
When enabling the Orchard.CustomForms module we always see an error in the log that results from the data migration (creating the CustomFormPartRecord table) happening after the default role updater runs on the module. The DefaultRoleUpdater calls into the GetPermissions method in the CustomForms module, which in turn queries the table to see what custom forms exist. This results in the message below appearing in the orchard error log.

This is troublesome mainly because we "recook" frequently for testing. After testing we check the logs and our testers just have to know that this message isn't really a problem. I don't like that and would like to come up with a fix to prevent the error.

The simplest change that would resolve the error would be to change the DefaultRoleUpdater to respond to the Installed event instead of the installing event. Is this a bad idea? If so, any other suggestions how to fix this?

NHibernate.Exceptions.GenericADOException: could not execute query
[ select distinct customform0_.ContentType as col_0_0_ from Orchard_CustomForms_CustomFormPartRecord customform0_ ]
[SQL: select distinct customform0_.ContentType as col_0_0_ from Orchard_CustomForms_CustomFormPartRecord customform0_] ---> System.Data.SqlServerCe.SqlCeException: The specified table does not exist. [ Orchard_CustomForms_CustomFormPartRecord ]
at System.Data.SqlServerCe.SqlCeCommand.ProcessResults(Int32 hr)
at System.Data.SqlServerCe.SqlCeCommand.CompileQueryPlan()
at System.Data.SqlServerCe.SqlCeCommand.ExecuteCommand(CommandBehavior behavior, String method, ResultSetOptions options)
at System.Data.SqlServerCe.SqlCeCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.SqlServerCe.SqlCeCommand.ExecuteDbDataReader(CommandBehavior behavior)
at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader()
at NHibernate.AdoNet.AbstractBatcher.ExecuteReader(IDbCommand cmd) in c:\Users\sebros\Documents\My Projects\nhibernate-core\src\NHibernate\AdoNet\AbstractBatcher.cs:line 229
at NHibernate.Loader.Loader.GetResultSet(IDbCommand st, Boolean autoDiscoverTypes, Boolean callable, RowSelection selection, ISessionImplementor session) in c:\Users\sebros\Documents\My Projects\nhibernate-core\src\NHibernate\Loader\Loader.cs:line 1224
at NHibernate.Loader.Loader.DoQuery(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies) in c:\Users\sebros\Documents\My Projects\nhibernate-core\src\NHibernate\Loader\Loader.cs:line 421
at NHibernate.Loader.Loader.DoQueryAndInitializeNonLazyCollections(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies) in c:\Users\sebros\Documents\My Projects\nhibernate-core\src\NHibernate\Loader\Loader.cs:line 251
at NHibernate.Loader.Loader.DoList(ISessionImplementor session, QueryParameters queryParameters) in c:\Users\sebros\Documents\My Projects\nhibernate-core\src\NHibernate\Loader\Loader.cs:line 1564
--- End of inner exception stack trace ---
at NHibernate.Loader.Loader.DoList(ISessionImplementor session, QueryParameters queryParameters) in c:\Users\sebros\Documents\My Projects\nhibernate-core\src\NHibernate\Loader\Loader.cs:line 1573
at NHibernate.Loader.Loader.ListIgnoreQueryCache(ISessionImplementor session, QueryParameters queryParameters) in c:\Users\sebros\Documents\My Projects\nhibernate-core\src\NHibernate\Loader\Loader.cs:line 1472
at NHibernate.Loader.Loader.List(ISessionImplementor session, QueryParameters queryParameters, ISet1 querySpaces, IType[] resultTypes) in c:\Users\sebros\Documents\My Projects\nhibernate-core\src\NHibernate\Loader\Loader.cs:line 1467
at NHibernate.Hql.Ast.ANTLR.Loader.QueryLoader.List(ISessionImplementor session, QueryParameters queryParameters) in c:\Users\sebros\Documents\My Projects\nhibernate-core\src\NHibernate\Hql\Ast\ANTLR\Loader\QueryLoader.cs:line 288
at NHibernate.Hql.Ast.ANTLR.QueryTranslatorImpl.List(ISessionImplementor session, QueryParameters queryParameters) in c:\Users\sebros\Documents\My Projects\nhibernate-core\src\NHibernate\Hql\Ast\ANTLR\QueryTranslatorImpl.cs:line 112
at NHibernate.Engine.Query.HQLQueryPlan.PerformList(QueryParameters queryParameters, ISessionImplementor session, IList results) in c:\Users\sebros\Documents\My Projects\nhibernate-core\src\NHibernate\Engine\Query\HQLQueryPlan.cs:line 116
at NHibernate.Impl.SessionImpl.List(IQueryExpression queryExpression, QueryParameters queryParameters, IList results) in c:\Users\sebros\Documents\My Projects\nhibernate-core\src\NHibernate\Impl\SessionImpl.cs:line 659
at NHibernate.Impl.AbstractSessionImpl.List(IQueryExpression queryExpression, QueryParameters parameters) in c:\Users\sebros\Documents\My Projects\nhibernate-core\src\NHibernate\Impl\AbstractSessionImpl.cs:line 92
at NHibernate.Impl.ExpressionQueryImpl.List() in c:\Users\sebros\Documents\My Projects\nhibernate-core\src\NHibernate\Impl\ExpressionQueryImpl.cs:line 61
at NHibernate.Linq.DefaultQueryProvider.ExecuteQuery(NhLinqExpression nhLinqExpression, IQuery query, NhLinqExpression nhQuery) in c:\Users\sebros\Documents\My Projects\nhibernate-core\src\NHibernate\Linq\DefaultQueryProvider.cs:line 103
at NHibernate.Linq.DefaultQueryProvider.Execute(Expression expression) in c:\Users\sebros\Documents\My Projects\nhibernate-core\src\NHibernate\Linq\DefaultQueryProvider.cs:line 35
at NHibernate.Linq.DefaultQueryProvider.Execute[TResult](Expression expression) in c:\Users\sebros\Documents\My Projects\nhibernate-core\src\NHibernate\Linq\DefaultQueryProvider.cs:line 40
at Remotion.Linq.QueryableBase
1.GetEnumerator() in :line 0
at System.Collections.Generic.List1..ctor(IEnumerable1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable1 source)
at Orchard.CustomForms.Permissions.<GetPermissions>d__0.MoveNext()
at Orchard.Roles.Services.RoleService.GetPermissionDescription(String permissionName)
at Orchard.Roles.Services.RoleService.CreatePermissionForRole(String roleName, String permissionName)
at Orchard.Roles.DefaultRoleUpdater.AddDefaultRolesForFeature(Feature feature)
at Orchard.Roles.DefaultRoleUpdater.Orchard.Environment.IFeatureEventHandler.Installing(Feature feature)
at Orchard.Events.DelegateHelper.<>c__DisplayClass2b
2.<BuildAction>b__2a(Object target, Object[] p) in c:\Tf\Cider\Dev\orchard\src\Orchard\Events\DelegateHelper.cs:line 116
at Orchard.Events.DefaultOrchardEventBus.TryInvokeMethod(IEventHandler eventHandler, Type interfaceType, String messageName, String interfaceName, String methodName, IDictionary2 arguments, IEnumerable& returnValue) in c:\Tf\Cider\Dev\orchard\src\Orchard\Events\DefaultOrchardEventBus.cs:line 81
at Orchard.Events.DefaultOrchardEventBus.TryInvoke(IEventHandler eventHandler, String messageName, String interfaceName, String methodName, IDictionary
2 arguments, IEnumerable& returnValue) in c:\Tf\Cider\Dev\orchard\src\Orchard\Events\DefaultOrchardEventBus.cs:line 67
at Orchard.Events.DefaultOrchardEventBus.TryNotifyHandler(IEventHandler eventHandler, String messageName, String interfaceName, String methodName, IDictionary`2 eventData, IEnumerable& returnValue) in c:\Tf\Cider\Dev\orchard\src\Orchard\Events\DefaultOrchardEventBus.cs:line 53