Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Resolve null reference when data types are missing #5231

Merged
merged 1 commit into from
Aug 11, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions DNN Platform/Library/Entities/Users/Profile/UserProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information

// ReSharper disable CheckNamespace
// ReSharper disable once CheckNamespace
namespace DotNetNuke.Entities.Users

// ReSharper restore CheckNamespace
{
using System;
using System.Globalization;
Expand All @@ -18,6 +16,7 @@ namespace DotNetNuke.Entities.Users
using DotNetNuke.Common.Utilities;
using DotNetNuke.Entities.Portals;
using DotNetNuke.Entities.Profile;
using DotNetNuke.Instrumentation;
using DotNetNuke.Services.FileSystem;

/// <summary>
Expand Down Expand Up @@ -620,7 +619,7 @@ public ProfilePropertyDefinition GetProperty(string propName)
/// <remarks>
/// Used mainly for custom profile properties, many default properties are already exposed in this class.
/// </remarks>
/// <param name="propName">The name of the propoerty to retrieve.</param>
/// <param name="propName">The name of the property to retrieve.</param>
/// <returns>A string representing the property value.</returns>
public string GetPropertyValue(string propName)
{
Expand All @@ -634,6 +633,12 @@ public string GetPropertyValue(string propName)
{
var controller = new ListController();
var dataType = controller.GetListEntryInfo("DataType", profileProp.DataType);
if (dataType == null)
{
LoggerSource.Instance.GetLogger(typeof(UserProfile)).ErrorFormat("Invalid data type {0} for profile property {1}", profileProp.DataType, profileProp.PropertyName);
return propValue;
}

if (dataType.Value == "Country" || dataType.Value == "Region")
{
propValue = this.GetListValue(dataType.Value, propValue);
Expand Down