Skip to content

Commit 2da06fb

Browse files
Merge pull request #10898 from umbraco/v9/task/removed_obsolete_property_in_user
v9: removed obsolete property from User and IUser
2 parents 7d0b26b + b272afa commit 2da06fb

File tree

4 files changed

+1
-95
lines changed

4 files changed

+1
-95
lines changed

src/Umbraco.Core/Models/Membership/IUser.cs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,5 @@ public interface IUser : IMembershipUser, IRememberBeingDirty, ICanBeDirty
4646
/// A Json blob stored for recording tour data for a user
4747
/// </summary>
4848
string TourData { get; set; }
49-
50-
/// <summary>
51-
/// Returns an item from the user instance's cache
52-
/// </summary>
53-
/// <typeparam name="T"></typeparam>
54-
/// <param name="cacheKey"></param>
55-
/// <returns></returns>
56-
T FromUserCache<T>(string cacheKey) where T : class;
57-
58-
/// <summary>
59-
/// Puts an item in the user instance's cache
60-
/// </summary>
61-
/// <typeparam name="T"></typeparam>
62-
/// <param name="cacheKey"></param>
63-
/// <param name="vals"></param>
64-
void ToUserCache<T>(string cacheKey, T vals) where T : class;
6549
}
6650
}

src/Umbraco.Core/Models/Membership/User.cs

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,6 @@ public User(GlobalSettings globalSettings, int id, string name, string email, st
119119
private DateTime _lastPasswordChangedDate;
120120
private DateTime _lastLoginDate;
121121
private DateTime _lastLockoutDate;
122-
private IDictionary<string, object> _additionalData;
123-
private object _additionalDataLock = new object();
124122

125123
//Custom comparer for enumerable
126124
private static readonly DelegateEqualityComparer<IEnumerable<int>> IntegerEnumerableComparer =
@@ -366,41 +364,6 @@ public void AddGroup(IReadOnlyUserGroup group)
366364
}
367365
}
368366

369-
public T FromUserCache<T>(string cacheKey)
370-
where T : class
371-
{
372-
lock (_additionalDataLock)
373-
{
374-
return AdditionalData.TryGetValue(cacheKey, out var data)
375-
? data as T
376-
: null;
377-
}
378-
}
379-
380-
public void ToUserCache<T>(string cacheKey, T vals)
381-
where T : class
382-
{
383-
lock (_additionalDataLock)
384-
{
385-
AdditionalData[cacheKey] = vals;
386-
}
387-
}
388-
389-
[IgnoreDataMember]
390-
[DoNotClone]
391-
[EditorBrowsable(EditorBrowsableState.Never)]
392-
[Obsolete("This should not be used, it's currently used for only a single edge case - should probably be removed for netcore")]
393-
internal IDictionary<string, object> AdditionalData
394-
{
395-
get
396-
{
397-
lock (_additionalDataLock)
398-
{
399-
return _additionalData ?? (_additionalData = new Dictionary<string, object>());
400-
}
401-
}
402-
}
403-
404367
protected override void PerformDeepClone(object clone)
405368
{
406369
base.PerformDeepClone(clone);
@@ -410,29 +373,6 @@ protected override void PerformDeepClone(object clone)
410373
//manually clone the start node props
411374
clonedEntity._startContentIds = _startContentIds.ToArray();
412375
clonedEntity._startMediaIds = _startMediaIds.ToArray();
413-
414-
// this value has been cloned and points to the same object
415-
// which obviously is bad - needs to point to a new object
416-
clonedEntity._additionalDataLock = new object();
417-
418-
if (_additionalData != null)
419-
{
420-
// clone._additionalData points to the same dictionary, which is bad, because
421-
// changing one clone impacts all of them - so we need to reset it with a fresh
422-
// dictionary that will contain the same values - and, if some values are deep
423-
// cloneable, they should be deep-cloned too
424-
var cloneAdditionalData = clonedEntity._additionalData = new Dictionary<string, object>();
425-
426-
lock (_additionalDataLock)
427-
{
428-
foreach (var kvp in _additionalData)
429-
{
430-
var deepCloneable = kvp.Value as IDeepCloneable;
431-
cloneAdditionalData[kvp.Key] = deepCloneable == null ? kvp.Value : deepCloneable.DeepClone();
432-
}
433-
}
434-
}
435-
436376
//need to create new collections otherwise they'll get copied by ref
437377
clonedEntity._userGroups = new HashSet<IReadOnlyUserGroup>(_userGroups);
438378
clonedEntity._allowedSections = _allowedSections != null ? new List<string>(_allowedSections) : null;

src/Umbraco.Infrastructure/Persistence/Factories/UserFactory.cs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Linq;
33
using Umbraco.Cms.Core.Configuration.Models;
44
using Umbraco.Cms.Core.Models.Membership;
@@ -38,13 +38,6 @@ public static IUser BuildEntity(GlobalSettings globalSettings, UserDto dto)
3838
user.InvitedDate = dto.InvitedDate;
3939
user.TourData = dto.TourData;
4040

41-
// we should never get user with ID zero from database, except
42-
// when upgrading from v7 - mark that user so that we do not
43-
// save it back to database (as that would create a *new* user)
44-
// see also: UserRepository.PersistNewItem
45-
if (dto.Id == 0)
46-
user.ToUserCache<string>("IS_V7_ZERO", "true");
47-
4841
// reset dirty initial properties (U4-1946)
4942
user.ResetDirtyProperties(false);
5043

src/Umbraco.Infrastructure/Persistence/Repositories/Implement/UserRepository.cs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -444,17 +444,6 @@ protected override IEnumerable<string> GetDeleteClauses()
444444

445445
protected override void PersistNewItem(IUser entity)
446446
{
447-
// the use may have no identity, ie ID is zero, and be v7 super
448-
// user - then it has been marked - and we must not persist it
449-
// as new, as we do not want to create a new user - instead, persist
450-
// it as updated
451-
// see also: UserFactory.BuildEntity
452-
if (entity.FromUserCache<string>("IS_V7_ZERO") != null)
453-
{
454-
PersistUpdatedItem(entity);
455-
return;
456-
}
457-
458447
entity.AddingEntity();
459448

460449
// ensure security stamp if missing

0 commit comments

Comments
 (0)