diff --git a/src/Umbraco.Core/Models/Rdbms/UserLoginDto.cs b/src/Umbraco.Core/Models/Rdbms/UserLoginDto.cs index 3315d1f7c1..6826377856 100644 --- a/src/Umbraco.Core/Models/Rdbms/UserLoginDto.cs +++ b/src/Umbraco.Core/Models/Rdbms/UserLoginDto.cs @@ -9,7 +9,7 @@ namespace Umbraco.Core.Models.Rdbms internal class UserLoginDto { [Column("contextID")] - [Index(IndexTypes.Clustered, Name = "umbracoUserLogins_Index")] + [Index(IndexTypes.Clustered, Name = "IX_umbracoUserLogins_Index")] public Guid ContextId { get; set; } [Column("userID")] diff --git a/src/Umbraco.Core/Models/RelationType.cs b/src/Umbraco.Core/Models/RelationType.cs index e1f5b4a388..ae20482229 100644 --- a/src/Umbraco.Core/Models/RelationType.cs +++ b/src/Umbraco.Core/Models/RelationType.cs @@ -21,9 +21,18 @@ namespace Umbraco.Core.Models public RelationType(Guid childObjectType, Guid parentObjectType, string @alias) { + Mandate.ParameterNotNullOrEmpty(@alias, "alias"); _childObjectType = childObjectType; _parentObjectType = parentObjectType; _alias = alias; + Name = _alias; + } + + public RelationType(Guid childObjectType, Guid parentObjectType, string @alias, string name) + :this(childObjectType, parentObjectType, @alias) + { + Mandate.ParameterNotNullOrEmpty(name, "name"); + Name = name; } private static readonly PropertyInfo NameSelector = ExpressionHelper.GetPropertyInfo(x => x.Name); diff --git a/src/Umbraco.Core/Persistence/Migrations/CatastrophicDataLossException.cs b/src/Umbraco.Core/Persistence/Migrations/DataLossException.cs similarity index 63% rename from src/Umbraco.Core/Persistence/Migrations/CatastrophicDataLossException.cs rename to src/Umbraco.Core/Persistence/Migrations/DataLossException.cs index 9c425a9e82..cb4ea9120a 100644 --- a/src/Umbraco.Core/Persistence/Migrations/CatastrophicDataLossException.cs +++ b/src/Umbraco.Core/Persistence/Migrations/DataLossException.cs @@ -5,15 +5,15 @@ namespace Umbraco.Core.Persistence.Migrations /// /// Used if a migration has executed but the whole process has failed and cannot be rolled back /// - internal class CatastrophicDataLossException : Exception + internal class DataLossException : Exception { - public CatastrophicDataLossException(string msg) + public DataLossException(string msg) : base(msg) { } - public CatastrophicDataLossException(string msg, Exception inner) + public DataLossException(string msg, Exception inner) : base(msg, inner) { diff --git a/src/Umbraco.Core/Persistence/Migrations/Initial/DatabaseSchemaCreation.cs b/src/Umbraco.Core/Persistence/Migrations/Initial/DatabaseSchemaCreation.cs index fddc71c483..7ad88f0739 100644 --- a/src/Umbraco.Core/Persistence/Migrations/Initial/DatabaseSchemaCreation.cs +++ b/src/Umbraco.Core/Persistence/Migrations/Initial/DatabaseSchemaCreation.cs @@ -171,7 +171,8 @@ namespace Umbraco.Core.Persistence.Migrations.Initial x.Item3.InvariantStartsWith("FK_") == false && x.Item3.InvariantStartsWith("PK_") == false && x.Item3.InvariantStartsWith("IX_") == false).Select(x => x.Item3).ToList(); var foreignKeysInSchema = result.TableDefinitions.SelectMany(x => x.ForeignKeys.Select(y => y.Name)).ToList(); - var primaryKeysInSchema = result.TableDefinitions.SelectMany(x => x.Columns.Select(y => y.PrimaryKeyName)).ToList(); + var primaryKeysInSchema = result.TableDefinitions.SelectMany(x => x.Columns.Select(y => y.PrimaryKeyName)) + .Where(x => x.IsNullOrWhiteSpace() == false).ToList(); //Add valid and invalid foreign key differences to the result object foreach (var unknown in unknownConstraintsInDatabase) @@ -283,7 +284,8 @@ namespace Umbraco.Core.Persistence.Migrations.Initial private void ValidateDbIndexes(DatabaseSchemaResult result) { //These are just column indexes NOT constraints or Keys - var colIndexesInDatabase = result.DbIndexDefinitions.Where(x => x.IndexName.InvariantStartsWith("IX_")).Select(x => x.IndexName).ToList(); + //var colIndexesInDatabase = result.DbIndexDefinitions.Where(x => x.IndexName.InvariantStartsWith("IX_")).Select(x => x.IndexName).ToList(); + var colIndexesInDatabase = result.DbIndexDefinitions.Select(x => x.IndexName).ToList(); var indexesInSchema = result.TableDefinitions.SelectMany(x => x.Indexes.Select(y => y.Name)).ToList(); //Add valid and invalid index differences to the result object diff --git a/src/Umbraco.Core/Persistence/Migrations/MigrationRunner.cs b/src/Umbraco.Core/Persistence/Migrations/MigrationRunner.cs index 5e9e6bc1ac..3ab415e455 100644 --- a/src/Umbraco.Core/Persistence/Migrations/MigrationRunner.cs +++ b/src/Umbraco.Core/Persistence/Migrations/MigrationRunner.cs @@ -48,26 +48,21 @@ namespace Umbraco.Core.Persistence.Migrations var foundMigrations = MigrationResolver.Current.Migrations.ToArray(); - //filter all schema migrations - var schemaMigrations = isUpgrade - ? OrderedUpgradeMigrations(foundMigrations.Where(x => (x is SchemaMigration))).ToList() - : OrderedDowngradeMigrations(foundMigrations.Where(x => (x is SchemaMigration))).ToList(); - //filter all non-schema migrations - var dataMigrations = isUpgrade - ? OrderedUpgradeMigrations(foundMigrations.Where(x => (x is SchemaMigration) == false)).ToList() - : OrderedDowngradeMigrations(foundMigrations.Where(x => (x is SchemaMigration) == false)).ToList(); + var migrations = isUpgrade + ? OrderedUpgradeMigrations(foundMigrations).ToList() + : OrderedDowngradeMigrations(foundMigrations).ToList(); //SD: Why do we want this? - if (Migrating.IsRaisedEventCancelled(new MigrationEventArgs(dataMigrations, _currentVersion, _targetVersion, true), this)) + if (Migrating.IsRaisedEventCancelled(new MigrationEventArgs(migrations, _configuredVersion, _targetVersion, true), this)) return false; //Loop through migrations to generate sql - var schemaMigrationContext = InitializeMigrations(schemaMigrations, database, databaseProvider, isUpgrade); + var migrationContext = InitializeMigrations(migrations, database, databaseProvider, isUpgrade); try { - ExecuteMigrations(schemaMigrationContext, database); + ExecuteMigrations(migrationContext, database); } catch (Exception ex) { @@ -77,35 +72,16 @@ namespace Umbraco.Core.Persistence.Migrations if (databaseProvider == DatabaseProviders.MySql) { - try - { - var downgrades = OrderedDowngradeMigrations(foundMigrations.Where(x => (x is SchemaMigration))).ToList(); - var downgradeMigrationContext = InitializeMigrations(downgrades, database, databaseProvider, false); - //lets hope that works! - if something cannot be rolled back then a CatastrophicDataLossException should - // be thrown. - ExecuteMigrations(downgradeMigrationContext, database); - } - catch (Exception e) - { - throw new CatastrophicDataLossException( + throw new DataLossException( "An error occurred running a schema migration but the changes could not be rolled back. Error: " + ex.Message + ". In some cases, it may be required that the database be restored to it's original state before running this upgrade process again.", ex); - - } } //continue throwing the exception throw; } - //Ok, we've made it this far, now we can execute our data migrations - - //Loop through migrations to generate sql - var dataMigrationContext = InitializeMigrations(dataMigrations, database, databaseProvider, isUpgrade); - //run them - if this fails the data will be rolled back - ExecuteMigrations(dataMigrationContext, database); - - Migrated.RaiseEvent(new MigrationEventArgs(dataMigrations, dataMigrationContext, _currentVersion, _targetVersion, false), this); + Migrated.RaiseEvent(new MigrationEventArgs(migrations, migrationContext, _configuredVersion, _targetVersion, false), this); return true; } diff --git a/src/Umbraco.Core/Persistence/Migrations/SchemaMigration.cs b/src/Umbraco.Core/Persistence/Migrations/SchemaMigration.cs deleted file mode 100644 index 6c1e9301ae..0000000000 --- a/src/Umbraco.Core/Persistence/Migrations/SchemaMigration.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace Umbraco.Core.Persistence.Migrations -{ - /// - /// A migration class that specifies that it is used for db schema migrations only - these need to execute first and MUST - /// have a downgrade plan. - /// - public abstract class SchemaMigration : MigrationBase - { - - } -} \ No newline at end of file diff --git a/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionFourNineZero/RemoveUmbracoAppConstraints.cs b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionFourNineZero/RemoveUmbracoAppConstraints.cs index e7543fd063..efcb5d2415 100644 --- a/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionFourNineZero/RemoveUmbracoAppConstraints.cs +++ b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionFourNineZero/RemoveUmbracoAppConstraints.cs @@ -4,7 +4,7 @@ using Umbraco.Core.Configuration; namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionFourNineZero { [MigrationAttribute("4.9.0", 0, GlobalSettings.UmbracoMigrationName)] - public class RemoveUmbracoAppConstraints : SchemaMigration + public class RemoveUmbracoAppConstraints : MigrationBase { public override void Up() { diff --git a/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSix/DeleteAppTables.cs b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSix/DeleteAppTables.cs index fe0820a025..05edf00062 100644 --- a/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSix/DeleteAppTables.cs +++ b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSix/DeleteAppTables.cs @@ -16,7 +16,7 @@ namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSix public override void Down() { //This cannot be rolled back!! - throw new CatastrophicDataLossException("Cannot rollback migration " + typeof(DeleteAppTables) + " the db tables umbracoAppTree and umbracoApp have been droppped"); + throw new DataLossException("Cannot rollback migration " + typeof(DeleteAppTables) + " the db tables umbracoAppTree and umbracoApp have been droppped"); } } } \ No newline at end of file diff --git a/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSix/NewCmsContentType2ContentTypeTable.cs b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSix/NewCmsContentType2ContentTypeTable.cs index 29fb8c0f6d..7ff03087c4 100644 --- a/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSix/NewCmsContentType2ContentTypeTable.cs +++ b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSix/NewCmsContentType2ContentTypeTable.cs @@ -3,7 +3,7 @@ namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSix { [Migration("6.0.0", 4, GlobalSettings.UmbracoMigrationName)] - public class NewCmsContentType2ContentTypeTable : SchemaMigration + public class NewCmsContentType2ContentTypeTable : MigrationBase { public override void Up() { diff --git a/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSix/RemoveMasterContentTypeColumn.cs b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSix/RemoveMasterContentTypeColumn.cs index b11c32e818..680b2001a0 100644 --- a/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSix/RemoveMasterContentTypeColumn.cs +++ b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSix/RemoveMasterContentTypeColumn.cs @@ -3,7 +3,7 @@ namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSix { [Migration("6.0.0", 6, GlobalSettings.UmbracoMigrationName)] - public class RemoveMasterContentTypeColumn : SchemaMigration + public class RemoveMasterContentTypeColumn : MigrationBase { public override void Up() { diff --git a/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSix/RenameCmsTabTable.cs b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSix/RenameCmsTabTable.cs index daf5400c81..0f8635af09 100644 --- a/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSix/RenameCmsTabTable.cs +++ b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSix/RenameCmsTabTable.cs @@ -3,7 +3,7 @@ namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSix { [Migration("6.0.0", 0, GlobalSettings.UmbracoMigrationName)] - public class RenameCmsTabTable : SchemaMigration + public class RenameCmsTabTable : MigrationBase { public override void Up() { diff --git a/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSix/RenameTabIdColumn.cs b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSix/RenameTabIdColumn.cs index 7ff33092b0..6f3f7edc80 100644 --- a/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSix/RenameTabIdColumn.cs +++ b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSix/RenameTabIdColumn.cs @@ -4,7 +4,7 @@ using Umbraco.Core.Configuration; namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSix { [Migration("6.0.0", 7, GlobalSettings.UmbracoMigrationName)] - public class RenameTabIdColumn : SchemaMigration + public class RenameTabIdColumn : MigrationBase { public override void Up() { diff --git a/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSix/UpdateCmsContentTypeAllowedContentTypeTable.cs b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSix/UpdateCmsContentTypeAllowedContentTypeTable.cs index 0d9ddef431..be704466a8 100644 --- a/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSix/UpdateCmsContentTypeAllowedContentTypeTable.cs +++ b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSix/UpdateCmsContentTypeAllowedContentTypeTable.cs @@ -3,7 +3,7 @@ namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSix { [Migration("6.0.0", 3, GlobalSettings.UmbracoMigrationName)] - public class UpdateCmsContentTypeAllowedContentTypeTable : SchemaMigration + public class UpdateCmsContentTypeAllowedContentTypeTable : MigrationBase { public override void Up() { diff --git a/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSix/UpdateCmsContentTypeTable.cs b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSix/UpdateCmsContentTypeTable.cs index 935b6f62bf..3e6b4cf05c 100644 --- a/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSix/UpdateCmsContentTypeTable.cs +++ b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSix/UpdateCmsContentTypeTable.cs @@ -3,7 +3,7 @@ namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSix { [Migration("6.0.0", 2, GlobalSettings.UmbracoMigrationName)] - public class UpdateCmsContentTypeTable : SchemaMigration + public class UpdateCmsContentTypeTable : MigrationBase { public override void Up() { diff --git a/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSix/UpdateCmsContentVersionTable.cs b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSix/UpdateCmsContentVersionTable.cs index e84383d753..1dc8998e68 100644 --- a/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSix/UpdateCmsContentVersionTable.cs +++ b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSix/UpdateCmsContentVersionTable.cs @@ -3,7 +3,7 @@ namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSix { [Migration("6.0.0", 8, GlobalSettings.UmbracoMigrationName)] - public class UpdateCmsContentVersionTable : SchemaMigration + public class UpdateCmsContentVersionTable : MigrationBase { public override void Up() { diff --git a/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSix/UpdateCmsPropertyTypeGroupTable.cs b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSix/UpdateCmsPropertyTypeGroupTable.cs index 7c5c1651d9..51054efb6c 100644 --- a/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSix/UpdateCmsPropertyTypeGroupTable.cs +++ b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSix/UpdateCmsPropertyTypeGroupTable.cs @@ -4,7 +4,7 @@ using Umbraco.Core.Configuration; namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSix { [Migration("6.0.0", 1, GlobalSettings.UmbracoMigrationName)] - public class UpdateCmsPropertyTypeGroupTable : SchemaMigration + public class UpdateCmsPropertyTypeGroupTable : MigrationBase { public override void Up() { diff --git a/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSixOneZero/CreateServerRegistryTable.cs b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSixOneZero/CreateServerRegistryTable.cs index e54e43761d..5c39f92b21 100644 --- a/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSixOneZero/CreateServerRegistryTable.cs +++ b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSixOneZero/CreateServerRegistryTable.cs @@ -9,7 +9,7 @@ namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSixOneZero { [Migration("6.1.0", 0, GlobalSettings.UmbracoMigrationName)] - public class CreateServerRegistryTable : SchemaMigration + public class CreateServerRegistryTable : MigrationBase { public override void Up() { diff --git a/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSixTwoZero/AdditionalIndexesAndKeys.cs b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSixTwoZero/AdditionalIndexesAndKeys.cs index 3a1381c71a..aac2db246a 100644 --- a/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSixTwoZero/AdditionalIndexesAndKeys.cs +++ b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSixTwoZero/AdditionalIndexesAndKeys.cs @@ -41,6 +41,17 @@ namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSixTwoZero { Create.Index("IX_cmsDocument_newest").OnTable("cmsDocument").OnColumn("newest").Ascending().WithOptions().NonClustered(); } + + //we want to drop the umbracoUserLogins_Index index since it is named incorrectly and then re-create it so + // it follows the standard naming convention + if (dbIndexes.Any(x => x.IndexName.InvariantEquals("umbracoUserLogins_Index"))) + { + Delete.Index("umbracoUserLogins_Index").OnTable("umbracoUserLogins"); + } + if (dbIndexes.Any(x => x.IndexName.InvariantEquals("IX_umbracoUserLogins_Index")) == false) + { + Create.Index("IX_umbracoUserLogins_Index").OnTable("umbracoUserLogins").OnColumn("contextID").Ascending().WithOptions().Clustered(); + } } public override void Down() diff --git a/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSixTwoZero/ChangePasswordColumn.cs b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSixTwoZero/ChangePasswordColumn.cs index 972a172011..437a188013 100644 --- a/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSixTwoZero/ChangePasswordColumn.cs +++ b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSixTwoZero/ChangePasswordColumn.cs @@ -5,7 +5,7 @@ namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSixTwoZero { [Migration("7.1.0", 2, GlobalSettings.UmbracoMigrationName)] [Migration("6.2.0", 2, GlobalSettings.UmbracoMigrationName)] - public class ChangePasswordColumn : SchemaMigration + public class ChangePasswordColumn : MigrationBase { public override void Up() { diff --git a/src/Umbraco.Core/StringExtensions.cs b/src/Umbraco.Core/StringExtensions.cs index 0b0c76f620..6a2784cc98 100644 --- a/src/Umbraco.Core/StringExtensions.cs +++ b/src/Umbraco.Core/StringExtensions.cs @@ -532,7 +532,7 @@ namespace Umbraco.Core public static bool InvariantContains(this IEnumerable compare, string compareTo) { - return compare.Contains(compareTo, new DelegateEqualityComparer((source, dest) => source.Equals(dest, StringComparison.InvariantCultureIgnoreCase), x => x.GetHashCode())); + return compare.Contains(compareTo, StringComparer.InvariantCultureIgnoreCase); } /// diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj index 7e75d96b05..35a194cd7b 100644 --- a/src/Umbraco.Core/Umbraco.Core.csproj +++ b/src/Umbraco.Core/Umbraco.Core.csproj @@ -364,8 +364,7 @@ - - + diff --git a/src/Umbraco.Tests/Membership/UmbracoServiceMembershipProviderTests.cs b/src/Umbraco.Tests/Membership/UmbracoServiceMembershipProviderTests.cs index 99ec6dbef2..8ea9665f41 100644 --- a/src/Umbraco.Tests/Membership/UmbracoServiceMembershipProviderTests.cs +++ b/src/Umbraco.Tests/Membership/UmbracoServiceMembershipProviderTests.cs @@ -15,17 +15,6 @@ namespace Umbraco.Tests.Membership [TestFixture, RequiresSTA] public class UmbracoServiceMembershipProviderTests { - - [Test] - public void Throws_On_Empty_Default_Member_Type_On_Init() - { - var mServiceMock = new Mock(); - var provider = new MembersMembershipProvider(mServiceMock.Object); - mServiceMock.Setup(service => service.GetDefaultMemberType()).Returns(""); - - Assert.Throws(() => provider.Initialize("test", new NameValueCollection())); - } - [Test] public void Sets_Default_Member_Type_From_Service_On_Init() { diff --git a/src/Umbraco.Tests/Services/ContentServiceTests.cs b/src/Umbraco.Tests/Services/ContentServiceTests.cs index c424c04640..ee6d719177 100644 --- a/src/Umbraco.Tests/Services/ContentServiceTests.cs +++ b/src/Umbraco.Tests/Services/ContentServiceTests.cs @@ -14,7 +14,7 @@ using Umbraco.Tests.TestHelpers.Entities; namespace Umbraco.Tests.Services { - /// + /// /// Tests covering all methods in the ContentService class. /// This is more of an integration test as it involves multiple layers /// as well as configuration. diff --git a/src/Umbraco.Tests/Services/RelationServiceTests.cs b/src/Umbraco.Tests/Services/RelationServiceTests.cs new file mode 100644 index 0000000000..e2b9f57287 --- /dev/null +++ b/src/Umbraco.Tests/Services/RelationServiceTests.cs @@ -0,0 +1,34 @@ +using System; +using NUnit.Framework; +using Umbraco.Core; +using Umbraco.Core.Models; + +namespace Umbraco.Tests.Services +{ + [TestFixture, RequiresSTA] + public class RelationServiceTests : BaseServiceTest + { + [SetUp] + public override void Initialize() + { + base.Initialize(); + } + + [TearDown] + public override void TearDown() + { + base.TearDown(); + } + + [Test] + public void Can_Create_RelationType_Without_Name() + { + var rs = ServiceContext.RelationService; + var rt = new RelationType(new Guid(Constants.ObjectTypes.Document), new Guid(Constants.ObjectTypes.Document), "repeatedEventOccurence"); + + Assert.DoesNotThrow(() => rs.Save(rt)); + + Assert.AreEqual(rt.Name, "repeatedEventOccurence"); + } + } +} \ No newline at end of file diff --git a/src/Umbraco.Tests/Umbraco.Tests.csproj b/src/Umbraco.Tests/Umbraco.Tests.csproj index b837fec9d7..b8736f8695 100644 --- a/src/Umbraco.Tests/Umbraco.Tests.csproj +++ b/src/Umbraco.Tests/Umbraco.Tests.csproj @@ -300,6 +300,7 @@ + @@ -592,6 +593,7 @@ ResXFileCodeGenerator SqlResources.Designer.cs + Designer ResXFileCodeGenerator diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/protectPage.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/protectPage.aspx.cs index c914b9350b..6c414206e0 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/protectPage.aspx.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/protectPage.aspx.cs @@ -102,14 +102,17 @@ namespace umbraco.presentation.umbraco.dialogs if (Access.GetProtectionType(documentId) == ProtectionType.Simple) { - MembershipUser m = Access.GetAccessingMembershipUser(documentId); - pane_simple.Visible = true; - pp_pass.Visible = false; - simpleLogin.Visible = false; - SimpleLoginLabel.Visible = true; - SimpleLoginLabel.Text = m.UserName; - pane_advanced.Visible = false; - bt_protect.CommandName = "simple"; + MembershipUser m = Access.GetAccessingMembershipUser(documentId); + if (m != null) + { + pane_simple.Visible = true; + pp_pass.Visible = false; + simpleLogin.Visible = false; + SimpleLoginLabel.Visible = true; + SimpleLoginLabel.Text = m.UserName; + pane_advanced.Visible = false; + bt_protect.CommandName = "simple"; + } } else if (Access.GetProtectionType(documentId) == ProtectionType.Advanced) diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/treePicker.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/treePicker.aspx.cs index 38518804b4..30f9fbb12d 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/treePicker.aspx.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/treePicker.aspx.cs @@ -21,10 +21,14 @@ namespace umbraco.dialogs TreeParams = TreeRequestParams.FromQueryStrings().CreateTreeService(); DataBind(); - if(Request.QueryString["selected"] != null && TreeParams.TreeType == "content") { + if(Request.QueryString["selected"] != null && TreeParams.TreeType == "content") + { var currContent = Services.ContentService.GetById(int.Parse(Request.QueryString["selected"])); - if (currContent.ParentId > 0) - DialogTree.SelectedNodePath = currContent.Path; + if (currContent != null) + { + if (currContent.ParentId > 0) + DialogTree.SelectedNodePath = currContent.Path; + } } } diff --git a/src/umbraco.MacroEngines/RazorDynamicNode/DynamicBackingItem.cs b/src/umbraco.MacroEngines/RazorDynamicNode/DynamicBackingItem.cs index c748605264..ded21a3119 100644 --- a/src/umbraco.MacroEngines/RazorDynamicNode/DynamicBackingItem.cs +++ b/src/umbraco.MacroEngines/RazorDynamicNode/DynamicBackingItem.cs @@ -32,6 +32,16 @@ namespace umbraco.MacroEngines } public DynamicBackingItem(int Id) { + if (Id == -1) + { + //this is a special check, previously passing in -1 would return a real node, the root node. Though + // it has no properties (defaults apply), you could access descendants, children, etc... + //This is how this used to work before a large refactor - which I think may have broken other legacy logic too :( + + this.content = new NodeFactory.Node(Id); + return; + } + var n = CompatibilityHelper.ConvertToNode(UmbracoContext.Current.ContentCache.GetById(Id)); this.content = n; @@ -57,7 +67,19 @@ namespace umbraco.MacroEngines } else { - this.content = CompatibilityHelper.ConvertToNode(UmbracoContext.Current.ContentCache.GetById(Id)); + if (Id == -1) + { + //this is a special check, previously passing in -1 would return a real node, the root node. Though + // it has no properties (defaults apply), you could access descendants, children, etc... + //This is how this used to work before a large refactor - which I think may have broken other legacy logic too :( + + this.content = new NodeFactory.Node(Id); + } + else + { + this.content = CompatibilityHelper.ConvertToNode(UmbracoContext.Current.ContentCache.GetById(Id)); + } + this.Type = Type; } } diff --git a/src/umbraco.MacroEngines/RazorDynamicNode/RazorLibraryCore.cs b/src/umbraco.MacroEngines/RazorDynamicNode/RazorLibraryCore.cs index 6ab1bad3d8..d9d93a458e 100644 --- a/src/umbraco.MacroEngines/RazorDynamicNode/RazorLibraryCore.cs +++ b/src/umbraco.MacroEngines/RazorDynamicNode/RazorLibraryCore.cs @@ -33,13 +33,13 @@ namespace umbraco.MacroEngines.Library public dynamic NodeById(int Id) { var node = new DynamicNode(Id); - if (node != null && node.Id == 0) return new DynamicNull(); + if (node.Id == 0) return new DynamicNull(); return node; } public dynamic NodeById(string Id) { var node = new DynamicNode(Id); - if (node != null && node.Id == 0) return new DynamicNull(); + if (node.Id == 0) return new DynamicNull(); return node; } public dynamic NodeById(DynamicNull Id) @@ -53,7 +53,7 @@ namespace umbraco.MacroEngines.Library return new DynamicNull(); } var node = new DynamicNode(Id); - if (node != null && node.Id == 0) return new DynamicNull(); + if (node.Id == 0) return new DynamicNull(); return node; } public dynamic NodesById(List Ids) diff --git a/src/umbraco.editorControls/pagepicker/pagePicker.cs b/src/umbraco.editorControls/pagepicker/pagePicker.cs index 5aaf8fa7db..a45ce2ac96 100644 --- a/src/umbraco.editorControls/pagepicker/pagePicker.cs +++ b/src/umbraco.editorControls/pagepicker/pagePicker.cs @@ -23,15 +23,15 @@ namespace umbraco.editorControls { public pagePicker() : base() { } - public pagePicker(interfaces.IData data) : base(data) { } + public pagePicker(IData data) : base(data) { } public override string TreePickerUrl { get { - if (HttpContext.Current != null && HttpContext.Current.Request.QueryString["id"] != null) + if (Context.Request.QueryString["id"] != null) { - return TreeUrlGenerator.GetPickerUrl(Umbraco.Core.Constants.Applications.Content, "content") + "&selected=" + HttpContext.Current.Request.QueryString["id"]; + return TreeUrlGenerator.GetPickerUrl(Umbraco.Core.Constants.Applications.Content, "content") + "&selected=" + Context.Request.QueryString["id"]; } return TreeUrlGenerator.GetPickerUrl(Umbraco.Core.Constants.Applications.Content, "content");