OrchardCMS / Orchard

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

1.8x Invalidated features should also be applied on placement Info files and alternates #4455

Open orchardbot opened 10 years ago

orchardbot commented 10 years ago

@csurieux created: https://orchard.codeplex.com/workitem/20626

Actually it does not work.

My module uses a Part named OrderPart and a contentitem nammed Order, I am also using Nwazet.Commerce which also defines in its namespace a part named OrderPart and a similar content item, but this part is 'selectable' or not by a feature [OrchardFeature("Datwendo.Commerce")] which I don't use.

But Nwazet commerce contains a placement file with this design:

it also define an alternate named Content-Order.SummaryAdmin.cshtml in its View folder. and when from the Admin menu I select the 'Content' Menu' this last alternate is called when it is time to display my own Order contententItem, the alternate from Nwazet is called and crashes. I have no Nwazet Orders content items in my DB. Trace 2014-04-14 17:50:29,108 [45] Orchard.Exceptions.DefaultExceptionPolicy - Default - An unexpected exception was caught System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object. at ASP._Page_Modules_Nwazet_Commerce_Views_Content_Order_SummaryAdmin_cshtml.Execute() in e:\Datwendo\Datwendo18\src\Orchard.Web\Modules\Nwazet.Commerce\Views\Content-Order.SummaryAdmin.cshtml:line 23 at System.Web.WebPages.WebPageBase.ExecutePageHierarchy() at System.Web.Mvc.WebViewPage.ExecutePageHierarchy() at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) at System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance) at System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer) at System.Web.Mvc.HtmlHelper.RenderPartialInternal(String partialViewName, ViewDataDictionary viewData, Object model, TextWriter writer, ViewEngineCollection viewEngineCollection) at System.Web.Mvc.Html.PartialExtensions.Partial(HtmlHelper htmlHelper, String partialViewName, Object model, ViewDataDictionary viewData) at System.Web.Mvc.Html.PartialExtensions.Partial(HtmlHelper htmlHelper, String partialViewName, Object model) at Orchard.DisplayManagement.Descriptors.ShapeTemplateStrategy.ShapeTemplateBindingStrategy.Render(ShapeDescriptor shapeDescriptor, DisplayContext displayContext, HarvestShapeInfo harvestShapeInfo, HarvestShapeHit harvestShapeHit) in e:\Datwendo\Datwendo18\src\Orchard\DisplayManagement\Descriptors\ShapeTemplateStrategy\ShapeTemplateBindingStrategy.cs:line 151 at Orchard.DisplayManagement.Descriptors.ShapeTemplateStrategy.ShapeTemplateBindingStrategy.<>c__DisplayClass26.<>c__DisplayClass28.b__15(DisplayContext displayContext) in e:\Datwendo\Datwendo18\src\Orchard\DisplayManagement\Descriptors\ShapeTemplateStrategy\ShapeTemplateBindingStrategy.cs:line 133 at Orchard.DisplayManagement.Descriptors.ShapeAlterationBuilder.<>c__DisplayClass3.<>c__DisplayClass5.b__2(DisplayContext displayContext) in e:\Datwendo\Datwendo18\src\Orchard\DisplayManagement\Descriptors\ShapeAlterationBuilder.cs:line 56 at Orchard.DisplayManagement.Implementation.DefaultDisplayManager.Process(ShapeBinding shapeBinding, IShape shape, DisplayContext context) in e:\Datwendo\Datwendo18\src\Orchard\DisplayManagement\Implementation\DefaultDisplayManager.cs:line 185 at Orchard.DisplayManagement.Implementation.DefaultDisplayManager.Execute(DisplayContext context) in e:\Datwendo\Datwendo18\src\Orchard\DisplayManagement\Implementation\DefaultDisplayManager.cs:line 94 at Orchard.DisplayManagement.Implementation.DisplayHelper.ShapeExecute(Object shape) in e:\Datwendo\Datwendo18\src\Orchard\DisplayManagement\Implementation\DisplayHelper.cs:line 86 at Orchard.DisplayManagement.Implementation.DisplayHelper.Invoke(String name, INamedEnumerable1 parameters) in e:\Datwendo\Datwendo18\src\Orchard\DisplayManagement\Implementation\DisplayHelper.cs:line 44 at Orchard.DisplayManagement.Implementation.DisplayHelper.TryInvoke(InvokeBinder binder, Object[] args, Object& result) in e:\Datwendo\Datwendo18\src\Orchard\DisplayManagement\Implementation\DisplayHelper.cs:line 29 at CallSite.Target(Closure , CallSite , Object , Object ) at Orchard.Core.Shapes.CoreShapes.List(Object Display, TextWriter Output, IEnumerable1 Items, String Tag, String Id, IEnumerable1 Classes, IDictionary2 Attributes, String ItemTag, IEnumerable1 ItemClasses, IDictionary2 ItemAttributes) in e:\Datwendo\Datwendo18\src\Orchard.Web\Core\Shapes\CoreShapes.cs:line 687 --- End of inner exception stack trace --- at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) at Orchard.DisplayManagement.Descriptors.ShapeAttributeStrategy.ShapeAttributeBindingStrategy.PerformInvoke(DisplayContext displayContext, MethodInfo methodInfo, Object serviceInstance) in e:\Datwendo\Datwendo18\src\Orchard\DisplayManagement\Descriptors\ShapeAttributeStrategy\ShapeAttributeBindingStrategy.cs:line 64 at Orchard.DisplayManagement.Descriptors.ShapeAttributeStrategy.ShapeAttributeBindingStrategy.<>c__DisplayClass4.b__3(DisplayContext context) in e:\Datwendo\Datwendo18\src\Orchard\DisplayManagement\Descriptors\ShapeAttributeStrategy\ShapeAttributeBindingStrategy.cs:line 55 at Orchard.DisplayManagement.Descriptors.ShapeAlterationBuilder.<>c__DisplayClass3.<>c__DisplayClass5.b__2(DisplayContext displayContext) in e:\Datwendo\Datwendo18\src\Orchard\DisplayManagement\Descriptors\ShapeAlterationBuilder.cs:line 56 at Orchard.DisplayManagement.Implementation.DefaultDisplayManager.Process(ShapeBinding shapeBinding, IShape shape, DisplayContext context) in e:\Datwendo\Datwendo18\src\Orchard\DisplayManagement\Implementation\DefaultDisplayManager.cs:line 185 at Orchard.DisplayManagement.Implementation.DefaultDisplayManager.Execute(DisplayContext context) in e:\Datwendo\Datwendo18\src\Orchard\DisplayManagement\Implementation\DefaultDisplayManager.cs:line 94 at Orchard.DisplayManagement.Implementation.DisplayHelper.ShapeExecute(Object shape) in e:\Datwendo\Datwendo18\src\Orchard\DisplayManagement\Implementation\DisplayHelper.cs:line 86 at Orchard.DisplayManagement.Implementation.DisplayHelper.Invoke(String name, INamedEnumerable1 parameters) in e:\Datwendo\Datwendo18\src\Orchard\DisplayManagement\Implementation\DisplayHelper.cs:line 44 at Orchard.DisplayManagement.Implementation.DisplayHelper.TryInvoke(InvokeBinder binder, Object[] args, Object& result) in e:\Datwendo\Datwendo18\src\Orchard\DisplayManagement\Implementation\DisplayHelper.cs:line 29 at CallSite.Target(Closure , CallSite , Object , Object ) at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1) at ASP._Page_Core_Contents_Views_admin_List_cshtml.Execute() in e:\Datwendo\Datwendo18\src\Orchard.Web\Core\Contents\Views\Admin\List.cshtml:line 52 at System.Web.WebPages.WebPageBase.ExecutePageHierarchy() at System.Web.Mvc.WebViewPage.ExecutePageHierarchy() at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) at System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance) at System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer) at Orchard.Mvc.ViewEngines.ThemeAwareness.LayoutAwareViewEngine.<>c__DisplayClass7.b__5(ViewContext viewContext, TextWriter writer, IViewDataContainer viewDataContainer) in e:\Datwendo\Datwendo18\src\Orchard\Mvc\ViewEngines\ThemeAwareness\LayoutAwareViewEngine.cs:line 59 at Orchard.Mvc.ViewEngines.ThemeAwareness.LayoutAwareViewEngine.LayoutView.Render(ViewContext viewContext, TextWriter writer) in e:\Datwendo\Datwendo18\src\Orchard\Mvc\ViewEngines\ThemeAwareness\LayoutAwareViewEngine.cs:line 90 at System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) at System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext
orchardbot commented 10 years ago

@sebastienros commented:

Two solutions:

Also, if the default feature of a module is not enabled, the placement.info should not be parsed.

This last syntax has to be applied on the predicates when parsed so that enabling/disabling a module can be reflected dynamically. TODO: ensure checking if a feature is enabled doesn't cost too much CPU.