From cce3cdc18b9c1a29ce7e16f5e18c2d695c1fd2d4 Mon Sep 17 00:00:00 2001 From: "agrath@gmail.com" Date: Wed, 29 Jun 2011 17:36:37 -1200 Subject: [PATCH] fixed some potential crashes in datatype lookups and a keyalreadyexists exception in datatype lookup --- .../RazorDynamicNode/DynamicNode.cs | 5 ++++- umbraco/cms/businesslogic/ContentType.cs | 11 ++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/umbraco.MacroEngines.Juno/RazorDynamicNode/DynamicNode.cs b/umbraco.MacroEngines.Juno/RazorDynamicNode/DynamicNode.cs index 7586bee95d..3588380e5b 100644 --- a/umbraco.MacroEngines.Juno/RazorDynamicNode/DynamicNode.cs +++ b/umbraco.MacroEngines.Juno/RazorDynamicNode/DynamicNode.cs @@ -396,7 +396,10 @@ namespace umbraco.MacroEngines //special casing for true/false properties //int/decimal are handled by ConvertPropertyValueByDataType //fallback is stringT - + if (n.NodeTypeAlias == null && data.Alias == null) + { + throw new ArgumentNullException("No node alias or property alias available. Unable to look up the datatype of the property you are trying to fetch."); + } Guid dataType = ContentType.GetDataType(n.NodeTypeAlias, data.Alias); if (RazorDataTypeModelTypes == null) diff --git a/umbraco/cms/businesslogic/ContentType.cs b/umbraco/cms/businesslogic/ContentType.cs index 68ab71aea9..26a661d033 100644 --- a/umbraco/cms/businesslogic/ContentType.cs +++ b/umbraco/cms/businesslogic/ContentType.cs @@ -193,12 +193,17 @@ namespace umbraco.cms.businesslogic } finally { - reader.Close(); + if (reader != null) + { + reader.Close(); + } } //add to cache - _propertyTypeCache.Add(key, controlId); - + if (!_propertyTypeCache.ContainsKey(key)) + { + _propertyTypeCache.Add(key, controlId); + } return controlId; }