From 5f95575141e37ef772639eab1e88539281da8c50 Mon Sep 17 00:00:00 2001 From: agrath Date: Thu, 26 Jul 2012 15:36:34 -1200 Subject: [PATCH 1/2] Fixed a NRE in FileHandlerData when user has not updated umbracoSettings.config to add the new /settings/content/imaging/autoFillImageProperties node --- .../businesslogic/datatype/FileHandlerData.cs | 41 ++++++++++--------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/src/umbraco.cms/businesslogic/datatype/FileHandlerData.cs b/src/umbraco.cms/businesslogic/datatype/FileHandlerData.cs index 5f2262cb6e..0b856bf733 100644 --- a/src/umbraco.cms/businesslogic/datatype/FileHandlerData.cs +++ b/src/umbraco.cms/businesslogic/datatype/FileHandlerData.cs @@ -83,28 +83,31 @@ namespace umbraco.cms.businesslogic.datatype // check for auto fill of other properties (width, height, extension and filesize) string propertyTypeAlias = new Property(PropertyId).PropertyType.Alias; - XmlNode uploadFieldConfigNode = - UmbracoSettings.ImageAutoFillImageProperties.SelectSingleNode( - string.Format("uploadField [@alias = \"{0}\"]", propertyTypeAlias)); - if (uploadFieldConfigNode != null) + if (UmbracoSettings.ImageAutoFillImageProperties != null) { - // get the current document - Content content = Content.GetContentFromVersion(Version); - // only add dimensions to web images - if (um.SupportsResizing) + XmlNode uploadFieldConfigNode = + UmbracoSettings.ImageAutoFillImageProperties.SelectSingleNode( + string.Format("uploadField [@alias = \"{0}\"]", propertyTypeAlias)); + if (uploadFieldConfigNode != null) { - updateContentProperty(uploadFieldConfigNode, content, "widthFieldAlias", - um.GetDimensions().Item1); - updateContentProperty(uploadFieldConfigNode, content, "heightFieldAlias", - um.GetDimensions().Item2); + // get the current document + Content content = Content.GetContentFromVersion(Version); + // only add dimensions to web images + if (um.SupportsResizing) + { + updateContentProperty(uploadFieldConfigNode, content, "widthFieldAlias", + um.GetDimensions().Item1); + updateContentProperty(uploadFieldConfigNode, content, "heightFieldAlias", + um.GetDimensions().Item2); + } + else + { + updateContentProperty(uploadFieldConfigNode, content, "widthFieldAlias", String.Empty); + updateContentProperty(uploadFieldConfigNode, content, "heightFieldAlias", String.Empty); + } + updateContentProperty(uploadFieldConfigNode, content, "lengthFieldAlias", um.Length); + updateContentProperty(uploadFieldConfigNode, content, "extensionFieldAlias", um.Extension); } - else - { - updateContentProperty(uploadFieldConfigNode, content, "widthFieldAlias", String.Empty); - updateContentProperty(uploadFieldConfigNode, content, "heightFieldAlias", String.Empty); - } - updateContentProperty(uploadFieldConfigNode, content, "lengthFieldAlias", um.Length); - updateContentProperty(uploadFieldConfigNode, content, "extensionFieldAlias", um.Extension); } base.Value = um.LocalName; From fffbd960c1dee6beed9ed2c81b2220650089219f Mon Sep 17 00:00:00 2001 From: agrath Date: Thu, 26 Jul 2012 16:05:44 -1200 Subject: [PATCH 2/2] Another NRE that I missed --- .../businesslogic/datatype/FileHandlerData.cs | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/umbraco.cms/businesslogic/datatype/FileHandlerData.cs b/src/umbraco.cms/businesslogic/datatype/FileHandlerData.cs index 0b856bf733..f34677c4dc 100644 --- a/src/umbraco.cms/businesslogic/datatype/FileHandlerData.cs +++ b/src/umbraco.cms/businesslogic/datatype/FileHandlerData.cs @@ -132,18 +132,21 @@ namespace umbraco.cms.businesslogic.datatype private void clearRelatedValues() { string propertyTypeAlias = new Property(PropertyId).PropertyType.Alias; - XmlNode uploadFieldConfigNode = - UmbracoSettings.ImageAutoFillImageProperties.SelectSingleNode( - string.Format("uploadField [@alias = \"{0}\"]", propertyTypeAlias)); - if (uploadFieldConfigNode != null) + if (UmbracoSettings.ImageAutoFillImageProperties != null) { - // get the current document - Content content = Content.GetContentFromVersion(Version); - // only add dimensions to web images - updateContentProperty(uploadFieldConfigNode, content, "widthFieldAlias", String.Empty); - updateContentProperty(uploadFieldConfigNode, content, "heightFieldAlias", String.Empty); - updateContentProperty(uploadFieldConfigNode, content, "lengthFieldAlias", String.Empty); - updateContentProperty(uploadFieldConfigNode, content, "extensionFieldAlias", String.Empty); + XmlNode uploadFieldConfigNode = + UmbracoSettings.ImageAutoFillImageProperties.SelectSingleNode( + string.Format("uploadField [@alias = \"{0}\"]", propertyTypeAlias)); + if (uploadFieldConfigNode != null) + { + // get the current document + Content content = Content.GetContentFromVersion(Version); + // only add dimensions to web images + updateContentProperty(uploadFieldConfigNode, content, "widthFieldAlias", String.Empty); + updateContentProperty(uploadFieldConfigNode, content, "heightFieldAlias", String.Empty); + updateContentProperty(uploadFieldConfigNode, content, "lengthFieldAlias", String.Empty); + updateContentProperty(uploadFieldConfigNode, content, "extensionFieldAlias", String.Empty); + } } }