From 95b9a46b88d1afd56c1ec9b6cf17af7e78c40a78 Mon Sep 17 00:00:00 2001 From: Stephan Date: Mon, 26 May 2014 15:02:05 +0200 Subject: [PATCH 1/3] U4-4928 - issue with missing media content properties --- .../XmlPublishedCache/PublishedMediaCache.cs | 63 +++++++++---------- 1 file changed, 28 insertions(+), 35 deletions(-) diff --git a/src/Umbraco.Web/PublishedCache/XmlPublishedCache/PublishedMediaCache.cs b/src/Umbraco.Web/PublishedCache/XmlPublishedCache/PublishedMediaCache.cs index 06da0c807d..7488b097ac 100644 --- a/src/Umbraco.Web/PublishedCache/XmlPublishedCache/PublishedMediaCache.cs +++ b/src/Umbraco.Web/PublishedCache/XmlPublishedCache/PublishedMediaCache.cs @@ -464,6 +464,10 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache // I'm not sure that _properties contains all properties including those without a value, // neither that GetProperty will return a property without a value vs. null... @zpqrtbnk + // List of properties that will appear in the XML and do not match + // anything in the ContentType, so they must be ignored. + private static readonly string[] IgnoredKeys = { "version", "isDoc", "key" }; + public DictionaryPublishedContent( IDictionary valueDictionary, Func getParent, @@ -509,47 +513,36 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache _contentType = PublishedContentType.Get(PublishedItemType.Media, _documentTypeAlias); _properties = new Collection(); + //handle content type properties + //make sure we create them even if there's no value + foreach (var propertyType in _contentType.PropertyTypes) + { + var alias = propertyType.PropertyTypeAlias; + _keysAdded.Add(alias); + string value; + const bool isPreviewing = false; // false :: never preview a media + var property = valueDictionary.TryGetValue(alias, out value) == false + ? new XmlPublishedProperty(propertyType, isPreviewing) + : new XmlPublishedProperty(propertyType, isPreviewing, value); + _properties.Add(property); + } + //loop through remaining values that haven't been applied - foreach (var i in valueDictionary.Where(x => !_keysAdded.Contains(x.Key))) + foreach (var i in valueDictionary.Where(x => + _keysAdded.Contains(x.Key) == false // not already processed + && IgnoredKeys.Contains(x.Key) == false)) // not ignorable { - IPublishedContentProperty property; - - // must ignore that one - if (i.Key == "version" || i.Key == "isDoc") continue; - if (i.Key.InvariantStartsWith("__")) - { - // no type for tha tone, dunno how to convert - property = new PropertyResult(i.Key, i.Value, Guid.Empty, PropertyResultType.CustomProperty); - } + { + // no type for that one, dunno how to convert + IPublishedContentProperty property = new PropertyResult(i.Key, i.Value, Guid.Empty, PropertyResultType.CustomProperty); + _properties.Add(property); + } else { - // use property type to ensure proper conversion - var propertyType = _contentType.GetPropertyType(i.Key); - - // note: this is where U4-4144 and -3665 were born - // - // because propertyType is null, the XmlPublishedProperty ctor will throw - // it's null because i.Key is not a valid property alias for the type... - // the alias is case insensitive (verified) so it means it really is not - // a correct alias. - // - // in every cases this is after a ConvertFromXPathNavigator, so it means - // that we get some properties from the XML that are not valid properties. - // no idea which property. could come from the cache in library, could come - // from so many places really. - - // workaround: just ignore that property - if (propertyType == null) - { - LogHelper.Warn("Dropping property \"" + i.Key + "\" because it does not belong to the content type."); - continue; - } - - property = new XmlPublishedProperty(propertyType, false, i.Value); // false :: never preview a media + // this is a property that does not correspond to anything, ignore and log + LogHelper.Warn("Dropping property \"" + i.Key + "\" because it does not belong to the content type."); } - - _properties.Add(property); } } From d631039c0dcdfcf3e9f4fa71c7ef43dcd578ca83 Mon Sep 17 00:00:00 2001 From: Stephan Date: Mon, 26 May 2014 18:07:20 +0200 Subject: [PATCH 2/3] U4-4928 - issue with missing media content properties --- src/Umbraco.Web/Models/PublishedContentBase.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Umbraco.Web/Models/PublishedContentBase.cs b/src/Umbraco.Web/Models/PublishedContentBase.cs index e59c2981cb..9eab1a9dc6 100644 --- a/src/Umbraco.Web/Models/PublishedContentBase.cs +++ b/src/Umbraco.Web/Models/PublishedContentBase.cs @@ -47,7 +47,7 @@ namespace Umbraco.Web.Models var prop = GetProperty(Constants.Conventions.Media.File); if (prop == null) throw new NotSupportedException("Cannot resolve a Url for a media item when there is no 'umbracoFile' property defined."); - _url = prop.Value.ToString(); + _url = prop.Value == null ? "" : prop.Value.ToString(); break; default: throw new NotSupportedException(); From 13e8e972ebbf2f18199566327af605a3ec1f790b Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Tue, 27 May 2014 11:43:24 +0200 Subject: [PATCH 3/3] U4-4956 UserService.SavePassword method always throws a not supported exception --- src/Umbraco.Core/Services/UserService.cs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/Umbraco.Core/Services/UserService.cs b/src/Umbraco.Core/Services/UserService.cs index d2a58b6ad8..2874aa4aaa 100644 --- a/src/Umbraco.Core/Services/UserService.cs +++ b/src/Umbraco.Core/Services/UserService.cs @@ -205,10 +205,11 @@ namespace Umbraco.Core.Services if (user == null) throw new ArgumentNullException("user"); var provider = MembershipProviderExtensions.GetUsersMembershipProvider(); - if (provider.IsUmbracoMembershipProvider()) - { - provider.ChangePassword(user.Username, "", password); - } + + if (provider.IsUmbracoMembershipProvider() == false) + throw new NotSupportedException("When using a non-Umbraco membership provider you must change the user password by using the MembershipProvider.ChangePassword method"); + + provider.ChangePassword(user.Username, "", password); //go re-fetch the member and update the properties that may have changed var result = GetByUsername(user.Username); @@ -219,8 +220,6 @@ namespace Umbraco.Core.Services user.LastPasswordChangeDate = result.LastPasswordChangeDate; user.UpdateDate = user.UpdateDate; } - - throw new NotSupportedException("When using a non-Umbraco membership provider you must change the user password by using the MembershipProvider.ChangePassword method"); } ///