mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
Contribution by Piotr.
Fix workitem #17872: Null shape added to Zone causes NotImplementedException being thrown (return to change listing). Added handling of null shapes. If shape that gets passed to Add method is null - it is simply ignored. --HG-- branch : contributions
This commit is contained in:
@@ -19,6 +19,11 @@ namespace Orchard.DisplayManagement.Shapes {
|
||||
public virtual IEnumerable<dynamic> Items { get { return _items; } }
|
||||
|
||||
public virtual Shape Add(object item, string position = DefaultPosition) {
|
||||
// pszmyd: Ignoring null shapes
|
||||
if (item == null) {
|
||||
return this;
|
||||
}
|
||||
|
||||
try {
|
||||
// todo: (sebros) this is a temporary implementation to prevent common known scenarios throwing exceptions. The final solution would need to filter based on the fact that it is a Shape instance
|
||||
if ( item is MvcHtmlString ||
|
||||
|
||||
@@ -35,7 +35,8 @@ namespace Orchard.UI {
|
||||
public virtual string ZoneName { get; set; }
|
||||
|
||||
public IZone Add(Action<HtmlHelper> action, string position) {
|
||||
throw new NotImplementedException();
|
||||
// pszmyd: Replaced the NotImplementedException with simply doing nothing
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,6 +89,10 @@ namespace Orchard.UI.Zones {
|
||||
public override object InvokeMember(Func<object> proceed, object self, string name, INamedEnumerable<object> args) {
|
||||
var argsCount = args.Count();
|
||||
if (name == "Add" && (argsCount == 1 || argsCount == 2)) {
|
||||
// pszmyd: Ignore null shapes
|
||||
if (args.First() == null)
|
||||
return _parent;
|
||||
|
||||
dynamic parent = _parent;
|
||||
|
||||
dynamic zone = _zoneFactory();
|
||||
|
||||
Reference in New Issue
Block a user