diff --git a/src/Umbraco.Core/Persistence/Factories/MemberTypeReadOnlyFactory.cs b/src/Umbraco.Core/Persistence/Factories/MemberTypeReadOnlyFactory.cs index d1e090fafe..56d9f4cff9 100644 --- a/src/Umbraco.Core/Persistence/Factories/MemberTypeReadOnlyFactory.cs +++ b/src/Umbraco.Core/Persistence/Factories/MemberTypeReadOnlyFactory.cs @@ -95,7 +95,10 @@ namespace Umbraco.Core.Persistence.Factories var propertyType = new PropertyType(typeDto.PropertyEditorAlias, //ensures that any built-in membership properties have their correct dbtype assigned no matter //what the underlying data type is - MemberTypeRepository.GetDbTypeForProperty(typeDto.Alias, typeDto.DbType.EnumParse(true), standardProps)) + MemberTypeRepository.GetDbTypeForBuiltInProperty( + typeDto.Alias, + typeDto.DbType.EnumParse(true), + standardProps).Result) { Alias = typeDto.Alias, DataTypeDefinitionId = typeDto.DataTypeId, diff --git a/src/Umbraco.Core/Persistence/Repositories/ContentTypeBaseRepository.cs b/src/Umbraco.Core/Persistence/Repositories/ContentTypeBaseRepository.cs index c5982989f3..3201213b8c 100644 --- a/src/Umbraco.Core/Persistence/Repositories/ContentTypeBaseRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/ContentTypeBaseRepository.cs @@ -145,8 +145,7 @@ namespace Umbraco.Core.Persistence.Repositories //If the Id of the DataType is not set, we resolve it from the db by its PropertyEditorAlias if (propertyType.DataTypeDefinitionId == 0 || propertyType.DataTypeDefinitionId == default(int)) { - var datatype = Database.FirstOrDefault("WHERE propertyEditorAlias = @alias", new { alias = propertyType.PropertyEditorAlias }); - propertyType.DataTypeDefinitionId = datatype.DataTypeId; + AssignDataTypeFromPropertyEditor(propertyType); } var propertyTypeDto = propertyFactory.BuildPropertyTypeDto(tabId, propertyType); int typePrimaryKey = Convert.ToInt32(Database.Insert(propertyTypeDto)); @@ -303,21 +302,7 @@ namespace Umbraco.Core.Persistence.Repositories //If the Id of the DataType is not set, we resolve it from the db by its PropertyEditorAlias if (propertyType.DataTypeDefinitionId == 0 || propertyType.DataTypeDefinitionId == default(int)) { - //we cannot try to assign a data type of it's an empty guid - if (propertyType.DataTypeId != Guid.Empty) - { - var sql = new Sql() - .Select("*") - .From() - .Where("propertyEditorAlias = @propertyEditorAlias", new { propertyEditorAlias = propertyType.PropertyEditorAlias }) - .OrderBy(typeDto => typeDto.DataTypeId); - var datatype = Database.FirstOrDefault(sql); - //we cannot assign a data type if one was not found - if (datatype != null) - { - propertyType.DataTypeDefinitionId = datatype.DataTypeId; - } - } + AssignDataTypeFromPropertyEditor(propertyType); } //validate the alias! @@ -434,5 +419,32 @@ namespace Umbraco.Core.Persistence.Repositories throw exception; }); } + + /// + /// Try to set the data type id based on its ControlId + /// + /// + private void AssignDataTypeFromPropertyEditor(PropertyType propertyType) + { + //we cannot try to assign a data type of it's an empty guid + if (propertyType.DataTypeId != Guid.Empty) + { + var sql = new Sql() + .Select("*") + .From() + .Where("controlId = @Id", new { Id = propertyType.DataTypeId }) + .OrderBy(typeDto => typeDto.DataTypeId); + var datatype = Database.FirstOrDefault(sql); + //we cannot assign a data type if one was not found + if (datatype != null) + { + propertyType.DataTypeDefinitionId = datatype.DataTypeId; + } + else + { + LogHelper.Warn>("Could not assign a data type for the property type " + propertyType.Alias + " since no data type was found with a property editor " + propertyType.DataTypeId); + } + } + } } } \ No newline at end of file diff --git a/src/Umbraco.Core/Persistence/Repositories/Interfaces/IMemberRepository.cs b/src/Umbraco.Core/Persistence/Repositories/Interfaces/IMemberRepository.cs index ac005aa731..2c5e6a3e5b 100644 --- a/src/Umbraco.Core/Persistence/Repositories/Interfaces/IMemberRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/Interfaces/IMemberRepository.cs @@ -7,7 +7,7 @@ using Umbraco.Core.Persistence.Querying; namespace Umbraco.Core.Persistence.Repositories { - internal interface IMemberRepository : IRepositoryVersionable + public interface IMemberRepository : IRepositoryVersionable { /// /// Finds members in a given role diff --git a/src/Umbraco.Core/Persistence/Repositories/Interfaces/IUserRepository.cs b/src/Umbraco.Core/Persistence/Repositories/Interfaces/IUserRepository.cs index c09d51d3f0..90e6e49c2f 100644 --- a/src/Umbraco.Core/Persistence/Repositories/Interfaces/IUserRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/Interfaces/IUserRepository.cs @@ -6,7 +6,7 @@ using Umbraco.Core.Persistence.Querying; namespace Umbraco.Core.Persistence.Repositories { - internal interface IUserRepository : IRepositoryQueryable + public interface IUserRepository : IRepositoryQueryable { /// /// Gets the count of items based on a complex query diff --git a/src/Umbraco.Core/Persistence/Repositories/Interfaces/IUserTypeRepository.cs b/src/Umbraco.Core/Persistence/Repositories/Interfaces/IUserTypeRepository.cs index efa50f6641..43b6709aa7 100644 --- a/src/Umbraco.Core/Persistence/Repositories/Interfaces/IUserTypeRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/Interfaces/IUserTypeRepository.cs @@ -2,7 +2,7 @@ namespace Umbraco.Core.Persistence.Repositories { - internal interface IUserTypeRepository : IRepositoryQueryable + public interface IUserTypeRepository : IRepositoryQueryable { } diff --git a/src/Umbraco.Core/Persistence/Repositories/MemberTypeRepository.cs b/src/Umbraco.Core/Persistence/Repositories/MemberTypeRepository.cs index 8f55b31075..7c0deb1edc 100644 --- a/src/Umbraco.Core/Persistence/Repositories/MemberTypeRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/MemberTypeRepository.cs @@ -245,10 +245,14 @@ namespace Umbraco.Core.Persistence.Repositories var stdProps = Constants.Conventions.Member.GetStandardPropertyTypeStubs(); foreach (var propertyType in memberType.PropertyTypes) { - propertyType.DataTypeDatabaseType = GetDbTypeForProperty(propertyType.Alias, propertyType.DataTypeDatabaseType, stdProps); - //this reset's it's current data type reference which will be re-assigned based on the property editor assigned on the next line - propertyType.DataTypeDefinitionId = 0; - propertyType.DataTypeId = GetPropertyEditorForProperty(propertyType.Alias, propertyType.DataTypeId, stdProps); + var dbTypeAttempt = GetDbTypeForBuiltInProperty(propertyType.Alias, propertyType.DataTypeDatabaseType, stdProps); + if (dbTypeAttempt) + { + propertyType.DataTypeDatabaseType = dbTypeAttempt.Result; + //this reset's it's current data type reference which will be re-assigned based on the property editor assigned on the next line + propertyType.DataTypeDefinitionId = 0; + propertyType.DataTypeId = GetPropertyEditorForBuiltInProperty(propertyType.Alias, propertyType.DataTypeId, stdProps).Result; + } } } @@ -273,8 +277,10 @@ namespace Umbraco.Core.Persistence.Repositories /// /// /// - /// - internal static DataTypeDatabaseType GetDbTypeForProperty( + /// + /// Successful attempt if it was a built in property + /// + internal static Attempt GetDbTypeForBuiltInProperty( string propAlias, DataTypeDatabaseType dbType, Dictionary standardProps) @@ -285,13 +291,22 @@ namespace Umbraco.Core.Persistence.Repositories if (aliases.Contains(propAlias)) { //return the pre-determined db type for this property - return standardProps.Single(x => x.Key == propAlias).Value.DataTypeDatabaseType; + return Attempt.Succeed(standardProps.Single(x => x.Key == propAlias).Value.DataTypeDatabaseType); } - return dbType; + return Attempt.Fail(dbType); } - internal static Guid GetPropertyEditorForProperty( + /// + /// + /// + /// + /// + /// + /// + /// Successful attempt if it was a built in property + /// + internal static Attempt GetPropertyEditorForBuiltInProperty( string propAlias, Guid propertyEditor, Dictionary standardProps) @@ -302,10 +317,10 @@ namespace Umbraco.Core.Persistence.Repositories if (aliases.Contains(propAlias)) { //return the pre-determined db type for this property - return standardProps.Single(x => x.Key == propAlias).Value.DataTypeId; + return Attempt.Succeed(standardProps.Single(x => x.Key == propAlias).Value.DataTypeId); } - return propertyEditor; + return Attempt.Fail(propertyEditor); } } } \ No newline at end of file diff --git a/src/Umbraco.Core/Persistence/RepositoryFactory.cs b/src/Umbraco.Core/Persistence/RepositoryFactory.cs index 5df3c9b414..a381443561 100644 --- a/src/Umbraco.Core/Persistence/RepositoryFactory.cs +++ b/src/Umbraco.Core/Persistence/RepositoryFactory.cs @@ -159,20 +159,20 @@ namespace Umbraco.Core.Persistence NullCacheProvider.Current); } - internal virtual IUserTypeRepository CreateUserTypeRepository(IDatabaseUnitOfWork uow) + public virtual IUserTypeRepository CreateUserTypeRepository(IDatabaseUnitOfWork uow) { return new UserTypeRepository( uow, //There's not many user types but we query on users all the time so the result needs to be cached - RuntimeCacheProvider.Current); + _disableAllCache ? (IRepositoryCacheProvider)NullCacheProvider.Current : RuntimeCacheProvider.Current); } - internal virtual IUserRepository CreateUserRepository(IDatabaseUnitOfWork uow) + public virtual IUserRepository CreateUserRepository(IDatabaseUnitOfWork uow) { return new UserRepository( uow, //Need to cache users - we look up user information more than anything in the back office! - RuntimeCacheProvider.Current, + _disableAllCache ? (IRepositoryCacheProvider)NullCacheProvider.Current : RuntimeCacheProvider.Current, CreateUserTypeRepository(uow), _cacheHelper); } @@ -182,7 +182,7 @@ namespace Umbraco.Core.Persistence return new MacroRepository(uow, _disableAllCache ? (IRepositoryCacheProvider)NullCacheProvider.Current : RuntimeCacheProvider.Current); } - internal virtual IMemberRepository CreateMemberRepository(IDatabaseUnitOfWork uow) + public virtual IMemberRepository CreateMemberRepository(IDatabaseUnitOfWork uow) { return new MemberRepository( uow, @@ -192,17 +192,17 @@ namespace Umbraco.Core.Persistence CreateTagsRepository(uow)); } - internal virtual IMemberTypeRepository CreateMemberTypeRepository(IDatabaseUnitOfWork uow) + public virtual IMemberTypeRepository CreateMemberTypeRepository(IDatabaseUnitOfWork uow) { return new MemberTypeRepository(uow, _disableAllCache ? (IRepositoryCacheProvider)NullCacheProvider.Current : RuntimeCacheProvider.Current); } - internal virtual IMemberGroupRepository CreateMemberGroupRepository(IDatabaseUnitOfWork uow) + public virtual IMemberGroupRepository CreateMemberGroupRepository(IDatabaseUnitOfWork uow) { return new MemberGroupRepository(uow, _disableAllCache ? (IRepositoryCacheProvider)NullCacheProvider.Current : RuntimeCacheProvider.Current, _cacheHelper); } - internal virtual IEntityRepository CreateEntityRepository(IDatabaseUnitOfWork uow) + public virtual IEntityRepository CreateEntityRepository(IDatabaseUnitOfWork uow) { return new EntityRepository(uow); } diff --git a/src/Umbraco.Tests/Umbraco.Tests.csproj b/src/Umbraco.Tests/Umbraco.Tests.csproj index c84a44df45..d807c3fc2e 100644 --- a/src/Umbraco.Tests/Umbraco.Tests.csproj +++ b/src/Umbraco.Tests/Umbraco.Tests.csproj @@ -1,4 +1,4 @@ - + Debug @@ -60,7 +60,7 @@ False - ..\packages\Examine.0.1.52.2941\lib\Examine.dll + ..\packages\Examine.0.1.53.2941\lib\Examine.dll False diff --git a/src/Umbraco.Tests/packages.config b/src/Umbraco.Tests/packages.config index df4bc3d02d..218eaad3aa 100644 --- a/src/Umbraco.Tests/packages.config +++ b/src/Umbraco.Tests/packages.config @@ -1,8 +1,8 @@  + - diff --git a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj index 96238cff03..7cbc525e55 100644 --- a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj +++ b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj @@ -1,4 +1,4 @@ - + @@ -125,7 +125,7 @@ False - ..\packages\Examine.0.1.52.2941\lib\Examine.dll + ..\packages\Examine.0.1.53.2941\lib\Examine.dll ..\packages\ImageProcessor.1.8.3.0\lib\net45\ImageProcessor.dll diff --git a/src/Umbraco.Web.UI/packages.config b/src/Umbraco.Web.UI/packages.config index d897305d0a..0910c927f1 100644 --- a/src/Umbraco.Web.UI/packages.config +++ b/src/Umbraco.Web.UI/packages.config @@ -3,7 +3,7 @@ - + diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index 47fd9fbffd..55c5b18bb0 100644 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -1,4 +1,4 @@ - + @@ -112,7 +112,7 @@ False - ..\packages\Examine.0.1.52.2941\lib\Examine.dll + ..\packages\Examine.0.1.53.2941\lib\Examine.dll False diff --git a/src/Umbraco.Web/packages.config b/src/Umbraco.Web/packages.config index 556fb360ba..26a530678d 100644 --- a/src/Umbraco.Web/packages.config +++ b/src/Umbraco.Web/packages.config @@ -3,7 +3,7 @@ - + diff --git a/src/UmbracoExamine.Azure/UmbracoExamine.Azure.csproj b/src/UmbracoExamine.Azure/UmbracoExamine.Azure.csproj index 22792d6aa0..b6334d6a5e 100644 --- a/src/UmbracoExamine.Azure/UmbracoExamine.Azure.csproj +++ b/src/UmbracoExamine.Azure/UmbracoExamine.Azure.csproj @@ -1,4 +1,4 @@ - + Debug @@ -42,7 +42,7 @@ False - ..\packages\Examine.0.1.52.2941\lib\Examine.dll + ..\packages\Examine.0.1.53.2941\lib\Examine.dll False diff --git a/src/UmbracoExamine.Azure/packages.config b/src/UmbracoExamine.Azure/packages.config index 54eb3830da..f159081ad4 100644 --- a/src/UmbracoExamine.Azure/packages.config +++ b/src/UmbracoExamine.Azure/packages.config @@ -2,7 +2,7 @@ - + diff --git a/src/UmbracoExamine.PDF.Azure/UmbracoExamine.PDF.Azure.csproj b/src/UmbracoExamine.PDF.Azure/UmbracoExamine.PDF.Azure.csproj index 203fc935dc..7dc3ae5ae2 100644 --- a/src/UmbracoExamine.PDF.Azure/UmbracoExamine.PDF.Azure.csproj +++ b/src/UmbracoExamine.PDF.Azure/UmbracoExamine.PDF.Azure.csproj @@ -1,4 +1,4 @@ - + Debug @@ -42,7 +42,7 @@ False - ..\packages\Examine.0.1.52.2941\lib\Examine.dll + ..\packages\Examine.0.1.53.2941\lib\Examine.dll False diff --git a/src/UmbracoExamine.PDF.Azure/packages.config b/src/UmbracoExamine.PDF.Azure/packages.config index 54eb3830da..f159081ad4 100644 --- a/src/UmbracoExamine.PDF.Azure/packages.config +++ b/src/UmbracoExamine.PDF.Azure/packages.config @@ -2,7 +2,7 @@ - + diff --git a/src/UmbracoExamine.PDF/UmbracoExamine.PDF.csproj b/src/UmbracoExamine.PDF/UmbracoExamine.PDF.csproj index aed13c7c13..1c65905ee9 100644 --- a/src/UmbracoExamine.PDF/UmbracoExamine.PDF.csproj +++ b/src/UmbracoExamine.PDF/UmbracoExamine.PDF.csproj @@ -1,4 +1,4 @@ - + Debug @@ -48,7 +48,7 @@ False - ..\packages\Examine.0.1.52.2941\lib\Examine.dll + ..\packages\Examine.0.1.53.2941\lib\Examine.dll ..\packages\SharpZipLib.0.86.0\lib\20\ICSharpCode.SharpZipLib.dll diff --git a/src/UmbracoExamine.PDF/packages.config b/src/UmbracoExamine.PDF/packages.config index 1d29bc3cc6..0ea9c20ae7 100644 --- a/src/UmbracoExamine.PDF/packages.config +++ b/src/UmbracoExamine.PDF/packages.config @@ -1,6 +1,6 @@  - + diff --git a/src/UmbracoExamine/UmbracoExamine.csproj b/src/UmbracoExamine/UmbracoExamine.csproj index 7bcb270bce..b6e8292094 100644 --- a/src/UmbracoExamine/UmbracoExamine.csproj +++ b/src/UmbracoExamine/UmbracoExamine.csproj @@ -1,4 +1,4 @@ - + Debug @@ -84,7 +84,7 @@ False - ..\packages\Examine.0.1.52.2941\lib\Examine.dll + ..\packages\Examine.0.1.53.2941\lib\Examine.dll False diff --git a/src/UmbracoExamine/packages.config b/src/UmbracoExamine/packages.config index 31026832a5..1bb39ddebc 100644 --- a/src/UmbracoExamine/packages.config +++ b/src/UmbracoExamine/packages.config @@ -1,6 +1,6 @@  - + \ No newline at end of file diff --git a/src/umbraco.MacroEngines/packages.config b/src/umbraco.MacroEngines/packages.config index 992451e496..d321df1e85 100644 --- a/src/umbraco.MacroEngines/packages.config +++ b/src/umbraco.MacroEngines/packages.config @@ -1,6 +1,6 @@  - + diff --git a/src/umbraco.MacroEngines/umbraco.MacroEngines.csproj b/src/umbraco.MacroEngines/umbraco.MacroEngines.csproj index 6dec8e9ee7..e2dffc276a 100644 --- a/src/umbraco.MacroEngines/umbraco.MacroEngines.csproj +++ b/src/umbraco.MacroEngines/umbraco.MacroEngines.csproj @@ -1,4 +1,4 @@ - + Debug @@ -45,9 +45,9 @@ false - + False - ..\packages\Examine.0.1.52.2941\lib\Examine.dll + ..\packages\Examine.0.1.53.2941\lib\Examine.dll False diff --git a/src/umbraco.cms/businesslogic/ContentType.cs b/src/umbraco.cms/businesslogic/ContentType.cs index 6f9514f460..58dbde48a3 100644 --- a/src/umbraco.cms/businesslogic/ContentType.cs +++ b/src/umbraco.cms/businesslogic/ContentType.cs @@ -59,6 +59,7 @@ namespace umbraco.cms.businesslogic /// /// /// + /// /// /// This is like creating a ContentType node using optimized mode but this lets you set /// all of the properties that are initialized normally from the database. diff --git a/src/umbraco.editorControls/umbraco.editorControls.csproj b/src/umbraco.editorControls/umbraco.editorControls.csproj index 865b574024..9a2c47fabd 100644 --- a/src/umbraco.editorControls/umbraco.editorControls.csproj +++ b/src/umbraco.editorControls/umbraco.editorControls.csproj @@ -1,4 +1,4 @@ - + Local