Fix user for v7 migration

This commit is contained in:
Stephan
2019-05-07 19:44:41 +02:00
parent 7fed43cc68
commit ba9aa49b91
3 changed files with 18 additions and 1 deletions

View File

@@ -54,7 +54,6 @@ namespace Umbraco.Core.Models.Membership
_isLockedOut = false;
_startContentIds = new int[] { };
_startMediaIds = new int[] { };
}
/// <summary>

View File

@@ -36,6 +36,13 @@ namespace Umbraco.Core.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.AdditionalData["IS_V7_ZERO"] = true;
// reset dirty initial properties (U4-1946)
user.ResetDirtyProperties(false);

View File

@@ -434,6 +434,17 @@ 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 (((User) entity).AdditionalData.ContainsKey("IS_V7_ZERO"))
{
PersistUpdatedItem(entity);
return;
}
((User) entity).AddingEntity();
// ensure security stamp if missing