diff --git a/src/Umbraco.Core/Models/UserExtensions.cs b/src/Umbraco.Core/Models/UserExtensions.cs index fe90ec8bfb..e7035caf10 100644 --- a/src/Umbraco.Core/Models/UserExtensions.cs +++ b/src/Umbraco.Core/Models/UserExtensions.cs @@ -227,7 +227,7 @@ namespace Umbraco.Core.Models internal static bool IsInBranchOfStartNode(string path, int[] startNodeIds, string[] startNodePaths, out bool hasPathAccess) { - if (string.IsNullOrWhiteSpace(path)) throw new ArgumentException("Value cannot be null or whitespace.", "path"); + if (string.IsNullOrWhiteSpace(path)) throw new ArgumentException("Value cannot be null or whitespace.", nameof(path)); hasPathAccess = false; @@ -254,7 +254,7 @@ namespace Umbraco.Core.Models var ancestor = startNodePaths.Any(x => x.StartsWith(path)); if (ancestor) { - hasPathAccess = false; + //hasPathAccess = false; return true; } @@ -328,13 +328,11 @@ namespace Umbraco.Core.Models private static T FromUserCache(IUser user, string cacheKey) where T: class { - var entityUser = user as User; - if (entityUser == null) return null; + if (!(user is User entityUser)) return null; lock (entityUser.AdditionalDataLock) { - object allContentStartNodes; - return entityUser.AdditionalData.TryGetValue(cacheKey, out allContentStartNodes) + return entityUser.AdditionalData.TryGetValue(cacheKey, out var allContentStartNodes) ? allContentStartNodes as T : null; } @@ -343,8 +341,7 @@ namespace Umbraco.Core.Models private static void ToUserCache(IUser user, string cacheKey, T vals) where T: class { - var entityUser = user as User; - if (entityUser == null) return; + if (!(user is User entityUser)) return; lock (entityUser.AdditionalDataLock) { @@ -369,7 +366,7 @@ namespace Umbraco.Core.Models binPath += Constants.System.RecycleBinMedia; break; default: - throw new ArgumentOutOfRangeException("objectType"); + throw new ArgumentOutOfRangeException(nameof(objectType)); } return binPath; } @@ -379,7 +376,9 @@ namespace Umbraco.Core.Models // assume groupSn and userSn each don't contain duplicates var asn = groupSn.Concat(userSn).Distinct().ToArray(); - var paths = entityService.GetAllPaths(objectType, asn).ToDictionary(x => x.Id, x => x.Path); + var paths = asn.Length > 0 + ? entityService.GetAllPaths(objectType, asn).ToDictionary(x => x.Id, x => x.Path) + : new Dictionary(); paths[Constants.System.Root] = Constants.System.Root.ToString(); // entityService does not get that one @@ -388,8 +387,7 @@ namespace Umbraco.Core.Models var lsn = new List(); foreach (var sn in groupSn) { - string snp; - if (paths.TryGetValue(sn, out snp) == false) continue; // ignore rogue node (no path) + if (paths.TryGetValue(sn, out var snp) == false) continue; // ignore rogue node (no path) if (StartsWithPath(snp, binPath)) continue; // ignore bin @@ -401,8 +399,7 @@ namespace Umbraco.Core.Models var usn = new List(); foreach (var sn in userSn) { - string snp; - if (paths.TryGetValue(sn, out snp) == false) continue; // ignore rogue node (no path) + if (paths.TryGetValue(sn, out var snp) == false) continue; // ignore rogue node (no path) if (StartsWithPath(snp, binPath)) continue; // ignore bin diff --git a/src/Umbraco.Web/PropertyEditors/NestedContentConfiguration.cs b/src/Umbraco.Web/PropertyEditors/NestedContentConfiguration.cs index 44648ee859..b1ea7c633a 100644 --- a/src/Umbraco.Web/PropertyEditors/NestedContentConfiguration.cs +++ b/src/Umbraco.Web/PropertyEditors/NestedContentConfiguration.cs @@ -18,12 +18,15 @@ namespace Umbraco.Web.PropertyEditors public int? MaxItems { get; set; } [ConfigurationField("confirmDeletes", "Confirm Deletes", "boolean", Description = "Set whether item deletions should require confirming.")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] // do not try to map a null value to a boolean public bool ConfirmDeletes { get; set; } = true; [ConfigurationField("showIcons", "Show Icons", "boolean", Description = "Set whether to show the items doc type icon in the list.")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] // do not try to map a null value to a boolean public bool ShowIcons { get; set; } = true; [ConfigurationField("hideLabel", "Hide Label", "boolean", Description = "Set whether to hide the editor label and have the list take up the full width of the editor window.")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] // do not try to map a null value to a boolean public bool HideLabel { get; set; } public class ContentType diff --git a/src/Umbraco.Web/PropertyEditors/NestedContentPropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/NestedContentPropertyEditor.cs index b5e9ffa8a0..3fbbab1510 100644 --- a/src/Umbraco.Web/PropertyEditors/NestedContentPropertyEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/NestedContentPropertyEditor.cs @@ -115,7 +115,7 @@ namespace Umbraco.Web.PropertyEditors { // convert the value, and store the converted value var propEditor = _propertyEditors[propType.PropertyEditorAlias]; - var convValue = propEditor.ValueEditor.ConvertDbToString(propType, propValues[propAlias], dataTypeService); + var convValue = propEditor.ValueEditor.ConvertDbToString(propType, propValues[propAlias]?.ToString(), dataTypeService); propValues[propAlias] = convValue; } catch (InvalidOperationException)