diff --git a/src/Umbraco.Core/Persistence/NPocoDatabaseExtensions.cs b/src/Umbraco.Core/Persistence/NPocoDatabaseExtensions.cs index 9329fa2287..176232cfe7 100644 --- a/src/Umbraco.Core/Persistence/NPocoDatabaseExtensions.cs +++ b/src/Umbraco.Core/Persistence/NPocoDatabaseExtensions.cs @@ -212,10 +212,9 @@ namespace Umbraco.Core.Persistence private static bool IncludeColumn(PocoData pocoData, string columnKey, PocoColumn column) { - return - column.ResultColumn == false - && pocoData.TableInfo.AutoIncrement == false - && columnKey != pocoData.TableInfo.PrimaryKey; + // exclude result columns, + // exclude primary key column if auto-increment + return column.ResultColumn == false && (pocoData.TableInfo.AutoIncrement == false || columnKey != pocoData.TableInfo.PrimaryKey); } /// @@ -256,7 +255,7 @@ namespace Umbraco.Core.Persistence // 4168 / 262 = 15.908... = there will be 16 trans in total // if we have disabled db parameters, then all items will be included, in only one transaction - var rowsPerCommand = Convert.ToInt32(Math.Floor(2000.00 / paramsPerRow)); + var rowsPerCommand = paramsPerRow == 0 ? int.MaxValue : Convert.ToInt32(Math.Floor(2000.00 / paramsPerRow)); var commandsCount = Convert.ToInt32(Math.Ceiling((double) records.Length / rowsPerCommand)); sql = new string[commandsCount]; diff --git a/src/Umbraco.Core/PropertyEditors/PropertyValueConverterBase.cs b/src/Umbraco.Core/PropertyEditors/PropertyValueConverterBase.cs index a124f0fcb2..f58342ca2c 100644 --- a/src/Umbraco.Core/PropertyEditors/PropertyValueConverterBase.cs +++ b/src/Umbraco.Core/PropertyEditors/PropertyValueConverterBase.cs @@ -24,7 +24,7 @@ namespace Umbraco.Core.PropertyEditors public virtual object ConvertSourceToXPath(PublishedPropertyType propertyType, object source, bool preview) { - return source.ToString(); + return source?.ToString() ?? string.Empty; } } } diff --git a/src/Umbraco.Core/Services/ContentService.cs b/src/Umbraco.Core/Services/ContentService.cs index 01cc3cf4cf..8ceea3de36 100644 --- a/src/Umbraco.Core/Services/ContentService.cs +++ b/src/Umbraco.Core/Services/ContentService.cs @@ -1663,25 +1663,25 @@ namespace Umbraco.Core.Services // if parent has not been copied, skip, else gets its copy id if (idmap.TryGetValue(descendant.ParentId, out parentId) == false) continue; - copy = descendant.DeepCloneWithResetIdentities(); - copy.ParentId = parentId; + var descendantCopy = descendant.DeepCloneWithResetIdentities(); + descendantCopy.ParentId = parentId; - if (Copying.IsRaisedEventCancelled(new CopyEventArgs(descendant, copy, parentId), this)) + if (Copying.IsRaisedEventCancelled(new CopyEventArgs(descendant, descendantCopy, parentId), this)) continue; // a copy is .Saving and will be .Unpublished // update the create author and last edit author - if (copy.Published) - copy.ChangePublishedState(PublishedState.Saving); - copy.CreatorId = userId; - copy.WriterId = userId; + if (descendantCopy.Published) + descendantCopy.ChangePublishedState(PublishedState.Saving); + descendantCopy.CreatorId = userId; + descendantCopy.WriterId = userId; // save and flush (see above) - repository.AddOrUpdate(copy); + repository.AddOrUpdate(descendantCopy); uow.Flush(); - copies.Add(Tuple.Create(descendant, copy)); - idmap[descendant.Id] = copy.Id; + copies.Add(Tuple.Create(descendant, descendantCopy)); + idmap[descendant.Id] = descendantCopy.Id; } } diff --git a/src/Umbraco.Tests/Membership/DynamicMemberContentTests.cs b/src/Umbraco.Tests/Membership/DynamicMemberContentTests.cs index 6b8fd17a2d..a93359bd68 100644 --- a/src/Umbraco.Tests/Membership/DynamicMemberContentTests.cs +++ b/src/Umbraco.Tests/Membership/DynamicMemberContentTests.cs @@ -76,7 +76,7 @@ namespace Umbraco.Tests.Membership Assert.AreEqual(date.AddMinutes(1), d.LastActivityDate); Assert.AreEqual(date.AddMinutes(2), d.LastLockoutDate); Assert.AreEqual(date.AddMinutes(1), d.LastLoginDate); - Assert.AreEqual(date.AddMinutes(4), d.LastPasswordChangedDate); + Assert.AreEqual(date.AddMinutes(4), d.LastPasswordChangeDate); Assert.AreEqual("test name", d.Name); Assert.AreEqual("test question", d.PasswordQuestion); Assert.AreEqual("test username", d.UserName); @@ -114,7 +114,7 @@ namespace Umbraco.Tests.Membership Assert.AreEqual(date.AddMinutes(1), d.lastActivityDate); Assert.AreEqual(date.AddMinutes(2), d.lastLockoutDate); Assert.AreEqual(date.AddMinutes(1), d.lastLoginDate); - Assert.AreEqual(date.AddMinutes(4), d.lastPasswordChangedDate); + Assert.AreEqual(date.AddMinutes(4), d.lastPasswordChangeDate); Assert.AreEqual("test name", d.name); Assert.AreEqual("test question", d.passwordQuestion); Assert.AreEqual("test username", d.userName);