OrchardCMS / Orchard

Orchard is a free, open source, community-focused Content Management System built on the ASP.NET MVC platform.
https://orchardproject.net
BSD 3-Clause "New" or "Revised" License
2.38k stars 1.12k forks source link

Container sorting contained items by 'Title' throws exception when container is empty #2181

Open orchardbot opened 12 years ago

orchardbot commented 12 years ago

BitCrazed created: https://orchard.codeplex.com/workitem/18354

Repro steps: 1) Create new content type called "bucket". Make it a container 2) Create new content type called "fish". Make it containable 3) Create new "bucket" content item called "RedBucket". Configure it to contain "fish" and choose default sort order of "Title". 4) View http://.../RedBucket

Error reported: Could not resolve property: TitlePartRecord of: Orchard.ContentManagement.Records.ContentItemVersionRecord Exception Details: NHibernate.QueryException: could not resolve property: TitlePartRecord of: Orchard.ContentManagement.Records.ContentItemVersionRecord

See http://orchard.codeplex.com/discussions/285966 for exception dump.

orchardbot commented 12 years ago

@sebastienros commented:

As you are writing http://.../RedBucket, I assumed the repro forgot to mention to add a Routable to Bucket.

Though I was not able to reproduce using the latest version of the source code.

\ Closed by sebastienros 01/13/2012 4:22PM

orchardbot commented 12 years ago

BitCrazed commented:

Sorry for the delay - been busy getting first public Orchard site launched!

Okay, so we're seeing this error reported when trying to access specific content items, but not other items of the same content type! The content type is defined as:

The site is built from a (current) enlistment from the Orchard tree. I have a project branch which I've regularly merged from Default branch and is up to date. The project has all the usual modules and I have added the latest versions of the following additional modules: Contrib.Cache Mello.ImageGallery

Content Type Id: ProductBreakdownCategory Fields: (None) Parts: Common Body Containable Container Custom Properties Identity Publish Later Route Tags Admin Menu

Site is running in Azure, configured to talk to SqlAzure DB, using .NET Framework Version 4.0.30319; ASP.NET Version 4.0.30319.272.

The exception details & stacktrace are as follows:

Exception Details: NHibernate.QueryException: could not resolve property: TitlePartRecord of: Orchard.ContentManagement.Records.ContentItemVersionRecord

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[QueryException: could not resolve property: TitlePartRecord of: Orchard.ContentManagement.Records.ContentItemVersionRecord] NHibernate.Persister.Entity.AbstractPropertyMapping.ToType(String propertyName) +191 NHibernate.Loader.Criteria.CriteriaQueryTranslator.GetPathInfo(String path) +292 NHibernate.Loader.Criteria.CriteriaQueryTranslator.CreateCriteriaEntityNameMap() +269 NHibernate.Loader.Criteria.CriteriaQueryTranslator..ctor(ISessionFactoryImplementor factory, CriteriaImpl criteria, String rootEntityName, String rootSQLAlias) +481 NHibernate.Loader.Criteria.CriteriaLoader..ctor(IOuterJoinLoadable persister, ISessionFactoryImplementor factory, CriteriaImpl rootCriteria, String rootEntityName, IDictionary2 enabledFilters) +162 NHibernate.Impl.SessionImpl.List(CriteriaImpl criteria, IList results) +673 NHibernate.Impl.CriteriaImpl.List(IList results) +63 NHibernate.Impl.CriteriaImpl.UniqueResult() +65 Orchard.Core.Containers.Controllers.ItemController.Display(String path, PagerParameters pagerParameters) in c:\dev\Clients\MVP\Sites\mvp2\src\Orchard.Web\Core\Containers\Controllers\ItemController.cs:75 lambda_method(Closure , ControllerBase , Object[] ) +140 System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary2 parameters) +248 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary2 parameters) +39 System.Web.Mvc.<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12() +125 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func1 continuation) +640 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func1 continuation) +640 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func1 continuation) +640 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func1 continuation) +640 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +312 System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +691 System.Web.Mvc.Controller.ExecuteCore() +162 System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +305 System.Web.Mvc.<>cDisplayClassb.b5() +62 System.Web.Mvc.Async.<>cDisplayClass1.b0() +20 Orchard.Mvc.Routes.HttpAsyncHandler.EndProcessRequest(IAsyncResult result) in c:\dev\Clients\MVP\Sites\mvp2\src\Orchard\Mvc\Routes\ShellRoute.cs:148 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +469 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +375

orchardbot commented 12 years ago

BitCrazed commented:

Ah HAH! I think I've found the issue!

For some reason, the container that contains these content types allows the contained items to be sorted by Title ... even though the content item doesn't have a Title part!

Sorting by Routable Title (or any other field) prevents this error.

Why, then, is Title presented as a sortable property?

orchardbot commented 12 years ago

@bleroy commented:

Re-opening considering the new information.

orchardbot commented 12 years ago

@sebastienros commented:

Moving to later version as it is not critical. And it will be handled by Projector.

orchardbot commented 12 years ago

BitCrazed commented:

Erm ... excuse my ignorance here, but wouldn't an exception thrown by an aparrently valid end-user selected action be classed as a pretty substantial bug that should AT LEAST be fixed in the mainline branch?

It's not as if our users are doing anything cruel and unusual! ;)

orchardbot commented 12 years ago

@bleroy commented:

What do you mean? The bug is active.

orchardbot commented 12 years ago

BitCrazed commented:

I was replying to Sebastian's comment : "Moving to later version as it is not critical".

Does this mean you guys will be able to look into a fix for this in 1.3.x?

orchardbot commented 12 years ago

@bleroy commented:

Yes, we are less than two weeks away from shipping. The bar is extremely high. I'm afraid this doesn't meet it.