Merge pull request #10898 from umbraco/v9/task/removed_obsolete_property_in_user

v9: removed obsolete property from User and IUser
This commit is contained in:
Mole
2021-08-23 12:47:36 +02:00
committed by GitHub
4 changed files with 1 additions and 95 deletions

View File

@@ -46,21 +46,5 @@ namespace Umbraco.Cms.Core.Models.Membership
/// A Json blob stored for recording tour data for a user
/// </summary>
string TourData { get; set; }
/// <summary>
/// Returns an item from the user instance's cache
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="cacheKey"></param>
/// <returns></returns>
T FromUserCache<T>(string cacheKey) where T : class;
/// <summary>
/// Puts an item in the user instance's cache
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="cacheKey"></param>
/// <param name="vals"></param>
void ToUserCache<T>(string cacheKey, T vals) where T : class;
}
}

View File

@@ -119,8 +119,6 @@ namespace Umbraco.Cms.Core.Models.Membership
private DateTime _lastPasswordChangedDate;
private DateTime _lastLoginDate;
private DateTime _lastLockoutDate;
private IDictionary<string, object> _additionalData;
private object _additionalDataLock = new object();
//Custom comparer for enumerable
private static readonly DelegateEqualityComparer<IEnumerable<int>> IntegerEnumerableComparer =
@@ -366,41 +364,6 @@ namespace Umbraco.Cms.Core.Models.Membership
}
}
public T FromUserCache<T>(string cacheKey)
where T : class
{
lock (_additionalDataLock)
{
return AdditionalData.TryGetValue(cacheKey, out var data)
? data as T
: null;
}
}
public void ToUserCache<T>(string cacheKey, T vals)
where T : class
{
lock (_additionalDataLock)
{
AdditionalData[cacheKey] = vals;
}
}
[IgnoreDataMember]
[DoNotClone]
[EditorBrowsable(EditorBrowsableState.Never)]
[Obsolete("This should not be used, it's currently used for only a single edge case - should probably be removed for netcore")]
internal IDictionary<string, object> AdditionalData
{
get
{
lock (_additionalDataLock)
{
return _additionalData ?? (_additionalData = new Dictionary<string, object>());
}
}
}
protected override void PerformDeepClone(object clone)
{
base.PerformDeepClone(clone);
@@ -410,29 +373,6 @@ namespace Umbraco.Cms.Core.Models.Membership
//manually clone the start node props
clonedEntity._startContentIds = _startContentIds.ToArray();
clonedEntity._startMediaIds = _startMediaIds.ToArray();
// this value has been cloned and points to the same object
// which obviously is bad - needs to point to a new object
clonedEntity._additionalDataLock = new object();
if (_additionalData != null)
{
// clone._additionalData points to the same dictionary, which is bad, because
// changing one clone impacts all of them - so we need to reset it with a fresh
// dictionary that will contain the same values - and, if some values are deep
// cloneable, they should be deep-cloned too
var cloneAdditionalData = clonedEntity._additionalData = new Dictionary<string, object>();
lock (_additionalDataLock)
{
foreach (var kvp in _additionalData)
{
var deepCloneable = kvp.Value as IDeepCloneable;
cloneAdditionalData[kvp.Key] = deepCloneable == null ? kvp.Value : deepCloneable.DeepClone();
}
}
}
//need to create new collections otherwise they'll get copied by ref
clonedEntity._userGroups = new HashSet<IReadOnlyUserGroup>(_userGroups);
clonedEntity._allowedSections = _allowedSections != null ? new List<string>(_allowedSections) : null;

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Linq;
using Umbraco.Cms.Core.Configuration.Models;
using Umbraco.Cms.Core.Models.Membership;
@@ -38,13 +38,6 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Factories
user.InvitedDate = dto.InvitedDate;
user.TourData = dto.TourData;
// we should never get user with ID zero from database, except
// when upgrading from v7 - mark that user so that we do not
// save it back to database (as that would create a *new* user)
// see also: UserRepository.PersistNewItem
if (dto.Id == 0)
user.ToUserCache<string>("IS_V7_ZERO", "true");
// reset dirty initial properties (U4-1946)
user.ResetDirtyProperties(false);

View File

@@ -444,17 +444,6 @@ ORDER BY colName";
protected override void PersistNewItem(IUser entity)
{
// the use may have no identity, ie ID is zero, and be v7 super
// user - then it has been marked - and we must not persist it
// as new, as we do not want to create a new user - instead, persist
// it as updated
// see also: UserFactory.BuildEntity
if (entity.FromUserCache<string>("IS_V7_ZERO") != null)
{
PersistUpdatedItem(entity);
return;
}
entity.AddingEntity();
// ensure security stamp if missing