("Database upgrade started");
- var message = _scopeProvider.SqlContext.DatabaseType.IsMySql() ? ResultMessageForMySql : "";
-
// upgrade
var upgrader = new UmbracoUpgrader();
upgrader.Execute(_scopeProvider, _migrationBuilder, _keyValueService, _logger, _postMigrations);
- message = message + "Upgrade completed!
";
+ var message = "Upgrade completed!
";
//now that everything is done, we need to determine the version of SQL server that is executing
@@ -515,15 +513,6 @@ namespace Umbraco.Core.Migrations.Install
}
}
- private const string ResultMessageForMySql = "
Congratulations, the database step ran successfully!
" +
- "Note: You're using MySQL and the database instance you're connecting to seems to support case insensitive queries.
" +
- "However, your hosting provider may not support this option. Umbraco does not currently support MySQL installs that do not support case insensitive queries
" +
- "Make sure to check with your hosting provider if they support case insensitive queries as well.
" +
- "They can check this by looking for the following setting in the my.ini file in their MySQL installation directory:
" +
- "lower_case_table_names=1
" +
- "For more technical information on case sensitivity in MySQL, have a look at " +
- "the documentation on the subject
";
-
private Attempt CheckReadyForInstall()
{
if (_databaseFactory.Configured == false)
diff --git a/src/Umbraco.Core/Migrations/Install/DatabaseDataCreator.cs b/src/Umbraco.Core/Migrations/Install/DatabaseDataCreator.cs
index f32ea1cb6f..7e9df321c3 100644
--- a/src/Umbraco.Core/Migrations/Install/DatabaseDataCreator.cs
+++ b/src/Umbraco.Core/Migrations/Install/DatabaseDataCreator.cs
@@ -135,7 +135,7 @@ namespace Umbraco.Core.Migrations.Install
_database.Insert(Constants.DatabaseSchema.Tables.Node, "id", false, new NodeDto { NodeId = 1047, Trashed = false, ParentId = -1, UserId = -1, Level = 1, Path = "-1,1047", SortOrder = 2, UniqueId = new Guid("1EA2E01F-EBD8-4CE1-8D71-6B1149E63548"), Text = "Member Picker", NodeObjectType = Constants.ObjectTypes.DataType, CreateDate = DateTime.Now });
_database.Insert(Constants.DatabaseSchema.Tables.Node, "id", false, new NodeDto { NodeId = 1048, Trashed = false, ParentId = -1, UserId = -1, Level = 1, Path = "-1,1048", SortOrder = 2, UniqueId = new Guid("135D60E0-64D9-49ED-AB08-893C9BA44AE5"), Text = "Media Picker", NodeObjectType = Constants.ObjectTypes.DataType, CreateDate = DateTime.Now });
_database.Insert(Constants.DatabaseSchema.Tables.Node, "id", false, new NodeDto { NodeId = 1049, Trashed = false, ParentId = -1, UserId = -1, Level = 1, Path = "-1,1049", SortOrder = 2, UniqueId = new Guid("9DBBCBBB-2327-434A-B355-AF1B84E5010A"), Text = "Multiple Media Picker", NodeObjectType = Constants.ObjectTypes.DataType, CreateDate = DateTime.Now });
- _database.Insert(Constants.DatabaseSchema.Tables.Node, "id", false, new NodeDto { NodeId = 1050, Trashed = false, ParentId = -1, UserId = -1, Level = 1, Path = "-1,1050", SortOrder = 2, UniqueId = new Guid("B4E3535A-1753-47E2-8568-602CF8CFEE6F"), Text = "Related Links", NodeObjectType = Constants.ObjectTypes.DataType, CreateDate = DateTime.Now });
+ _database.Insert(Constants.DatabaseSchema.Tables.Node, "id", false, new NodeDto { NodeId = 1050, Trashed = false, ParentId = -1, UserId = -1, Level = 1, Path = "-1,1050", SortOrder = 2, UniqueId = new Guid("B4E3535A-1753-47E2-8568-602CF8CFEE6F"), Text = "Multi URL Picker", NodeObjectType = Constants.ObjectTypes.DataType, CreateDate = DateTime.Now });
}
private void CreateLockData()
@@ -263,7 +263,7 @@ namespace Umbraco.Core.Migrations.Install
const string listLayout = "{\"name\": \"List\",\"path\": \"views/propertyeditors/listview/layouts/list/list.html\",\"icon\": \"icon-list\", \"isSystem\": 1,\"selected\": true}";
const string layouts = "[" + cardLayout + "," + listLayout + "]";
- //TODO Check which of the DataTypeIds below doesn't exist in umbracoNode, which results in a foreign key constraint errors.
+ // TODO: Check which of the DataTypeIds below doesn't exist in umbracoNode, which results in a foreign key constraint errors.
_database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = -49, EditorAlias = Constants.PropertyEditors.Aliases.Boolean, DbType = "Integer" });
_database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = -51, EditorAlias = Constants.PropertyEditors.Aliases.Integer, DbType = "Integer" });
_database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = -87, EditorAlias = Constants.PropertyEditors.Aliases.TinyMce, DbType = "Ntext",
@@ -301,7 +301,7 @@ namespace Umbraco.Core.Migrations.Install
_database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = 1048, EditorAlias = Constants.PropertyEditors.Aliases.MediaPicker, DbType = "Ntext" });
_database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = 1049, EditorAlias = Constants.PropertyEditors.Aliases.MediaPicker, DbType = "Ntext",
Configuration = "{\"multiPicker\":1}" });
- _database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = 1050, EditorAlias = Constants.PropertyEditors.Aliases.RelatedLinks, DbType = "Ntext" });
+ _database.Insert(Constants.DatabaseSchema.Tables.DataType, "pk", false, new DataTypeDto { NodeId = 1050, EditorAlias = Constants.PropertyEditors.Aliases.MultiUrlPicker, DbType = "Ntext" });
}
private void CreateRelationTypeData()
diff --git a/src/Umbraco.Core/Migrations/Install/DatabaseSchemaCreator.cs b/src/Umbraco.Core/Migrations/Install/DatabaseSchemaCreator.cs
index f9f3e5da30..5cc818a6d2 100644
--- a/src/Umbraco.Core/Migrations/Install/DatabaseSchemaCreator.cs
+++ b/src/Umbraco.Core/Migrations/Install/DatabaseSchemaCreator.cs
@@ -1,524 +1,513 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using NPoco;
-using Umbraco.Core.Events;
-using Umbraco.Core.Logging;
-using Umbraco.Core.Persistence;
-using Umbraco.Core.Persistence.DatabaseModelDefinitions;
-using Umbraco.Core.Persistence.Dtos;
-using Umbraco.Core.Persistence.SqlSyntax;
-
-namespace Umbraco.Core.Migrations.Install
-{
- ///
- /// Creates the initial database schema during install.
- ///
- public class DatabaseSchemaCreator
- {
- private readonly IUmbracoDatabase _database;
- private readonly ILogger _logger;
-
- public DatabaseSchemaCreator(IUmbracoDatabase database, ILogger logger)
- {
- _database = database;
- _logger = logger;
- }
-
- private ISqlSyntaxProvider SqlSyntax => _database.SqlContext.SqlSyntax;
-
- // all tables, in order
- internal static readonly List OrderedTables = new List
- {
- typeof (UserDto),
- typeof (NodeDto),
- typeof (ContentTypeDto),
- typeof (TemplateDto),
- typeof (ContentDto),
- typeof (ContentVersionDto),
- typeof (MediaVersionDto),
- typeof (DocumentDto),
- typeof (ContentTypeTemplateDto),
- typeof (DataTypeDto),
- typeof (DictionaryDto),
- typeof (LanguageDto),
- typeof (LanguageTextDto),
- typeof (DomainDto),
- typeof (LogDto),
- typeof (MacroDto),
- typeof (MacroPropertyDto),
- typeof (MemberTypeDto),
- typeof (MemberDto),
- typeof (Member2MemberGroupDto),
- typeof (ContentXmlDto),
- typeof (PreviewXmlDto),
- typeof (PropertyTypeGroupDto),
- typeof (PropertyTypeDto),
- typeof (PropertyDataDto),
- typeof (RelationTypeDto),
- typeof (RelationDto),
- typeof (TagDto),
- typeof (TagRelationshipDto),
- typeof (ContentType2ContentTypeDto),
- typeof (ContentTypeAllowedContentTypeDto),
- typeof (User2NodeNotifyDto),
- typeof (ServerRegistrationDto),
- typeof (AccessDto),
- typeof (AccessRuleDto),
- typeof (CacheInstructionDto),
- typeof (ExternalLoginDto),
- typeof (RedirectUrlDto),
- typeof (LockDto),
- typeof (UserGroupDto),
- typeof (User2UserGroupDto),
- typeof (UserGroup2NodePermissionDto),
- typeof (UserGroup2AppDto),
- typeof (UserStartNodeDto),
- typeof (ContentNuDto),
- typeof (DocumentVersionDto),
- typeof (KeyValueDto),
- typeof (UserLoginDto),
- typeof (ConsentDto),
- typeof (AuditEntryDto),
- typeof (ContentVersionCultureVariationDto),
- typeof (DocumentCultureVariationDto),
- typeof (ContentScheduleDto)
- };
-
- ///
- /// Drops all Umbraco tables in the db.
- ///
- internal void UninstallDatabaseSchema()
- {
- _logger.Info("Start UninstallDatabaseSchema");
-
- foreach (var table in OrderedTables.AsEnumerable().Reverse())
- {
- var tableNameAttribute = table.FirstAttribute();
- var tableName = tableNameAttribute == null ? table.Name : tableNameAttribute.Value;
-
- _logger.Info("Uninstall {TableName}", tableName);
-
- try
- {
- if (TableExists(tableName))
- DropTable(tableName);
- }
- catch (Exception ex)
- {
- //swallow this for now, not sure how best to handle this with diff databases... though this is internal
- // and only used for unit tests. If this fails its because the table doesn't exist... generally!
- _logger.Error(ex, "Could not drop table {TableName}", tableName);
- }
- }
- }
-
- ///
- /// Initializes the database by creating the umbraco db schema.
- ///
- /// This needs to execute as part of a transaction.
- public void InitializeDatabaseSchema()
- {
- if (!_database.InTransaction)
- throw new InvalidOperationException("Database is not in a transaction.");
-
- var e = new DatabaseCreationEventArgs();
- FireBeforeCreation(e);
-
- if (e.Cancel == false)
- {
- var dataCreation = new DatabaseDataCreator(_database, _logger);
- foreach (var table in OrderedTables)
- CreateTable(false, table, dataCreation);
- }
-
- FireAfterCreation(e);
- }
-
- ///
- /// Validates the schema of the current database.
- ///
- internal DatabaseSchemaResult ValidateSchema()
- {
- var result = new DatabaseSchemaResult(SqlSyntax);
-
- result.IndexDefinitions.AddRange(SqlSyntax.GetDefinedIndexes(_database)
- .Select(x => new DbIndexDefinition(x)));
-
- result.TableDefinitions.AddRange(OrderedTables
- .Select(x => DefinitionFactory.GetTableDefinition(x, SqlSyntax)));
-
- ValidateDbTables(result);
- ValidateDbColumns(result);
- ValidateDbIndexes(result);
- ValidateDbConstraints(result);
-
- return result;
- }
-
- ///
- /// This validates the Primary/Foreign keys in the database
- ///
- ///
- ///
- /// This does not validate any database constraints that are not PKs or FKs because Umbraco does not create a database with non PK/FK contraints.
- /// Any unique "constraints" in the database are done with unique indexes.
- ///
- private void ValidateDbConstraints(DatabaseSchemaResult result)
- {
- //MySql doesn't conform to the "normal" naming of constraints, so there is currently no point in doing these checks.
- //TODO: At a later point we do other checks for MySql, but ideally it should be necessary to do special checks for different providers.
- // ALso note that to get the constraints for MySql we have to open a connection which we currently have not.
- if (SqlSyntax is MySqlSyntaxProvider)
- return;
-
- //Check constraints in configured database against constraints in schema
- var constraintsInDatabase = SqlSyntax.GetConstraintsPerColumn(_database).DistinctBy(x => x.Item3).ToList();
- var foreignKeysInDatabase = constraintsInDatabase.Where(x => x.Item3.InvariantStartsWith("FK_")).Select(x => x.Item3).ToList();
- var primaryKeysInDatabase = constraintsInDatabase.Where(x => x.Item3.InvariantStartsWith("PK_")).Select(x => x.Item3).ToList();
-
- var unknownConstraintsInDatabase =
- constraintsInDatabase.Where(
- x =>
- 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))
- .Where(x => x.IsNullOrWhiteSpace() == false).ToList();
-
- //Add valid and invalid foreign key differences to the result object
- // We'll need to do invariant contains with case insensitivity because foreign key, primary key, and even index naming w/ MySQL is not standardized
- // In theory you could have: FK_ or fk_ ...or really any standard that your development department (or developer) chooses to use.
- foreach (var unknown in unknownConstraintsInDatabase)
- {
- if (foreignKeysInSchema.InvariantContains(unknown) || primaryKeysInSchema.InvariantContains(unknown))
- {
- result.ValidConstraints.Add(unknown);
- }
- else
- {
- result.Errors.Add(new Tuple("Unknown", unknown));
- }
- }
-
- //Foreign keys:
-
- var validForeignKeyDifferences = foreignKeysInDatabase.Intersect(foreignKeysInSchema, StringComparer.InvariantCultureIgnoreCase);
- foreach (var foreignKey in validForeignKeyDifferences)
- {
- result.ValidConstraints.Add(foreignKey);
- }
- var invalidForeignKeyDifferences =
- foreignKeysInDatabase.Except(foreignKeysInSchema, StringComparer.InvariantCultureIgnoreCase)
- .Union(foreignKeysInSchema.Except(foreignKeysInDatabase, StringComparer.InvariantCultureIgnoreCase));
- foreach (var foreignKey in invalidForeignKeyDifferences)
- {
- result.Errors.Add(new Tuple("Constraint", foreignKey));
- }
-
-
- //Primary keys:
-
- //Add valid and invalid primary key differences to the result object
- var validPrimaryKeyDifferences = primaryKeysInDatabase.Intersect(primaryKeysInSchema, StringComparer.InvariantCultureIgnoreCase);
- foreach (var primaryKey in validPrimaryKeyDifferences)
- {
- result.ValidConstraints.Add(primaryKey);
- }
- var invalidPrimaryKeyDifferences =
- primaryKeysInDatabase.Except(primaryKeysInSchema, StringComparer.InvariantCultureIgnoreCase)
- .Union(primaryKeysInSchema.Except(primaryKeysInDatabase, StringComparer.InvariantCultureIgnoreCase));
- foreach (var primaryKey in invalidPrimaryKeyDifferences)
- {
- result.Errors.Add(new Tuple("Constraint", primaryKey));
- }
-
- }
-
- private void ValidateDbColumns(DatabaseSchemaResult result)
- {
- //Check columns in configured database against columns in schema
- var columnsInDatabase = SqlSyntax.GetColumnsInSchema(_database);
- var columnsPerTableInDatabase = columnsInDatabase.Select(x => string.Concat(x.TableName, ",", x.ColumnName)).ToList();
- var columnsPerTableInSchema = result.TableDefinitions.SelectMany(x => x.Columns.Select(y => string.Concat(y.TableName, ",", y.Name))).ToList();
- //Add valid and invalid column differences to the result object
- var validColumnDifferences = columnsPerTableInDatabase.Intersect(columnsPerTableInSchema, StringComparer.InvariantCultureIgnoreCase);
- foreach (var column in validColumnDifferences)
- {
- result.ValidColumns.Add(column);
- }
-
- var invalidColumnDifferences =
- columnsPerTableInDatabase.Except(columnsPerTableInSchema, StringComparer.InvariantCultureIgnoreCase)
- .Union(columnsPerTableInSchema.Except(columnsPerTableInDatabase, StringComparer.InvariantCultureIgnoreCase));
- foreach (var column in invalidColumnDifferences)
- {
- result.Errors.Add(new Tuple("Column", column));
- }
- }
-
- private void ValidateDbTables(DatabaseSchemaResult result)
- {
- //Check tables in configured database against tables in schema
- var tablesInDatabase = SqlSyntax.GetTablesInSchema(_database).ToList();
- var tablesInSchema = result.TableDefinitions.Select(x => x.Name).ToList();
- //Add valid and invalid table differences to the result object
- var validTableDifferences = tablesInDatabase.Intersect(tablesInSchema, StringComparer.InvariantCultureIgnoreCase);
- foreach (var tableName in validTableDifferences)
- {
- result.ValidTables.Add(tableName);
- }
-
- var invalidTableDifferences =
- tablesInDatabase.Except(tablesInSchema, StringComparer.InvariantCultureIgnoreCase)
- .Union(tablesInSchema.Except(tablesInDatabase, StringComparer.InvariantCultureIgnoreCase));
- foreach (var tableName in invalidTableDifferences)
- {
- result.Errors.Add(new Tuple("Table", tableName));
- }
- }
-
- 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.IndexDefinitions.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
- var validColIndexDifferences = colIndexesInDatabase.Intersect(indexesInSchema, StringComparer.InvariantCultureIgnoreCase);
- foreach (var index in validColIndexDifferences)
- {
- result.ValidIndexes.Add(index);
- }
-
- var invalidColIndexDifferences =
- colIndexesInDatabase.Except(indexesInSchema, StringComparer.InvariantCultureIgnoreCase)
- .Union(indexesInSchema.Except(colIndexesInDatabase, StringComparer.InvariantCultureIgnoreCase));
- foreach (var index in invalidColIndexDifferences)
- {
- result.Errors.Add(new Tuple("Index", index));
- }
- }
-
- #region Events
-
- ///
- /// The save event handler
- ///
- internal delegate void DatabaseEventHandler(DatabaseCreationEventArgs e);
-
- ///
- /// Occurs when [before save].
- ///
- internal static event DatabaseEventHandler BeforeCreation;
- ///
- /// Raises the event.
- ///
- /// The instance containing the event data.
- internal virtual void FireBeforeCreation(DatabaseCreationEventArgs e)
- {
- BeforeCreation?.Invoke(e);
- }
-
- ///
- /// Occurs when [after save].
- ///
- internal static event DatabaseEventHandler AfterCreation;
- ///
- /// Raises the event.
- ///
- /// The instance containing the event data.
- internal virtual void FireAfterCreation(DatabaseCreationEventArgs e)
- {
- AfterCreation?.Invoke(e);
- }
-
- #endregion
-
- #region Utilities
-
- ///
- /// Returns whether a table with the specified exists in the database.
- ///
- /// The name of the table.
- /// true if the table exists; otherwise false.
- ///
- ///
- /// if (schemaHelper.TableExist("MyTable"))
- /// {
- /// // do something when the table exists
- /// }
- ///
- ///
- public bool TableExists(string tableName)
- {
- return SqlSyntax.DoesTableExist(_database, tableName);
- }
-
- ///
- /// Returns whether the table for the specified exists in the database.
- ///
- /// The type representing the DTO/table.
- /// true if the table exists; otherwise false.
- ///
- ///
- /// if (schemaHelper.TableExist<MyDto>)
- /// {
- /// // do something when the table exists
- /// }
- ///
- ///
- ///
- /// If has been decorated with an , the name from that
- /// attribute will be used for the table name. If the attribute is not present, the name
- /// will be used instead.
- ///
- public bool TableExists()
{
- var table = DefinitionFactory.GetTableDefinition(typeof(T), SqlSyntax);
- return table != null && TableExists(table.Name);
}
-
- ///
- /// Creates a new table in the database based on the type of .
- ///
- /// The type representing the DTO/table.
- /// Whether the table should be overwritten if it already exists.
- ///
- /// If has been decorated with an , the name from that
- /// attribute will be used for the table name. If the attribute is not present, the name
- /// will be used instead.
- ///
- /// If a table with the same name already exists, the parameter will determine
- /// whether the table is overwritten. If true, the table will be overwritten, whereas this method will
- /// not do anything if the parameter is false.
- ///
- internal void CreateTable(bool overwrite = false)
- where T : new()
- {
- var tableType = typeof(T);
- CreateTable(overwrite, tableType, new DatabaseDataCreator(_database, _logger));
- }
-
- ///
- /// Creates a new table in the database for the specified .
- ///
- /// Whether the table should be overwritten if it already exists.
- /// The the representing the table.
- ///
- ///
- /// If has been decorated with an , the name from
- /// that attribute will be used for the table name. If the attribute is not present, the name
- /// will be used instead.
- ///
- /// If a table with the same name already exists, the parameter will determine
- /// whether the table is overwritten. If true, the table will be overwritten, whereas this method will
- /// not do anything if the parameter is false.
- ///
- /// This need to execute as part of a transaction.
- ///
- internal void CreateTable(bool overwrite, Type modelType, DatabaseDataCreator dataCreation)
- {
- if (!_database.InTransaction)
- throw new InvalidOperationException("Database is not in a transaction.");
-
- var tableDefinition = DefinitionFactory.GetTableDefinition(modelType, SqlSyntax);
- var tableName = tableDefinition.Name;
-
- var createSql = SqlSyntax.Format(tableDefinition);
- var createPrimaryKeySql = SqlSyntax.FormatPrimaryKey(tableDefinition);
- var foreignSql = SqlSyntax.Format(tableDefinition.ForeignKeys);
- var indexSql = SqlSyntax.Format(tableDefinition.Indexes);
-
- var tableExist = TableExists(tableName);
- if (overwrite && tableExist)
- {
- _logger.Info("Table '{TableName}' already exists, but will be recreated", tableName);
-
- DropTable(tableName);
- tableExist = false;
- }
-
- if (tableExist)
- {
- // The table exists and was not recreated/overwritten.
- _logger.Info("Table '{TableName}' already exists - no changes were made", tableName);
- return;
- }
-
- //Execute the Create Table sql
- var created = _database.Execute(new Sql(createSql));
- _logger.Info("Create Table '{TableName}' ({Created}): \n {Sql}", tableName, created, createSql);
-
- //If any statements exists for the primary key execute them here
- if (string.IsNullOrEmpty(createPrimaryKeySql) == false)
- {
- var createdPk = _database.Execute(new Sql(createPrimaryKeySql));
- _logger.Info("Create Primary Key ({CreatedPk}):\n {Sql}", createdPk, createPrimaryKeySql);
- }
-
- //Turn on identity insert if db provider is not mysql
- if (SqlSyntax.SupportsIdentityInsert() && tableDefinition.Columns.Any(x => x.IsIdentity))
- _database.Execute(new Sql($"SET IDENTITY_INSERT {SqlSyntax.GetQuotedTableName(tableName)} ON "));
-
- //Call the NewTable-event to trigger the insert of base/default data
- //OnNewTable(tableName, _db, e, _logger);
-
- dataCreation.InitializeBaseData(tableName);
-
- //Turn off identity insert if db provider is not mysql
- if (SqlSyntax.SupportsIdentityInsert() && tableDefinition.Columns.Any(x => x.IsIdentity))
- _database.Execute(new Sql($"SET IDENTITY_INSERT {SqlSyntax.GetQuotedTableName(tableName)} OFF;"));
-
- //Special case for MySql
- if (SqlSyntax is MySqlSyntaxProvider && tableName.Equals("umbracoUser"))
- {
- _database.Update("SET id = @IdAfter WHERE id = @IdBefore AND userLogin = @Login", new { IdAfter = 0, IdBefore = 1, Login = "admin" });
- }
-
- //Loop through index statements and execute sql
- foreach (var sql in indexSql)
- {
- var createdIndex = _database.Execute(new Sql(sql));
- _logger.Info("Create Index ({CreatedIndex}):\n {Sql}", createdIndex, sql);
- }
-
- //Loop through foreignkey statements and execute sql
- foreach (var sql in foreignSql)
- {
- var createdFk = _database.Execute(new Sql(sql));
- _logger.Info("Create Foreign Key ({CreatedFk}):\n {Sql}", createdFk, sql);
- }
-
- if (overwrite)
- {
- _logger.Info("Table '{TableName}' was recreated", tableName);
- }
- else
- {
- _logger.Info("New table '{TableName}' was created", tableName);
- }
- }
-
- ///
- /// Drops the table for the specified .
- ///
- /// The type representing the DTO/table.
- ///
- ///
- /// schemaHelper.DropTable<MyDto>);
- ///
- ///
- ///
- /// If has been decorated with an , the name from that
- /// attribute will be used for the table name. If the attribute is not present, the name
- /// will be used instead.
- ///
- public void DropTable(string tableName)
- {
- var sql = new Sql(string.Format(SqlSyntax.DropTable, SqlSyntax.GetQuotedTableName(tableName)));
- _database.Execute(sql);
- }
-
- #endregion
- }
-}
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using NPoco;
+using Umbraco.Core.Events;
+using Umbraco.Core.Logging;
+using Umbraco.Core.Persistence;
+using Umbraco.Core.Persistence.DatabaseModelDefinitions;
+using Umbraco.Core.Persistence.Dtos;
+using Umbraco.Core.Persistence.SqlSyntax;
+
+namespace Umbraco.Core.Migrations.Install
+{
+ ///
+ /// Creates the initial database schema during install.
+ ///
+ public class DatabaseSchemaCreator
+ {
+ private readonly IUmbracoDatabase _database;
+ private readonly ILogger _logger;
+
+ public DatabaseSchemaCreator(IUmbracoDatabase database, ILogger logger)
+ {
+ _database = database;
+ _logger = logger;
+ }
+
+ private ISqlSyntaxProvider SqlSyntax => _database.SqlContext.SqlSyntax;
+
+ // all tables, in order
+ internal static readonly List OrderedTables = new List
+ {
+ typeof (UserDto),
+ typeof (NodeDto),
+ typeof (ContentTypeDto),
+ typeof (TemplateDto),
+ typeof (ContentDto),
+ typeof (ContentVersionDto),
+ typeof (MediaVersionDto),
+ typeof (DocumentDto),
+ typeof (ContentTypeTemplateDto),
+ typeof (DataTypeDto),
+ typeof (DictionaryDto),
+ typeof (LanguageDto),
+ typeof (LanguageTextDto),
+ typeof (DomainDto),
+ typeof (LogDto),
+ typeof (MacroDto),
+ typeof (MacroPropertyDto),
+ typeof (MemberTypeDto),
+ typeof (MemberDto),
+ typeof (Member2MemberGroupDto),
+ typeof (ContentXmlDto),
+ typeof (PreviewXmlDto),
+ typeof (PropertyTypeGroupDto),
+ typeof (PropertyTypeDto),
+ typeof (PropertyDataDto),
+ typeof (RelationTypeDto),
+ typeof (RelationDto),
+ typeof (TagDto),
+ typeof (TagRelationshipDto),
+ typeof (ContentType2ContentTypeDto),
+ typeof (ContentTypeAllowedContentTypeDto),
+ typeof (User2NodeNotifyDto),
+ typeof (ServerRegistrationDto),
+ typeof (AccessDto),
+ typeof (AccessRuleDto),
+ typeof (CacheInstructionDto),
+ typeof (ExternalLoginDto),
+ typeof (RedirectUrlDto),
+ typeof (LockDto),
+ typeof (UserGroupDto),
+ typeof (User2UserGroupDto),
+ typeof (UserGroup2NodePermissionDto),
+ typeof (UserGroup2AppDto),
+ typeof (UserStartNodeDto),
+ typeof (ContentNuDto),
+ typeof (DocumentVersionDto),
+ typeof (KeyValueDto),
+ typeof (UserLoginDto),
+ typeof (ConsentDto),
+ typeof (AuditEntryDto),
+ typeof (ContentVersionCultureVariationDto),
+ typeof (DocumentCultureVariationDto),
+ typeof (ContentScheduleDto)
+ };
+
+ ///
+ /// Drops all Umbraco tables in the db.
+ ///
+ internal void UninstallDatabaseSchema()
+ {
+ _logger.Info("Start UninstallDatabaseSchema");
+
+ foreach (var table in OrderedTables.AsEnumerable().Reverse())
+ {
+ var tableNameAttribute = table.FirstAttribute();
+ var tableName = tableNameAttribute == null ? table.Name : tableNameAttribute.Value;
+
+ _logger.Info("Uninstall {TableName}", tableName);
+
+ try
+ {
+ if (TableExists(tableName))
+ DropTable(tableName);
+ }
+ catch (Exception ex)
+ {
+ //swallow this for now, not sure how best to handle this with diff databases... though this is internal
+ // and only used for unit tests. If this fails its because the table doesn't exist... generally!
+ _logger.Error(ex, "Could not drop table {TableName}", tableName);
+ }
+ }
+ }
+
+ ///
+ /// Initializes the database by creating the umbraco db schema.
+ ///
+ /// This needs to execute as part of a transaction.
+ public void InitializeDatabaseSchema()
+ {
+ if (!_database.InTransaction)
+ throw new InvalidOperationException("Database is not in a transaction.");
+
+ var e = new DatabaseCreationEventArgs();
+ FireBeforeCreation(e);
+
+ if (e.Cancel == false)
+ {
+ var dataCreation = new DatabaseDataCreator(_database, _logger);
+ foreach (var table in OrderedTables)
+ CreateTable(false, table, dataCreation);
+ }
+
+ FireAfterCreation(e);
+ }
+
+ ///
+ /// Validates the schema of the current database.
+ ///
+ internal DatabaseSchemaResult ValidateSchema()
+ {
+ var result = new DatabaseSchemaResult(SqlSyntax);
+
+ result.IndexDefinitions.AddRange(SqlSyntax.GetDefinedIndexes(_database)
+ .Select(x => new DbIndexDefinition(x)));
+
+ result.TableDefinitions.AddRange(OrderedTables
+ .Select(x => DefinitionFactory.GetTableDefinition(x, SqlSyntax)));
+
+ ValidateDbTables(result);
+ ValidateDbColumns(result);
+ ValidateDbIndexes(result);
+ ValidateDbConstraints(result);
+
+ return result;
+ }
+
+ ///
+ /// This validates the Primary/Foreign keys in the database
+ ///
+ ///
+ ///
+ /// This does not validate any database constraints that are not PKs or FKs because Umbraco does not create a database with non PK/FK constraints.
+ /// Any unique "constraints" in the database are done with unique indexes.
+ ///
+ private void ValidateDbConstraints(DatabaseSchemaResult result)
+ {
+ //Check constraints in configured database against constraints in schema
+ var constraintsInDatabase = SqlSyntax.GetConstraintsPerColumn(_database).DistinctBy(x => x.Item3).ToList();
+ var foreignKeysInDatabase = constraintsInDatabase.Where(x => x.Item3.InvariantStartsWith("FK_")).Select(x => x.Item3).ToList();
+ var primaryKeysInDatabase = constraintsInDatabase.Where(x => x.Item3.InvariantStartsWith("PK_")).Select(x => x.Item3).ToList();
+
+ var unknownConstraintsInDatabase =
+ constraintsInDatabase.Where(
+ x =>
+ 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))
+ .Where(x => x.IsNullOrWhiteSpace() == false).ToList();
+
+ // Add valid and invalid foreign key differences to the result object
+ // We'll need to do invariant contains with case insensitivity because foreign key, primary key is not standardized
+ // In theory you could have: FK_ or fk_ ...or really any standard that your development department (or developer) chooses to use.
+ foreach (var unknown in unknownConstraintsInDatabase)
+ {
+ if (foreignKeysInSchema.InvariantContains(unknown) || primaryKeysInSchema.InvariantContains(unknown))
+ {
+ result.ValidConstraints.Add(unknown);
+ }
+ else
+ {
+ result.Errors.Add(new Tuple("Unknown", unknown));
+ }
+ }
+
+ //Foreign keys:
+
+ var validForeignKeyDifferences = foreignKeysInDatabase.Intersect(foreignKeysInSchema, StringComparer.InvariantCultureIgnoreCase);
+ foreach (var foreignKey in validForeignKeyDifferences)
+ {
+ result.ValidConstraints.Add(foreignKey);
+ }
+ var invalidForeignKeyDifferences =
+ foreignKeysInDatabase.Except(foreignKeysInSchema, StringComparer.InvariantCultureIgnoreCase)
+ .Union(foreignKeysInSchema.Except(foreignKeysInDatabase, StringComparer.InvariantCultureIgnoreCase));
+ foreach (var foreignKey in invalidForeignKeyDifferences)
+ {
+ result.Errors.Add(new Tuple("Constraint", foreignKey));
+ }
+
+
+ //Primary keys:
+
+ //Add valid and invalid primary key differences to the result object
+ var validPrimaryKeyDifferences = primaryKeysInDatabase.Intersect(primaryKeysInSchema, StringComparer.InvariantCultureIgnoreCase);
+ foreach (var primaryKey in validPrimaryKeyDifferences)
+ {
+ result.ValidConstraints.Add(primaryKey);
+ }
+ var invalidPrimaryKeyDifferences =
+ primaryKeysInDatabase.Except(primaryKeysInSchema, StringComparer.InvariantCultureIgnoreCase)
+ .Union(primaryKeysInSchema.Except(primaryKeysInDatabase, StringComparer.InvariantCultureIgnoreCase));
+ foreach (var primaryKey in invalidPrimaryKeyDifferences)
+ {
+ result.Errors.Add(new Tuple("Constraint", primaryKey));
+ }
+
+ }
+
+ private void ValidateDbColumns(DatabaseSchemaResult result)
+ {
+ //Check columns in configured database against columns in schema
+ var columnsInDatabase = SqlSyntax.GetColumnsInSchema(_database);
+ var columnsPerTableInDatabase = columnsInDatabase.Select(x => string.Concat(x.TableName, ",", x.ColumnName)).ToList();
+ var columnsPerTableInSchema = result.TableDefinitions.SelectMany(x => x.Columns.Select(y => string.Concat(y.TableName, ",", y.Name))).ToList();
+ //Add valid and invalid column differences to the result object
+ var validColumnDifferences = columnsPerTableInDatabase.Intersect(columnsPerTableInSchema, StringComparer.InvariantCultureIgnoreCase);
+ foreach (var column in validColumnDifferences)
+ {
+ result.ValidColumns.Add(column);
+ }
+
+ var invalidColumnDifferences =
+ columnsPerTableInDatabase.Except(columnsPerTableInSchema, StringComparer.InvariantCultureIgnoreCase)
+ .Union(columnsPerTableInSchema.Except(columnsPerTableInDatabase, StringComparer.InvariantCultureIgnoreCase));
+ foreach (var column in invalidColumnDifferences)
+ {
+ result.Errors.Add(new Tuple("Column", column));
+ }
+ }
+
+ private void ValidateDbTables(DatabaseSchemaResult result)
+ {
+ //Check tables in configured database against tables in schema
+ var tablesInDatabase = SqlSyntax.GetTablesInSchema(_database).ToList();
+ var tablesInSchema = result.TableDefinitions.Select(x => x.Name).ToList();
+ //Add valid and invalid table differences to the result object
+ var validTableDifferences = tablesInDatabase.Intersect(tablesInSchema, StringComparer.InvariantCultureIgnoreCase);
+ foreach (var tableName in validTableDifferences)
+ {
+ result.ValidTables.Add(tableName);
+ }
+
+ var invalidTableDifferences =
+ tablesInDatabase.Except(tablesInSchema, StringComparer.InvariantCultureIgnoreCase)
+ .Union(tablesInSchema.Except(tablesInDatabase, StringComparer.InvariantCultureIgnoreCase));
+ foreach (var tableName in invalidTableDifferences)
+ {
+ result.Errors.Add(new Tuple("Table", tableName));
+ }
+ }
+
+ 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.IndexDefinitions.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
+ var validColIndexDifferences = colIndexesInDatabase.Intersect(indexesInSchema, StringComparer.InvariantCultureIgnoreCase);
+ foreach (var index in validColIndexDifferences)
+ {
+ result.ValidIndexes.Add(index);
+ }
+
+ var invalidColIndexDifferences =
+ colIndexesInDatabase.Except(indexesInSchema, StringComparer.InvariantCultureIgnoreCase)
+ .Union(indexesInSchema.Except(colIndexesInDatabase, StringComparer.InvariantCultureIgnoreCase));
+ foreach (var index in invalidColIndexDifferences)
+ {
+ result.Errors.Add(new Tuple("Index", index));
+ }
+ }
+
+ #region Events
+
+ ///
+ /// The save event handler
+ ///
+ internal delegate void DatabaseEventHandler(DatabaseCreationEventArgs e);
+
+ ///
+ /// Occurs when [before save].
+ ///
+ internal static event DatabaseEventHandler BeforeCreation;
+ ///
+ /// Raises the event.
+ ///
+ /// The instance containing the event data.
+ internal virtual void FireBeforeCreation(DatabaseCreationEventArgs e)
+ {
+ BeforeCreation?.Invoke(e);
+ }
+
+ ///
+ /// Occurs when [after save].
+ ///
+ internal static event DatabaseEventHandler AfterCreation;
+ ///
+ /// Raises the event.
+ ///
+ /// The instance containing the event data.
+ internal virtual void FireAfterCreation(DatabaseCreationEventArgs e)
+ {
+ AfterCreation?.Invoke(e);
+ }
+
+ #endregion
+
+ #region Utilities
+
+ ///
+ /// Returns whether a table with the specified exists in the database.
+ ///
+ /// The name of the table.
+ /// true if the table exists; otherwise false.
+ ///
+ ///
+ /// if (schemaHelper.TableExist("MyTable"))
+ /// {
+ /// // do something when the table exists
+ /// }
+ ///
+ ///
+ public bool TableExists(string tableName)
+ {
+ return SqlSyntax.DoesTableExist(_database, tableName);
+ }
+
+ ///
+ /// Returns whether the table for the specified exists in the database.
+ ///
+ /// The type representing the DTO/table.
+ /// true if the table exists; otherwise false.
+ ///
+ ///
+ /// if (schemaHelper.TableExist<MyDto>)
+ /// {
+ /// // do something when the table exists
+ /// }
+ ///
+ ///
+ ///
+ /// If has been decorated with an , the name from that
+ /// attribute will be used for the table name. If the attribute is not present, the name
+ /// will be used instead.
+ ///
+ public bool TableExists()
+ {
+ var table = DefinitionFactory.GetTableDefinition(typeof(T), SqlSyntax);
+ return table != null && TableExists(table.Name);
+ }
+
+ ///
+ /// Creates a new table in the database based on the type of .
+ ///
+ /// The type representing the DTO/table.
+ /// Whether the table should be overwritten if it already exists.
+ ///
+ /// If has been decorated with an , the name from that
+ /// attribute will be used for the table name. If the attribute is not present, the name
+ /// will be used instead.
+ ///
+ /// If a table with the same name already exists, the parameter will determine
+ /// whether the table is overwritten. If true, the table will be overwritten, whereas this method will
+ /// not do anything if the parameter is false.
+ ///
+ internal void CreateTable(bool overwrite = false)
+ where T : new()
+ {
+ var tableType = typeof(T);
+ CreateTable(overwrite, tableType, new DatabaseDataCreator(_database, _logger));
+ }
+
+ ///
+ /// Creates a new table in the database for the specified .
+ ///
+ /// Whether the table should be overwritten if it already exists.
+ /// The representing the table.
+ ///
+ ///
+ /// If has been decorated with an , the name from
+ /// that attribute will be used for the table name. If the attribute is not present, the name
+ /// will be used instead.
+ ///
+ /// If a table with the same name already exists, the parameter will determine
+ /// whether the table is overwritten. If true, the table will be overwritten, whereas this method will
+ /// not do anything if the parameter is false.
+ ///
+ /// This need to execute as part of a transaction.
+ ///
+ internal void CreateTable(bool overwrite, Type modelType, DatabaseDataCreator dataCreation)
+ {
+ if (!_database.InTransaction)
+ throw new InvalidOperationException("Database is not in a transaction.");
+
+ var tableDefinition = DefinitionFactory.GetTableDefinition(modelType, SqlSyntax);
+ var tableName = tableDefinition.Name;
+
+ var createSql = SqlSyntax.Format(tableDefinition);
+ var createPrimaryKeySql = SqlSyntax.FormatPrimaryKey(tableDefinition);
+ var foreignSql = SqlSyntax.Format(tableDefinition.ForeignKeys);
+ var indexSql = SqlSyntax.Format(tableDefinition.Indexes);
+
+ var tableExist = TableExists(tableName);
+ if (overwrite && tableExist)
+ {
+ _logger.Info("Table {TableName} already exists, but will be recreated", tableName);
+
+ DropTable(tableName);
+ tableExist = false;
+ }
+
+ if (tableExist)
+ {
+ // The table exists and was not recreated/overwritten.
+ _logger.Info("Table {TableName} already exists - no changes were made", tableName);
+ return;
+ }
+
+ //Execute the Create Table sql
+ var created = _database.Execute(new Sql(createSql));
+ _logger.Info("Create Table {TableName} ({Created}): \n {Sql}", tableName, created, createSql);
+
+ //If any statements exists for the primary key execute them here
+ if (string.IsNullOrEmpty(createPrimaryKeySql) == false)
+ {
+ var createdPk = _database.Execute(new Sql(createPrimaryKeySql));
+ _logger.Info("Create Primary Key ({CreatedPk}):\n {Sql}", createdPk, createPrimaryKeySql);
+ }
+
+ if (SqlSyntax.SupportsIdentityInsert() && tableDefinition.Columns.Any(x => x.IsIdentity))
+ _database.Execute(new Sql($"SET IDENTITY_INSERT {SqlSyntax.GetQuotedTableName(tableName)} ON "));
+
+ //Call the NewTable-event to trigger the insert of base/default data
+ //OnNewTable(tableName, _db, e, _logger);
+
+ dataCreation.InitializeBaseData(tableName);
+
+ if (SqlSyntax.SupportsIdentityInsert() && tableDefinition.Columns.Any(x => x.IsIdentity))
+ _database.Execute(new Sql($"SET IDENTITY_INSERT {SqlSyntax.GetQuotedTableName(tableName)} OFF;"));
+
+ //Loop through index statements and execute sql
+ foreach (var sql in indexSql)
+ {
+ var createdIndex = _database.Execute(new Sql(sql));
+ _logger.Info("Create Index ({CreatedIndex}):\n {Sql}", createdIndex, sql);
+ }
+
+ //Loop through foreignkey statements and execute sql
+ foreach (var sql in foreignSql)
+ {
+ var createdFk = _database.Execute(new Sql(sql));
+ _logger.Info("Create Foreign Key ({CreatedFk}):\n {Sql}", createdFk, sql);
+ }
+
+ if (overwrite)
+ {
+ _logger.Info("Table {TableName} was recreated", tableName);
+ }
+ else
+ {
+ _logger.Info("New table {TableName} was created", tableName);
+
+ }
+ }
+
+ ///
+ /// Drops the table for the specified .
+ ///
+ /// The type representing the DTO/table.
+ ///
+ ///
+ /// schemaHelper.DropTable<MyDto>);
+ ///
+ ///
+ ///
+ /// If has been decorated with an , the name from that
+ /// attribute will be used for the table name. If the attribute is not present, the name
+ /// will be used instead.
+ ///
+ public void DropTable(string tableName)
+ {
+ var sql = new Sql(string.Format(SqlSyntax.DropTable, SqlSyntax.GetQuotedTableName(tableName)));
+ _database.Execute(sql);
+ }
+
+ #endregion
+ }
+}
diff --git a/src/Umbraco.Core/Migrations/Install/DatabaseSchemaResult.cs b/src/Umbraco.Core/Migrations/Install/DatabaseSchemaResult.cs
index 4c68addebc..f21216fde3 100644
--- a/src/Umbraco.Core/Migrations/Install/DatabaseSchemaResult.cs
+++ b/src/Umbraco.Core/Migrations/Install/DatabaseSchemaResult.cs
@@ -12,12 +12,8 @@ namespace Umbraco.Core.Migrations.Install
///
internal class DatabaseSchemaResult
{
- private readonly bool _isMySql;
-
public DatabaseSchemaResult(ISqlSyntaxProvider sqlSyntax)
{
- _isMySql = sqlSyntax is MySqlSyntaxProvider;
-
Errors = new List>();
TableDefinitions = new List();
ValidTables = new List();
@@ -31,7 +27,7 @@ namespace Umbraco.Core.Migrations.Install
public List TableDefinitions { get; }
- // fixme TableDefinitions are those that should be there, IndexDefinitions are those that... are in DB?
+ // TODO: what are these exactly? TableDefinitions are those that should be there, IndexDefinitions are those that... are in DB?
internal List IndexDefinitions { get; }
public List ValidTables { get; }
@@ -102,11 +98,6 @@ namespace Umbraco.Core.Migrations.Install
sb.AppendLine(" ");
}
- if (_isMySql)
- {
- sb.AppendLine("Please note that the constraints could not be validated because the current data provider is MySql.");
- }
-
return sb.ToString();
}
}
diff --git a/src/Umbraco.Core/Migrations/MigrationBase_Extra.cs b/src/Umbraco.Core/Migrations/MigrationBase_Extra.cs
index 9e13badacf..6d936e8407 100644
--- a/src/Umbraco.Core/Migrations/MigrationBase_Extra.cs
+++ b/src/Umbraco.Core/Migrations/MigrationBase_Extra.cs
@@ -98,14 +98,12 @@ namespace Umbraco.Core.Migrations
protected bool ColumnExists(string tableName, string columnName)
{
- // that's ok even on MySql
var columns = SqlSyntax.GetColumnsInSchema(Context.Database).Distinct().ToArray();
return columns.Any(x => x.TableName.InvariantEquals(tableName) && x.ColumnName.InvariantEquals(columnName));
}
protected string ColumnType(string tableName, string columnName)
{
- // that's ok even on MySql
var columns = SqlSyntax.GetColumnsInSchema(Context.Database).Distinct().ToArray();
var column = columns.FirstOrDefault(x => x.TableName.InvariantEquals(tableName) && x.ColumnName.InvariantEquals(columnName));
return column?.DataType;
diff --git a/src/Umbraco.Core/Migrations/MigrationPlan.cs b/src/Umbraco.Core/Migrations/MigrationPlan.cs
index 85d9c1d2cc..9ede9f04f2 100644
--- a/src/Umbraco.Core/Migrations/MigrationPlan.cs
+++ b/src/Umbraco.Core/Migrations/MigrationPlan.cs
@@ -61,7 +61,7 @@ namespace Umbraco.Core.Migrations
// register the target state if we don't know it already
// this is how we keep track of the final state - because
// transitions could be defined in any order, that might
- // be overriden afterwards.
+ // be overridden afterwards.
if (!_transitions.ContainsKey(targetState))
_transitions.Add(targetState, null);
diff --git a/src/Umbraco.Core/Migrations/Upgrade/UmbracoPlan.cs b/src/Umbraco.Core/Migrations/Upgrade/UmbracoPlan.cs
index 833955ee6a..9bf58c8d2f 100644
--- a/src/Umbraco.Core/Migrations/Upgrade/UmbracoPlan.cs
+++ b/src/Umbraco.Core/Migrations/Upgrade/UmbracoPlan.cs
@@ -124,6 +124,8 @@ namespace Umbraco.Core.Migrations.Upgrade
To("{64EBCE53-E1F0-463A-B40B-E98EFCCA8AE2}");
To("{0009109C-A0B8-4F3F-8FEB-C137BBDDA268}");
To("{8A027815-D5CD-4872-8B88-9A51AB5986A6}"); // from 7.14.0
+ To("{ED28B66A-E248-4D94-8CDB-9BDF574023F0}");
+ To("{38C809D5-6C34-426B-9BEA-EFD39162595C}");
//FINAL
diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_7_10_0/RenamePreviewFolder.cs b/src/Umbraco.Core/Migrations/Upgrade/V_7_10_0/RenamePreviewFolder.cs
index a73fb8a325..48e6d0085d 100644
--- a/src/Umbraco.Core/Migrations/Upgrade/V_7_10_0/RenamePreviewFolder.cs
+++ b/src/Umbraco.Core/Migrations/Upgrade/V_7_10_0/RenamePreviewFolder.cs
@@ -5,7 +5,7 @@ using File = System.IO.File;
namespace Umbraco.Core.Migrations.Upgrade.V_7_10_0
{
///
- /// Renames the preview folder containing static html files to ensure it does not interfere with the MVC route
+ /// Renames the preview folder containing static HTML files to ensure it does not interfere with the MVC route
/// that is now supposed to render these views dynamically. We don't want to delete as people may have made
/// customizations to these files that would need to be migrated to the new .cshtml view files.
///
@@ -25,7 +25,7 @@ namespace Umbraco.Core.Migrations.Upgrade.V_7_10_0
{
Directory.Move(previewFolderPath, newPath);
var readmeText =
- $"Static html files used for preview and canvas editing functionality no longer live in this directory.\r\n" +
+ $"Static HTML files used for preview and canvas editing functionality no longer live in this directory.\r\n" +
$"Instead they have been recreated as MVC views and can now be found in '~/Umbraco/Views/Preview'.\r\n" +
$"See issue: http://issues.umbraco.org/issue/U4-11090";
File.WriteAllText(Path.Combine(newPath, "readme.txt"), readmeText);
diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_7_5_0/UpdateUniqueIndexOnPropertyData.cs b/src/Umbraco.Core/Migrations/Upgrade/V_7_5_0/UpdateUniqueIndexOnPropertyData.cs
index 73f03e96c6..8c688cfd28 100644
--- a/src/Umbraco.Core/Migrations/Upgrade/V_7_5_0/UpdateUniqueIndexOnPropertyData.cs
+++ b/src/Umbraco.Core/Migrations/Upgrade/V_7_5_0/UpdateUniqueIndexOnPropertyData.cs
@@ -27,25 +27,7 @@ namespace Umbraco.Core.Migrations.Upgrade.V_7_5_0
if (found != null)
{
- //Check for MySQL
- if (DatabaseType.IsMySql())
- {
- //Use the special double nested sub query for MySQL since that is the only
- //way delete sub queries works
- var delPropQry = SqlSyntax.GetDeleteSubquery(
- "cmsPropertyData",
- "id",
- Sql("SELECT MIN(id) FROM cmsPropertyData GROUP BY nodeId, versionId, propertytypeid HAVING MIN(id) IS NOT NULL"),
- WhereInType.NotIn);
- Database.Execute(delPropQry.SQL);
- }
- else
- {
- //NOTE: Even though the above will work for MSSQL, we are not going to execute the
- // nested delete sub query logic since it will be slower and there could be a ton of property
- // data here so needs to be as fast as possible.
- Database.Execute("DELETE FROM cmsPropertyData WHERE id NOT IN (SELECT MIN(id) FROM cmsPropertyData GROUP BY nodeId, versionId, propertytypeid HAVING MIN(id) IS NOT NULL)");
- }
+ Database.Execute("DELETE FROM cmsPropertyData WHERE id NOT IN (SELECT MIN(id) FROM cmsPropertyData GROUP BY nodeId, versionId, propertytypeid HAVING MIN(id) IS NOT NULL)");
//we need to re create this index
Delete.Index("IX_cmsPropertyData_1").OnTable("cmsPropertyData").Do();
diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_7_6_0/AddIndexToCmsMemberLoginName.cs b/src/Umbraco.Core/Migrations/Upgrade/V_7_6_0/AddIndexToCmsMemberLoginName.cs
index 05abc5ec83..a223d76a07 100644
--- a/src/Umbraco.Core/Migrations/Upgrade/V_7_6_0/AddIndexToCmsMemberLoginName.cs
+++ b/src/Umbraco.Core/Migrations/Upgrade/V_7_6_0/AddIndexToCmsMemberLoginName.cs
@@ -16,9 +16,7 @@ namespace Umbraco.Core.Migrations.Upgrade.V_7_6_0
//Now we need to check if we can actually d6 this because we won't be able to if there's data in there that is too long
//http://issues.umbraco.org/issue/U4-9758
- var colLen = SqlSyntax is MySqlSyntaxProvider
- ? database.ExecuteScalar("select max(LENGTH(LoginName)) from cmsMember")
- : database.ExecuteScalar("select max(datalength(LoginName)) from cmsMember");
+ var colLen = database.ExecuteScalar("select max(datalength(LoginName)) from cmsMember");
if (colLen < 900 == false && colLen != null)
{
diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_7_6_0/AddIndexesToUmbracoRelationTables.cs b/src/Umbraco.Core/Migrations/Upgrade/V_7_6_0/AddIndexesToUmbracoRelationTables.cs
index 17dd060376..9042ae105e 100644
--- a/src/Umbraco.Core/Migrations/Upgrade/V_7_6_0/AddIndexesToUmbracoRelationTables.cs
+++ b/src/Umbraco.Core/Migrations/Upgrade/V_7_6_0/AddIndexesToUmbracoRelationTables.cs
@@ -18,7 +18,7 @@ namespace Umbraco.Core.Migrations.Upgrade.V_7_6_0
if (dbIndexes.Any(x => x.IndexName.InvariantEquals("IX_umbracoRelation_parentChildType")) == false)
{
//This will remove any corrupt/duplicate data in the relation table before the index is applied
- //Ensure this executes in a defered block which will be done inside of the migration transaction
+ //Ensure this executes in a deferred block which will be done inside of the migration transaction
var database = Database;
//We need to check if this index has corrupted data and then clear that data
diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_7_6_0/ReduceLoginNameColumnsSize.cs b/src/Umbraco.Core/Migrations/Upgrade/V_7_6_0/ReduceLoginNameColumnsSize.cs
index 30ee91300d..1af21617f3 100644
--- a/src/Umbraco.Core/Migrations/Upgrade/V_7_6_0/ReduceLoginNameColumnsSize.cs
+++ b/src/Umbraco.Core/Migrations/Upgrade/V_7_6_0/ReduceLoginNameColumnsSize.cs
@@ -17,9 +17,7 @@ namespace Umbraco.Core.Migrations.Upgrade.V_7_6_0
var database = Database;
var dbIndexes = SqlSyntax.GetDefinedIndexesDefinitions(database);
- var colLen = (SqlSyntax is MySqlSyntaxProvider)
- ? database.ExecuteScalar("select max(LENGTH(LoginName)) from cmsMember")
- : database.ExecuteScalar("select max(datalength(LoginName)) from cmsMember");
+ var colLen = database.ExecuteScalar("select max(datalength(LoginName)) from cmsMember");
if (colLen < 900 == false) return;
diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_7_7_0/AddIndexToDictionaryKeyColumn.cs b/src/Umbraco.Core/Migrations/Upgrade/V_7_7_0/AddIndexToDictionaryKeyColumn.cs
index 700702204c..b366c7dab9 100644
--- a/src/Umbraco.Core/Migrations/Upgrade/V_7_7_0/AddIndexToDictionaryKeyColumn.cs
+++ b/src/Umbraco.Core/Migrations/Upgrade/V_7_7_0/AddIndexToDictionaryKeyColumn.cs
@@ -13,9 +13,7 @@ namespace Umbraco.Core.Migrations.Upgrade.V_7_7_0
{
var database = Database;
//Now we need to check if we can actually do this because we won't be able to if there's data in there that is too long
- var colLen = (SqlSyntax is MySqlSyntaxProvider)
- ? database.ExecuteScalar(string.Format("select max(LENGTH({0})) from cmsDictionary", SqlSyntax.GetQuotedColumnName("key")))
- : database.ExecuteScalar(string.Format("select max(datalength({0})) from cmsDictionary", SqlSyntax.GetQuotedColumnName("key")));
+ var colLen = database.ExecuteScalar(string.Format("select max(datalength({0})) from cmsDictionary", SqlSyntax.GetQuotedColumnName("key")));
if (colLen < 900 == false && colLen != null)
{
diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_7_7_0/AddUserGroupTables.cs b/src/Umbraco.Core/Migrations/Upgrade/V_7_7_0/AddUserGroupTables.cs
index 35df178672..edd78e6c84 100644
--- a/src/Umbraco.Core/Migrations/Upgrade/V_7_7_0/AddUserGroupTables.cs
+++ b/src/Umbraco.Core/Migrations/Upgrade/V_7_7_0/AddUserGroupTables.cs
@@ -4,7 +4,6 @@ using System.Data;
using System.Linq;
using Umbraco.Core.Persistence;
using Umbraco.Core.Persistence.Dtos;
-using Umbraco.Core.Persistence.SqlSyntax;
using ColumnInfo = Umbraco.Core.Persistence.SqlSyntax.ColumnInfo;
namespace Umbraco.Core.Migrations.Upgrade.V_7_7_0
@@ -19,9 +18,7 @@ namespace Umbraco.Core.Migrations.Upgrade.V_7_7_0
//For some of the migration data inserts we require to use a special MSSQL collate expression since
//some databases may have a custom collation specified and if that is the case, when we compare strings
//in dynamic SQL it will try to compare strings in different collations and this will yield errors.
- _collateSyntax = SqlSyntax is MySqlSyntaxProvider || SqlSyntax is SqlCeSyntaxProvider
- ? string.Empty
- : "COLLATE DATABASE_DEFAULT";
+ _collateSyntax = "COLLATE DATABASE_DEFAULT";
}
public override void Migrate()
@@ -30,7 +27,7 @@ namespace Umbraco.Core.Migrations.Upgrade.V_7_7_0
var constraints = SqlSyntax.GetConstraintsPerColumn(Context.Database).Distinct().ToArray();
var columns = SqlSyntax.GetColumnsInSchema(Context.Database).ToArray();
- //In some very rare cases, there might alraedy be user group tables that we'll need to remove first
+ //In some very rare cases, there might already be user group tables that we'll need to remove first
//but of course we don't want to remove the tables we will be creating below if they already exist so
//need to do some checks first since these old rare tables have a different schema
RemoveOldTablesIfExist(tables, columns);
@@ -86,7 +83,7 @@ namespace Umbraco.Core.Migrations.Upgrade.V_7_7_0
}
///
- /// In some very rare cases, there might alraedy be user group tables that we'll need to remove first
+ /// In some very rare cases, there might already be user group tables that we'll need to remove first
/// but of course we don't want to remove the tables we will be creating below if they already exist so
/// need to do some checks first since these old rare tables have a different schema
///
@@ -340,24 +337,16 @@ namespace Umbraco.Core.Migrations.Upgrade.V_7_7_0
if (tables.InvariantContains("umbracoUserType") && tables.InvariantContains("umbracoUser"))
{
- if (DatabaseType.IsMySql())
+ //Delete the FK if it exists before dropping the column
+ if (constraints.Any(x => x.Item1.InvariantEquals("umbracoUser") && x.Item3.InvariantEquals("FK_umbracoUser_umbracoUserType_id")))
{
- //In MySql, this will drop the FK according to it's special naming rules
- Delete.ForeignKey().FromTable("umbracoUser").ForeignColumn("userType").ToTable("umbracoUserType").PrimaryColumn("id");
+ Delete.ForeignKey("FK_umbracoUser_umbracoUserType_id").OnTable("umbracoUser").Do();
}
- else
- {
- //Delete the FK if it exists before dropping the column
- if (constraints.Any(x => x.Item1.InvariantEquals("umbracoUser") && x.Item3.InvariantEquals("FK_umbracoUser_umbracoUserType_id")))
- {
- Delete.ForeignKey("FK_umbracoUser_umbracoUserType_id").OnTable("umbracoUser").Do();
- }
- //This is the super old constraint name of the FK for user type so check this one too
- if (constraints.Any(x => x.Item1.InvariantEquals("umbracoUser") && x.Item3.InvariantEquals("FK_user_userType")))
- {
- Delete.ForeignKey("FK_user_userType").OnTable("umbracoUser").Do();
- }
+ //This is the super old constraint name of the FK for user type so check this one too
+ if (constraints.Any(x => x.Item1.InvariantEquals("umbracoUser") && x.Item3.InvariantEquals("FK_user_userType")))
+ {
+ Delete.ForeignKey("FK_user_userType").OnTable("umbracoUser").Do();
}
Delete.Column("userType").FromTable("umbracoUser").Do();
diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_7_7_0/ReduceDictionaryKeyColumnsSize.cs b/src/Umbraco.Core/Migrations/Upgrade/V_7_7_0/ReduceDictionaryKeyColumnsSize.cs
index 9f84320620..17dd3064eb 100644
--- a/src/Umbraco.Core/Migrations/Upgrade/V_7_7_0/ReduceDictionaryKeyColumnsSize.cs
+++ b/src/Umbraco.Core/Migrations/Upgrade/V_7_7_0/ReduceDictionaryKeyColumnsSize.cs
@@ -16,9 +16,7 @@ namespace Umbraco.Core.Migrations.Upgrade.V_7_7_0
var database = Database;
var dbIndexes = SqlSyntax.GetDefinedIndexesDefinitions(database);
- var colLen = SqlSyntax is MySqlSyntaxProvider
- ? database.ExecuteScalar(string.Format("select max(LENGTH({0})) from cmsDictionary", SqlSyntax.GetQuotedColumnName("key")))
- : database.ExecuteScalar(string.Format("select max(datalength({0})) from cmsDictionary", SqlSyntax.GetQuotedColumnName("key")));
+ var colLen = database.ExecuteScalar(string.Format("select max(datalength({0})) from cmsDictionary", SqlSyntax.GetQuotedColumnName("key")));
if (colLen < 900 == false) return;
diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_7_7_0/UpdateUserTables.cs b/src/Umbraco.Core/Migrations/Upgrade/V_7_7_0/UpdateUserTables.cs
index 3714427cd7..509b3f91dd 100644
--- a/src/Umbraco.Core/Migrations/Upgrade/V_7_7_0/UpdateUserTables.cs
+++ b/src/Umbraco.Core/Migrations/Upgrade/V_7_7_0/UpdateUserTables.cs
@@ -14,7 +14,7 @@ namespace Umbraco.Core.Migrations.Upgrade.V_7_7_0
public override void Migrate()
{
- //Don't exeucte if the column is already there
+ //Don't execute if the column is already there
var columns = SqlSyntax.GetColumnsInSchema(Context.Database).ToArray();
if (columns.Any(x => x.TableName.InvariantEquals("umbracoUser") && x.ColumnName.InvariantEquals("createDate")) == false)
diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/AddVariationTables1A.cs b/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/AddVariationTables1A.cs
index 96e82d281d..34648d402a 100644
--- a/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/AddVariationTables1A.cs
+++ b/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/AddVariationTables1A.cs
@@ -40,8 +40,6 @@ namespace Umbraco.Core.Migrations.Upgrade.V_8_0_0
AlterColumn(Constants.DatabaseSchema.Tables.ContentVersionCultureVariation, "languageId");
Create.Table().Do();
-
- // fixme - data migration?
}
}
}
diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/AddVariationTables2.cs b/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/AddVariationTables2.cs
index 5b6c913195..c6cad2eac1 100644
--- a/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/AddVariationTables2.cs
+++ b/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/AddVariationTables2.cs
@@ -13,8 +13,6 @@ namespace Umbraco.Core.Migrations.Upgrade.V_8_0_0
{
Create.Table().Do();
Create.Table().Do();
-
- // fixme - data migration?
}
}
}
diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/ConvertRelatedLinksToMultiUrlPicker.cs b/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/ConvertRelatedLinksToMultiUrlPicker.cs
new file mode 100644
index 0000000000..ed1c08f0f8
--- /dev/null
+++ b/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/ConvertRelatedLinksToMultiUrlPicker.cs
@@ -0,0 +1,139 @@
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.Serialization;
+using Newtonsoft.Json;
+using Umbraco.Core.Logging;
+using Umbraco.Core.Models.PublishedContent;
+using Umbraco.Core.Persistence;
+using Umbraco.Core.Persistence.Dtos;
+
+namespace Umbraco.Core.Migrations.Upgrade.V_8_0_0
+{
+ public class ConvertRelatedLinksToMultiUrlPicker : MigrationBase
+ {
+ public ConvertRelatedLinksToMultiUrlPicker(IMigrationContext context) : base(context)
+ { }
+
+ public override void Migrate()
+ {
+ var sqlDataTypes = Sql()
+ .Select()
+ .From()
+ .Where(x => x.EditorAlias == "Umbraco.RelatedLinks"
+ || x.EditorAlias == "Umbraco.RelatedLinks2");
+
+ var dataTypes = Database.Fetch(sqlDataTypes);
+ var dataTypeIds = dataTypes.Select(x => x.NodeId).ToList();
+
+ if (dataTypeIds.Count == 0) return;
+
+ foreach (var dataType in dataTypes)
+ {
+ dataType.EditorAlias = Constants.PropertyEditors.Aliases.MultiUrlPicker;
+ Database.Update(dataType);
+ }
+
+ var sqlPropertyTpes = Sql()
+ .Select()
+ .From()
+ .Where(x => dataTypeIds.Contains(x.DataTypeId));
+
+ var propertyTypeIds = Database.Fetch(sqlPropertyTpes).Select(x => x.Id).ToList();
+
+ if (propertyTypeIds.Count == 0) return;
+
+ var sqlPropertyData = Sql()
+ .Select()
+ .From()
+ .Where(x => propertyTypeIds.Contains(x.PropertyTypeId));
+
+ var properties = Database.Fetch(sqlPropertyData);
+
+ // Create a Multi URL Picker datatype for the converted RelatedLinks data
+
+ foreach (var property in properties)
+ {
+ var value = property.Value.ToString();
+ if (string.IsNullOrWhiteSpace(value))
+ continue;
+
+ var relatedLinks = JsonConvert.DeserializeObject>(value);
+ var links = new List();
+ foreach (var relatedLink in relatedLinks)
+ {
+ GuidUdi udi = null;
+ if (relatedLink.IsInternal)
+ {
+ var linkIsUdi = GuidUdi.TryParse(relatedLink.Link, out udi);
+ if (linkIsUdi == false)
+ {
+ // oh no.. probably an integer, yikes!
+ if (int.TryParse(relatedLink.Link, out var intId))
+ {
+ var sqlNodeData = Sql()
+ .Select()
+ .Where(x => x.NodeId == intId);
+
+ var node = Database.Fetch(sqlNodeData).FirstOrDefault();
+ if (node != null)
+ // Note: RelatedLinks did not allow for picking media items,
+ // so if there's a value this will be a content item - hence
+ // the hardcoded "document" here
+ udi = new GuidUdi("document", node.UniqueId);
+ }
+ }
+ }
+
+ var link = new LinkDto
+ {
+ Name = relatedLink.Caption,
+ Target = relatedLink.NewWindow ? "_blank" : null,
+ Udi = udi,
+ // Should only have a URL if it's an external link otherwise it wil be a UDI
+ Url = relatedLink.IsInternal == false ? relatedLink.Link : null
+ };
+
+ links.Add(link);
+ }
+
+ var json = JsonConvert.SerializeObject(links);
+
+ // Update existing data
+ property.TextValue = json;
+ Database.Update(property);
+ }
+
+
+ }
+ }
+
+ internal class RelatedLink
+ {
+ public int? Id { get; internal set; }
+ internal bool IsDeleted { get; set; }
+ [JsonProperty("caption")]
+ public string Caption { get; set; }
+ [JsonProperty("link")]
+ public string Link { get; set; }
+ [JsonProperty("newWindow")]
+ public bool NewWindow { get; set; }
+ [JsonProperty("isInternal")]
+ public bool IsInternal { get; set; }
+ }
+
+ [DataContract]
+ internal class LinkDto
+ {
+ [DataMember(Name = "name")]
+ public string Name { get; set; }
+
+ [DataMember(Name = "target")]
+ public string Target { get; set; }
+
+ [DataMember(Name = "udi")]
+ public GuidUdi Udi { get; set; }
+
+ [DataMember(Name = "url")]
+ public string Url { get; set; }
+ }
+}
diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/PropertyEditorsMigration.cs b/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/PropertyEditorsMigration.cs
index ee439088be..064ffc7228 100644
--- a/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/PropertyEditorsMigration.cs
+++ b/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/PropertyEditorsMigration.cs
@@ -16,7 +16,6 @@ namespace Umbraco.Core.Migrations.Upgrade.V_8_0_0
RenameDataType(Constants.PropertyEditors.Aliases.MediaPicker + "2", Constants.PropertyEditors.Aliases.MediaPicker);
RenameDataType(Constants.PropertyEditors.Aliases.MemberPicker + "2", Constants.PropertyEditors.Aliases.MemberPicker);
RenameDataType(Constants.PropertyEditors.Aliases.MultiNodeTreePicker + "2", Constants.PropertyEditors.Aliases.MultiNodeTreePicker);
- RenameDataType(Constants.PropertyEditors.Aliases.RelatedLinks + "2", Constants.PropertyEditors.Aliases.RelatedLinks);
RenameDataType("Umbraco.TextboxMultiple", Constants.PropertyEditors.Aliases.TextArea, false);
RenameDataType("Umbraco.Textbox", Constants.PropertyEditors.Aliases.TextBox, false);
}
diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/RefactorMacroColumns.cs b/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/RefactorMacroColumns.cs
index 623a842525..bd08b53877 100644
--- a/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/RefactorMacroColumns.cs
+++ b/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/RefactorMacroColumns.cs
@@ -26,7 +26,7 @@ namespace Umbraco.Core.Migrations.Upgrade.V_8_0_0
//populate the new macroSource column with legacy data
Execute.Sql($"UPDATE {Constants.DatabaseSchema.Tables.Macro} SET macroSource = macroXSLT, macroType = {(int)MacroTypes.Unknown} WHERE macroXSLT IS NOT NULL").Do();
Execute.Sql($"UPDATE {Constants.DatabaseSchema.Tables.Macro} SET macroSource = macroScriptAssembly, macroType = {(int)MacroTypes.Unknown} WHERE macroScriptAssembly IS NOT NULL").Do();
- Execute.Sql($"UPDATE {Constants.DatabaseSchema.Tables.Macro} SET macroSource = macroScriptType, macroType = {(int)MacroTypes.UserControl} WHERE macroScriptType IS NOT NULL").Do();
+ Execute.Sql($"UPDATE {Constants.DatabaseSchema.Tables.Macro} SET macroSource = macroScriptType, macroType = {(int)MacroTypes.Unknown} WHERE macroScriptType IS NOT NULL").Do();
Execute.Sql($"UPDATE {Constants.DatabaseSchema.Tables.Macro} SET macroSource = macroPython, macroType = {(int)MacroTypes.PartialView} WHERE macroPython IS NOT NULL").Do();
//now apply constraints (NOT NULL) to new table
diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/RefactorXmlColumns.cs b/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/RefactorXmlColumns.cs
index db8f95bf71..c683940f60 100644
--- a/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/RefactorXmlColumns.cs
+++ b/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/RefactorXmlColumns.cs
@@ -20,36 +20,25 @@ namespace Umbraco.Core.Migrations.Upgrade.V_8_0_0
Alter.Table("cmsPreviewXml").AddColumn("Rv").AsInt64().NotNullable().WithDefaultValue(0).Do();
// remove the any PK_ and the FK_ to cmsContentVersion.VersionId
- if (DatabaseType.IsMySql())
+ var constraints = SqlSyntax.GetConstraintsPerColumn(Context.Database).Distinct().ToArray();
+ var dups = new List();
+ foreach (var c in constraints.Where(x => x.Item1.InvariantEquals("cmsPreviewXml") && x.Item3.InvariantStartsWith("PK_")))
+ {
+ var keyName = c.Item3.ToLowerInvariant();
+ if (dups.Contains(keyName))
+ {
+ Logger.Warn("Duplicate constraint '{Constraint}'", c.Item3);
+ continue;
+ }
+ dups.Add(keyName);
+ Delete.PrimaryKey(c.Item3).FromTable(c.Item1).Do();
+ }
+ foreach (var c in constraints.Where(x => x.Item1.InvariantEquals("cmsPreviewXml") && x.Item3.InvariantStartsWith("FK_cmsPreviewXml_cmsContentVersion")))
{
- Delete.PrimaryKey("PK_cmsPreviewXml").FromTable("cmsPreviewXml").Do();
-
Delete.ForeignKey().FromTable("cmsPreviewXml").ForeignColumn("VersionId")
.ToTable("cmsContentVersion").PrimaryColumn("VersionId")
.Do();
}
- else
- {
- var constraints = SqlSyntax.GetConstraintsPerColumn(Context.Database).Distinct().ToArray();
- var dups = new List();
- foreach (var c in constraints.Where(x => x.Item1.InvariantEquals("cmsPreviewXml") && x.Item3.InvariantStartsWith("PK_")))
- {
- var keyName = c.Item3.ToLowerInvariant();
- if (dups.Contains(keyName))
- {
- Logger.Warn("Duplicate constraint '{Constraint}'", c.Item3);
- continue;
- }
- dups.Add(keyName);
- Delete.PrimaryKey(c.Item3).FromTable(c.Item1).Do();
- }
- foreach (var c in constraints.Where(x => x.Item1.InvariantEquals("cmsPreviewXml") && x.Item3.InvariantStartsWith("FK_cmsPreviewXml_cmsContentVersion")))
- {
- Delete.ForeignKey().FromTable("cmsPreviewXml").ForeignColumn("VersionId")
- .ToTable("cmsContentVersion").PrimaryColumn("VersionId")
- .Do();
- }
- }
if (ColumnExists("cmsPreviewXml", "Timestamp"))
Delete.Column("Timestamp").FromTable("cmsPreviewXml").Do();
diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/UpdatePickerIntegerValuesToUdi.cs b/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/UpdatePickerIntegerValuesToUdi.cs
new file mode 100644
index 0000000000..2e37c79632
--- /dev/null
+++ b/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/UpdatePickerIntegerValuesToUdi.cs
@@ -0,0 +1,108 @@
+using System;
+using System.Linq;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+using Umbraco.Core.Persistence;
+using Umbraco.Core.Persistence.Dtos;
+
+namespace Umbraco.Core.Migrations.Upgrade.V_8_0_0
+{
+ public class UpdatePickerIntegerValuesToUdi : MigrationBase
+ {
+ public UpdatePickerIntegerValuesToUdi(IMigrationContext context) : base(context)
+ { }
+
+ public override void Migrate()
+ {
+ var sqlDataTypes = Sql()
+ .Select()
+ .From()
+ .Where(x => x.EditorAlias == Constants.PropertyEditors.Aliases.ContentPicker
+ || x.EditorAlias == Constants.PropertyEditors.Aliases.MediaPicker
+ || x.EditorAlias == Constants.PropertyEditors.Aliases.MultiNodeTreePicker);
+
+ var dataTypes = Database.Fetch(sqlDataTypes).ToList();
+
+ foreach (var datatype in dataTypes.Where(x => !x.Configuration.IsNullOrWhiteSpace()))
+ {
+ switch (datatype.EditorAlias)
+ {
+ case Constants.PropertyEditors.Aliases.ContentPicker:
+ case Constants.PropertyEditors.Aliases.MediaPicker:
+ {
+ var config = JsonConvert.DeserializeObject(datatype.Configuration);
+ var startNodeId = config.Value("startNodeId");
+ if (!startNodeId.IsNullOrWhiteSpace() && int.TryParse(startNodeId, out var intStartNode))
+ {
+ var guid = intStartNode <= 0
+ ? null
+ : Context.Database.ExecuteScalar(
+ Sql().Select(x => x.UniqueId).From().Where(x => x.NodeId == intStartNode));
+ if (guid.HasValue)
+ {
+ var udi = new GuidUdi(datatype.EditorAlias == Constants.PropertyEditors.Aliases.MediaPicker
+ ? Constants.UdiEntityType.Media
+ : Constants.UdiEntityType.Document, guid.Value);
+ config["startNodeId"] = new JValue(udi.ToString());
+ }
+ else
+ config.Remove("startNodeId");
+
+ datatype.Configuration = JsonConvert.SerializeObject(config);
+ Database.Update(datatype);
+ }
+
+ break;
+ }
+ case Constants.PropertyEditors.Aliases.MultiNodeTreePicker:
+ {
+ var config = JsonConvert.DeserializeObject(datatype.Configuration);
+ var startNodeConfig = config.Value("startNode");
+ if (startNodeConfig != null)
+ {
+ var startNodeId = startNodeConfig.Value("id");
+ var objectType = startNodeConfig.Value("type");
+ if (!objectType.IsNullOrWhiteSpace()
+ && !startNodeId.IsNullOrWhiteSpace()
+ && int.TryParse(startNodeId, out var intStartNode))
+ {
+ var guid = intStartNode <= 0
+ ? null
+ : Context.Database.ExecuteScalar(
+ Sql().Select(x => x.UniqueId).From().Where(x => x.NodeId == intStartNode));
+
+ string entityType = null;
+ switch (objectType.ToLowerInvariant())
+ {
+ case "content":
+ entityType = Constants.UdiEntityType.Document;
+ break;
+ case "media":
+ entityType = Constants.UdiEntityType.Media;
+ break;
+ case "member":
+ entityType = Constants.UdiEntityType.Member;
+ break;
+ }
+
+ if (entityType != null && guid.HasValue)
+ {
+ var udi = new GuidUdi(entityType, guid.Value);
+ startNodeConfig["id"] = new JValue(udi.ToString());
+ }
+ else
+ startNodeConfig.Remove("id");
+
+ datatype.Configuration = JsonConvert.SerializeObject(config);
+ Database.Update(datatype);
+ }
+ }
+
+ break;
+ }
+ }
+ }
+
+ }
+ }
+}
diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/VariantsMigration.cs b/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/VariantsMigration.cs
index 9e223e7beb..d484f7c6ba 100644
--- a/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/VariantsMigration.cs
+++ b/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/VariantsMigration.cs
@@ -1,10 +1,8 @@
using System;
-using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using Umbraco.Core.Migrations.Install;
using Umbraco.Core.Persistence;
-using Umbraco.Core.Persistence.DatabaseModelDefinitions;
using Umbraco.Core.Persistence.Dtos;
namespace Umbraco.Core.Migrations.Upgrade.V_8_0_0
@@ -17,7 +15,6 @@ namespace Umbraco.Core.Migrations.Upgrade.V_8_0_0
// notes
// do NOT use Rename.Column as it's borked on SQLCE - use ReplaceColumn instead
- // not sure it all runs on MySql, needs to test
public override void Migrate()
{
@@ -195,9 +192,7 @@ JOIN {SqlSyntax.GetQuotedTableName(PreTables.Document)} doc ON doc.nodeId=cver.n
FROM {SqlSyntax.GetQuotedTableName(PreTables.Document)} doc
JOIN {SqlSyntax.GetQuotedTableName(PreTables.ContentVersion)} cver ON doc.nodeId=cver.nodeId AND doc.versionId=cver.versionId
WHERE doc.newest=1 AND doc.published=1");
- var getIdentity = Database.SqlContext.DatabaseType.IsMySql()
- ? "LAST_INSERT_ID()"
- : "@@@@IDENTITY";
+ var getIdentity = "@@@@IDENTITY";
foreach (var t in temp3)
{
Database.Execute($@"INSERT INTO {SqlSyntax.GetQuotedTableName(PreTables.ContentVersion)} (nodeId, versionId, versionDate, userId, {SqlSyntax.GetQuotedColumnName("current")}, text)
diff --git a/src/Umbraco.Core/Models/ApplicationTree.cs b/src/Umbraco.Core/Models/ApplicationTree.cs
deleted file mode 100644
index ccdebea724..0000000000
--- a/src/Umbraco.Core/Models/ApplicationTree.cs
+++ /dev/null
@@ -1,170 +0,0 @@
-using System;
-using System.Collections.Concurrent;
-using System.Diagnostics;
-using Umbraco.Core.Services;
-
-namespace Umbraco.Core.Models
-{
- [DebuggerDisplay("Tree - {Title} ({ApplicationAlias})")]
- public class ApplicationTree
- {
- private static readonly ConcurrentDictionary ResolvedTypes = new ConcurrentDictionary();
-
- ///
- /// Initializes a new instance of the class.
- ///
- public ApplicationTree() { }
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// if set to true [initialize].
- /// The sort order.
- /// The application alias.
- /// The tree alias.
- /// The tree title.
- /// The icon closed.
- /// The icon opened.
- /// The tree type.
- public ApplicationTree(bool initialize, int sortOrder, string applicationAlias, string alias, string title, string iconClosed, string iconOpened, string type)
- {
- Initialize = initialize;
- SortOrder = sortOrder;
- ApplicationAlias = applicationAlias;
- Alias = alias;
- Title = title;
- IconClosed = iconClosed;
- IconOpened = iconOpened;
- Type = type;
-
- }
-
- ///
- /// Gets or sets a value indicating whether this should initialize.
- ///
- /// true if initialize; otherwise, false.
- public bool Initialize { get; set; }
-
- ///
- /// Gets or sets the sort order.
- ///
- /// The sort order.
- public int SortOrder { get; set; }
-
- ///
- /// Gets the application alias.
- ///
- /// The application alias.
- public string ApplicationAlias { get; }
-
- ///
- /// Gets the tree alias.
- ///
- /// The alias.
- public string Alias { get; }
-
- ///
- /// Gets or sets the tree title.
- ///
- /// The title.
- public string Title { get; set; }
-
- ///
- /// Gets or sets the icon closed.
- ///
- /// The icon closed.
- public string IconClosed { get; set; }
-
- ///
- /// Gets or sets the icon opened.
- ///
- /// The icon opened.
- public string IconOpened { get; set; }
-
- ///
- /// Gets or sets the tree type assembly name.
- ///
- /// The type.
- public string Type { get; set; }
-
- ///
- /// Returns the localized root node display name
- ///
- ///
- ///
- public string GetRootNodeDisplayName(ILocalizedTextService textService)
- {
- var label = $"[{Alias}]";
-
- // try to look up a the localized tree header matching the tree alias
- var localizedLabel = textService.Localize("treeHeaders/" + Alias);
-
- // if the localizedLabel returns [alias] then return the title attribute from the trees.config file, if it's defined
- if (localizedLabel != null && localizedLabel.Equals(label, StringComparison.InvariantCultureIgnoreCase))
- {
- if (string.IsNullOrEmpty(Title) == false)
- label = Title;
- }
- else
- {
- // the localizedLabel translated into something that's not just [alias], so use the translation
- label = localizedLabel;
- }
-
- return label;
- }
-
- private Type _runtimeType;
-
- ///
- /// Returns the CLR type based on it's assembly name stored in the config
- ///
- ///
- public Type GetRuntimeType()
- {
- return _runtimeType ?? (_runtimeType = System.Type.GetType(Type));
- }
-
- ///
- /// Used to try to get and cache the tree type
- ///
- ///
- ///
- internal static Type TryGetType(string type)
- {
- try
- {
- return ResolvedTypes.GetOrAdd(type, s =>
- {
- var result = System.Type.GetType(type);
- if (result != null)
- {
- return result;
- }
-
- //we need to implement a bit of a hack here due to some trees being renamed and backwards compat
- var parts = type.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
- if (parts.Length != 2)
- throw new InvalidOperationException("Could not resolve type");
- if (parts[1].Trim() != "Umbraco.Web" || parts[0].StartsWith("Umbraco.Web.Trees") == false || parts[0].EndsWith("Controller"))
- throw new InvalidOperationException("Could not resolve type");
-
- //if it's one of our controllers but it's not suffixed with "Controller" then add it and try again
- var tempType = parts[0] + "Controller, Umbraco.Web";
-
- result = System.Type.GetType(tempType);
- if (result != null)
- return result;
-
- throw new InvalidOperationException("Could not resolve type");
- });
- }
- catch (InvalidOperationException)
- {
- //swallow, this is our own exception, couldn't find the type
- // fixme bad use of exceptions here!
- return null;
- }
- }
- }
-}
diff --git a/src/Umbraco.Core/Models/ContentBase.cs b/src/Umbraco.Core/Models/ContentBase.cs
index b0c786d4b0..ca1152a9a4 100644
--- a/src/Umbraco.Core/Models/ContentBase.cs
+++ b/src/Umbraco.Core/Models/ContentBase.cs
@@ -128,14 +128,14 @@ namespace Umbraco.Core.Models
///
/// Gets the enumeration of property groups for the entity.
- /// fixme is a proxy, kill this
+ /// TODO: remove this proxy method
///
[IgnoreDataMember]
public IEnumerable PropertyGroups => ContentTypeBase.CompositionPropertyGroups;
///
/// Gets the numeration of property types for the entity.
- /// fixme is a proxy, kill this
+ /// TODO: remove this proxy method
///
[IgnoreDataMember]
public IEnumerable PropertyTypes => ContentTypeBase.CompositionPropertyTypes;
@@ -391,7 +391,7 @@ namespace Umbraco.Core.Models
#region Dirty
///
- /// Overriden to include user properties.
+ /// Overridden to include user properties.
public override void ResetDirtyProperties(bool rememberDirty)
{
base.ResetDirtyProperties(rememberDirty);
@@ -408,14 +408,14 @@ namespace Umbraco.Core.Models
}
///
- /// Overriden to include user properties.
+ /// Overridden to include user properties.
public override bool IsDirty()
{
return IsEntityDirty() || this.IsAnyUserPropertyDirty();
}
///
- /// Overriden to include user properties.
+ /// Overridden to include user properties.
public override bool WasDirty()
{
return WasEntityDirty() || this.WasAnyUserPropertyDirty();
@@ -438,7 +438,7 @@ namespace Umbraco.Core.Models
}
///
- /// Overriden to include user properties.
+ /// Overridden to include user properties.
public override bool IsPropertyDirty(string propertyName)
{
if (base.IsPropertyDirty(propertyName))
@@ -448,7 +448,7 @@ namespace Umbraco.Core.Models
}
///
- /// Overriden to include user properties.
+ /// Overridden to include user properties.
public override bool WasPropertyDirty(string propertyName)
{
if (base.WasPropertyDirty(propertyName))
@@ -458,7 +458,7 @@ namespace Umbraco.Core.Models
}
///
- /// Overriden to include user properties.
+ /// Overridden to include user properties.
public override IEnumerable GetDirtyProperties()
{
var instanceProperties = base.GetDirtyProperties();
@@ -467,7 +467,7 @@ namespace Umbraco.Core.Models
}
///
- /// Overriden to include user properties.
+ /// Overridden to include user properties.
public override IEnumerable GetWereDirtyProperties()
{
var instanceProperties = base.GetWereDirtyProperties();
@@ -479,7 +479,7 @@ namespace Umbraco.Core.Models
///
///
- /// Overriden to deal with specific object instances
+ /// Overridden to deal with specific object instances
///
protected override void PerformDeepClone(object clone)
{
diff --git a/src/Umbraco.Core/Models/ContentScheduleCollection.cs b/src/Umbraco.Core/Models/ContentScheduleCollection.cs
index 4c06f8927d..6c7dd79312 100644
--- a/src/Umbraco.Core/Models/ContentScheduleCollection.cs
+++ b/src/Umbraco.Core/Models/ContentScheduleCollection.cs
@@ -31,7 +31,7 @@ namespace Umbraco.Core.Models
_schedule[schedule.Culture] = changes;
}
- //TODO: Below will throw if there are duplicate dates added, validate/return bool?
+ // TODO: Below will throw if there are duplicate dates added, validate/return bool?
changes.Add(schedule.Date, schedule);
OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, schedule));
@@ -62,7 +62,7 @@ namespace Umbraco.Core.Models
if (!releaseDate.HasValue && !expireDate.HasValue) return false;
- //TODO: Do we allow passing in a release or expiry date that is before now?
+ // TODO: Do we allow passing in a release or expiry date that is before now?
if (!_schedule.TryGetValue(culture, out var changes))
{
@@ -70,7 +70,7 @@ namespace Umbraco.Core.Models
_schedule[culture] = changes;
}
- //TODO: Below will throw if there are duplicate dates added, should validate/return bool?
+ // TODO: Below will throw if there are duplicate dates added, should validate/return bool?
// but the bool won't indicate which date was in error, maybe have 2 diff methods to schedule start/end?
if (releaseDate.HasValue)
diff --git a/src/Umbraco.Core/Models/ContentType.cs b/src/Umbraco.Core/Models/ContentType.cs
index e6439acade..4b9831682c 100644
--- a/src/Umbraco.Core/Models/ContentType.cs
+++ b/src/Umbraco.Core/Models/ContentType.cs
@@ -160,5 +160,8 @@ namespace Umbraco.Core.Models
return result;
}
+
+ ///
+ IContentType IContentType.DeepCloneWithResetIdentities(string newAlias) => (IContentType)DeepCloneWithResetIdentities(newAlias);
}
}
diff --git a/src/Umbraco.Core/Models/ContentTypeBase.cs b/src/Umbraco.Core/Models/ContentTypeBase.cs
index b6ea9f50a0..3da2838d0e 100644
--- a/src/Umbraco.Core/Models/ContentTypeBase.cs
+++ b/src/Umbraco.Core/Models/ContentTypeBase.cs
@@ -431,7 +431,7 @@ namespace Umbraco.Core.Models
/// PropertyTypes that are not part of a PropertyGroup
///
[IgnoreDataMember]
- //fixme should we mark this as EditorBrowsable hidden since it really isn't ever used?
+ // TODO: should we mark this as EditorBrowsable hidden since it really isn't ever used?
internal PropertyTypeCollection PropertyTypeCollection => _noGroupPropertyTypes;
///
@@ -504,9 +504,9 @@ namespace Umbraco.Core.Models
}
}
- public IContentType DeepCloneWithResetIdentities(string alias)
+ public ContentTypeBase DeepCloneWithResetIdentities(string alias)
{
- var clone = (ContentType)DeepClone();
+ var clone = (ContentTypeBase)DeepClone();
clone.Alias = alias;
clone.Key = Guid.Empty;
foreach (var propertyGroup in clone.PropertyGroups)
diff --git a/src/Umbraco.Core/Models/ContentTypeBaseExtensions.cs b/src/Umbraco.Core/Models/ContentTypeBaseExtensions.cs
index adbc3de54f..51c642c20d 100644
--- a/src/Umbraco.Core/Models/ContentTypeBaseExtensions.cs
+++ b/src/Umbraco.Core/Models/ContentTypeBaseExtensions.cs
@@ -48,7 +48,7 @@ namespace Umbraco.Core.Models
throw new Exception("oops");
// skip new properties
- //TODO: This used to be WasPropertyDirty("HasIdentity") but i don't think that actually worked for detecting new entities this does seem to work properly
+ // TODO: This used to be WasPropertyDirty("HasIdentity") but i don't think that actually worked for detecting new entities this does seem to work properly
var isNewProperty = dirtyProperty.WasPropertyDirty("Id");
if (isNewProperty) return false;
diff --git a/src/Umbraco.Core/Models/DeepCloneHelper.cs b/src/Umbraco.Core/Models/DeepCloneHelper.cs
index 44a714c2c1..6470de912b 100644
--- a/src/Umbraco.Core/Models/DeepCloneHelper.cs
+++ b/src/Umbraco.Core/Models/DeepCloneHelper.cs
@@ -91,7 +91,7 @@ namespace Umbraco.Core.Models
|| (propertyInfo.PropertyType.IsInterface && propertyInfo.PropertyType.IsGenericType == false))
{
//if its an array, we'll create a list to work with first and then convert to array later
- //otherwise if its just a regular derivitave of IEnumerable, we can use a list too
+ //otherwise if its just a regular derivative of IEnumerable, we can use a list too
return new ClonePropertyInfo(propertyInfo) { GenericListType = typeof(List
/// Can be empty, but never null. To avoid allocating, do not
- /// test for emptyness, but use instead.
+ /// test for emptiness, but use instead.
IDictionary AdditionalData { get; }
///
diff --git a/src/Umbraco.Core/Models/Entities/TreeEntityBase.cs b/src/Umbraco.Core/Models/Entities/TreeEntityBase.cs
index 18e53a8a04..60e06c4977 100644
--- a/src/Umbraco.Core/Models/Entities/TreeEntityBase.cs
+++ b/src/Umbraco.Core/Models/Entities/TreeEntityBase.cs
@@ -33,9 +33,6 @@ namespace Umbraco.Core.Models.Entities
public readonly PropertyInfo Trashed = ExpressionHelper.GetPropertyInfo(x => x.Trashed);
}
- // fixme
- // ParentId, Path, Level and Trashed all should be consistent, and all derive from parentId, really
-
///
[DataMember]
public string Name
@@ -121,4 +118,4 @@ namespace Umbraco.Core.Models.Entities
set => SetPropertyValueAndDetectChanges(value, ref _trashed, Selectors.Trashed);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Umbraco.Core/Models/GridValue.cs b/src/Umbraco.Core/Models/GridValue.cs
index 237385f3f4..157304463f 100644
--- a/src/Umbraco.Core/Models/GridValue.cs
+++ b/src/Umbraco.Core/Models/GridValue.cs
@@ -5,7 +5,7 @@ using Newtonsoft.Json.Linq;
namespace Umbraco.Core.Models
{
- //TODO: Make a property value converter for this!
+ // TODO: Make a property value converter for this!
///
/// A model representing the value saved for the grid
@@ -21,7 +21,7 @@ namespace Umbraco.Core.Models
public class GridSection
{
[JsonProperty("grid")]
- public string Grid { get; set; } //fixme: what is this?
+ public string Grid { get; set; } // TODO: what is this?
[JsonProperty("rows")]
public IEnumerable Rows { get; set; }
@@ -48,7 +48,7 @@ namespace Umbraco.Core.Models
public class GridArea
{
[JsonProperty("grid")]
- public string Grid { get; set; } //fixme: what is this?
+ public string Grid { get; set; } // TODO: what is this?
[JsonProperty("controls")]
public IEnumerable Controls { get; set; }
diff --git a/src/Umbraco.Core/Models/IContent.cs b/src/Umbraco.Core/Models/IContent.cs
index 2e71d392c6..ee38f613a3 100644
--- a/src/Umbraco.Core/Models/IContent.cs
+++ b/src/Umbraco.Core/Models/IContent.cs
@@ -137,7 +137,7 @@ namespace Umbraco.Core.Models
///
IEnumerable EditedCultures { get; }
- // fixme - these two should move to some kind of service
+ // TODO: these two should move to some kind of service
///
/// Changes the for the current content object
diff --git a/src/Umbraco.Core/Models/IContentBase.cs b/src/Umbraco.Core/Models/IContentBase.cs
index fb3714cfc0..40a1c57097 100644
--- a/src/Umbraco.Core/Models/IContentBase.cs
+++ b/src/Umbraco.Core/Models/IContentBase.cs
@@ -137,8 +137,6 @@ namespace Umbraco.Core.Models
///
void CopyFrom(IContent other, string culture = "*");
- // fixme validate published cultures?
-
///
/// Validates the content item's properties pass variant rules
///
diff --git a/src/Umbraco.Core/Models/IContentTypeBase.cs b/src/Umbraco.Core/Models/IContentTypeBase.cs
index 787e347b37..aea84d9767 100644
--- a/src/Umbraco.Core/Models/IContentTypeBase.cs
+++ b/src/Umbraco.Core/Models/IContentTypeBase.cs
@@ -68,7 +68,7 @@ namespace Umbraco.Core.Models
///
/// The culture.
/// The segment.
- /// A value indicating whether wilcards are supported.
+ /// A value indicating whether wildcard are supported.
/// True if the combination is valid; otherwise false.
///
/// The combination must match the content type variation exactly. For instance, if the content type varies by culture,
@@ -81,7 +81,7 @@ namespace Umbraco.Core.Models
///
/// The culture.
/// The segment.
- /// A value indicating whether wilcards are supported.
+ /// A value indicating whether wildcard are supported.
/// True if the combination is valid; otherwise false.
///
/// The combination must be valid for properties of the content type. For instance, if the content type varies by culture,
diff --git a/src/Umbraco.Core/Models/IContentTypeComposition.cs b/src/Umbraco.Core/Models/IContentTypeComposition.cs
index 36ace19f0f..675d3cd268 100644
--- a/src/Umbraco.Core/Models/IContentTypeComposition.cs
+++ b/src/Umbraco.Core/Models/IContentTypeComposition.cs
@@ -10,7 +10,7 @@ namespace Umbraco.Core.Models
///
/// Gets or sets the content types that compose this content type.
///
- //fixme: we should be storing key references, not the object else we are caching way too much
+ // TODO: we should be storing key references, not the object else we are caching way too much
IEnumerable ContentTypeComposition { get; set; }
///
@@ -31,7 +31,7 @@ namespace Umbraco.Core.Models
bool AddContentType(IContentTypeComposition contentType);
///
- /// Removes a ContentType with the supplied alias from the the list of composite ContentTypes
+ /// Removes a ContentType with the supplied alias from the list of composite ContentTypes
///
/// Alias of a
/// True if ContentType was removed, otherwise returns False
diff --git a/src/Umbraco.Core/Models/ITemplate.cs b/src/Umbraco.Core/Models/ITemplate.cs
index 97b9324415..6548a49626 100644
--- a/src/Umbraco.Core/Models/ITemplate.cs
+++ b/src/Umbraco.Core/Models/ITemplate.cs
@@ -1,11 +1,9 @@
-using System;
-using System.Runtime.Serialization;
-using Umbraco.Core.Models.Entities;
+using Umbraco.Core.Models.Entities;
namespace Umbraco.Core.Models
{
///
- /// Defines a Template File (Masterpage or Mvc View)
+ /// Defines a Template File (Mvc View)
///
public interface ITemplate : IFile, IRememberBeingDirty, ICanBeDirty
{
diff --git a/src/Umbraco.Core/Models/Identity/BackOfficeIdentityUser.cs b/src/Umbraco.Core/Models/Identity/BackOfficeIdentityUser.cs
index dcf86a0b42..f5c21a3a74 100644
--- a/src/Umbraco.Core/Models/Identity/BackOfficeIdentityUser.cs
+++ b/src/Umbraco.Core/Models/Identity/BackOfficeIdentityUser.cs
@@ -67,7 +67,7 @@ namespace Umbraco.Core.Models.Identity
_startContentIds = new int[] { };
_groups = new IReadOnlyUserGroup[] { };
_allowedSections = new string[] { };
- _culture = Current.Configs.Global().DefaultUILanguage; //fixme inject somehow?
+ _culture = Current.Configs.Global().DefaultUILanguage; // TODO: inject
_groups = new IReadOnlyUserGroup[0];
_roles = new ObservableCollection>();
_roles.CollectionChanged += _roles_CollectionChanged;
@@ -84,7 +84,7 @@ namespace Umbraco.Core.Models.Identity
_startContentIds = new int[] { };
_groups = new IReadOnlyUserGroup[] { };
_allowedSections = new string[] { };
- _culture = Current.Configs.Global().DefaultUILanguage; //fixme inject somehow?
+ _culture = Current.Configs.Global().DefaultUILanguage; // TODO: inject
_groups = groups.ToArray();
_roles = new ObservableCollection>(_groups.Select(x => new IdentityUserRole
{
@@ -95,7 +95,7 @@ namespace Umbraco.Core.Models.Identity
}
///
- /// Returns true if an Id has been set on this object this will be false if the object is new and not peristed to the database
+ /// Returns true if an Id has been set on this object this will be false if the object is new and not persisted to the database
///
public bool HasIdentity => _hasIdentity;
diff --git a/src/Umbraco.Core/Models/Identity/IIdentityUserLogin.cs b/src/Umbraco.Core/Models/Identity/IIdentityUserLogin.cs
index 198f87cf21..276f601771 100644
--- a/src/Umbraco.Core/Models/Identity/IIdentityUserLogin.cs
+++ b/src/Umbraco.Core/Models/Identity/IIdentityUserLogin.cs
@@ -5,7 +5,7 @@ namespace Umbraco.Core.Models.Identity
public interface IIdentityUserLogin : IEntity, IRememberBeingDirty
{
///
- /// The login provider for the login (i.e. facebook, google)
+ /// The login provider for the login (i.e. Facebook, Google)
///
///
string LoginProvider { get; set; }
diff --git a/src/Umbraco.Core/Models/Identity/IdentityUserLogin.cs b/src/Umbraco.Core/Models/Identity/IdentityUserLogin.cs
index 28a9fe2f15..5876f420b4 100644
--- a/src/Umbraco.Core/Models/Identity/IdentityUserLogin.cs
+++ b/src/Umbraco.Core/Models/Identity/IdentityUserLogin.cs
@@ -4,7 +4,7 @@ using Umbraco.Core.Models.Entities;
namespace Umbraco.Core.Models.Identity
{
///
- /// Entity type for a user's login (i.e. facebook, google)
+ /// Entity type for a user's login (i.e. Facebook, Google)
///
///
public class IdentityUserLogin : EntityBase, IIdentityUserLogin
@@ -26,7 +26,7 @@ namespace Umbraco.Core.Models.Identity
}
///
- /// The login provider for the login (i.e. facebook, google)
+ /// The login provider for the login (i.e. Facebook, Google)
///
///
public string LoginProvider { get; set; }
diff --git a/src/Umbraco.Core/Models/MacroTypes.cs b/src/Umbraco.Core/Models/MacroTypes.cs
index 1f8ae696c5..5f8440845d 100644
--- a/src/Umbraco.Core/Models/MacroTypes.cs
+++ b/src/Umbraco.Core/Models/MacroTypes.cs
@@ -10,8 +10,6 @@ namespace Umbraco.Core.Models
[DataContract(IsReference = true)]
public enum MacroTypes
{
- [EnumMember]
- UserControl = 3,
[EnumMember]
Unknown = 4,
[EnumMember]
diff --git a/src/Umbraco.Core/Models/Media.cs b/src/Umbraco.Core/Models/Media.cs
index 9c13a22caa..a0f3aa35de 100644
--- a/src/Umbraco.Core/Models/Media.cs
+++ b/src/Umbraco.Core/Models/Media.cs
@@ -15,7 +15,7 @@ namespace Umbraco.Core.Models
///
/// Constructor for creating a Media object
///
- /// ame of the Media object
+ /// name of the Media object
/// Parent object
/// MediaType for the current Media object
public Media(string name, IMedia parent, IMediaType contentType)
@@ -25,7 +25,7 @@ namespace Umbraco.Core.Models
///
/// Constructor for creating a Media object
///
- /// ame of the Media object
+ /// name of the Media object
/// Parent object
/// MediaType for the current Media object
/// Collection of properties
@@ -38,7 +38,7 @@ namespace Umbraco.Core.Models
///
/// Constructor for creating a Media object
///
- /// ame of the Media object
+ /// name of the Media object
/// Id of the Parent IMedia
/// MediaType for the current Media object
public Media(string name, int parentId, IMediaType contentType)
diff --git a/src/Umbraco.Core/Models/MediaExtensions.cs b/src/Umbraco.Core/Models/MediaExtensions.cs
index f510377c09..e281aaf5ab 100644
--- a/src/Umbraco.Core/Models/MediaExtensions.cs
+++ b/src/Umbraco.Core/Models/MediaExtensions.cs
@@ -21,7 +21,7 @@ namespace Umbraco.Core.Models
var val = media.Properties[propertyType];
if (val == null) return string.Empty;
- //fixme doesn't take into account variants
+ // TODO: would need to be adjusted to variations, when media become variants
var jsonString = val.GetValue() as string;
if (jsonString == null) return string.Empty;
@@ -46,7 +46,7 @@ namespace Umbraco.Core.Models
}
}
- // hrm, without knowing what it is, just adding a string here might not be very nice
+ // Without knowing what it is, just adding a string here might not be very nice
return string.Empty;
}
diff --git a/src/Umbraco.Core/Models/MediaType.cs b/src/Umbraco.Core/Models/MediaType.cs
index 4ae2fd190c..83e1acfbc0 100644
--- a/src/Umbraco.Core/Models/MediaType.cs
+++ b/src/Umbraco.Core/Models/MediaType.cs
@@ -44,29 +44,7 @@ namespace Umbraco.Core.Models
///
public override bool IsPublishing => IsPublishingConst;
- ///
- /// Creates a deep clone of the current entity with its identity/alias and it's property identities reset
- ///
- ///
- public new IMediaType DeepCloneWithResetIdentities(string alias)
- {
- var clone = (MediaType)DeepClone();
- clone.Alias = alias;
- clone.Key = Guid.Empty;
- foreach (var propertyGroup in clone.PropertyGroups)
- {
- propertyGroup.ResetIdentity();
- propertyGroup.ResetDirtyProperties(false);
- }
- foreach (var propertyType in clone.PropertyTypes)
- {
- propertyType.ResetIdentity();
- propertyType.ResetDirtyProperties(false);
- }
-
- clone.ResetIdentity();
- clone.ResetDirtyProperties(false);
- return clone;
- }
+ ///
+ IMediaType IMediaType.DeepCloneWithResetIdentities(string newAlias) => (IMediaType)DeepCloneWithResetIdentities(newAlias);
}
}
diff --git a/src/Umbraco.Core/Models/Member.cs b/src/Umbraco.Core/Models/Member.cs
index 38927898cf..0ef15ee413 100644
--- a/src/Umbraco.Core/Models/Member.cs
+++ b/src/Umbraco.Core/Models/Member.cs
@@ -189,7 +189,7 @@ namespace Umbraco.Core.Models
[DataMember]
public IEnumerable Groups { get; set; }
- //TODO: When get/setting all of these properties we MUST:
+ // TODO: When get/setting all of these properties we MUST:
// * Check if we are using the umbraco membership provider, if so then we need to use the configured fields - not the explicit fields below
// * If any of the fields don't exist, what should we do? Currently it will throw an exception!
@@ -226,7 +226,7 @@ namespace Umbraco.Core.Models
/// Gets or sets the raw password answer value
///
///
- /// For security reasons this value should be encrypted, the encryption process is handled by the memberhip provider
+ /// For security reasons this value should be encrypted, the encryption process is handled by the membership provider
/// Alias: umbracoMemberPasswordRetrievalAnswer
///
/// Part of the standard properties collection.
@@ -338,7 +338,7 @@ namespace Umbraco.Core.Models
return tryConvert.Result;
}
return false;
- //TODO: Use TryConvertTo instead
+ // TODO: Use TryConvertTo instead
}
set
{
@@ -371,7 +371,7 @@ namespace Umbraco.Core.Models
return tryConvert.Result;
}
return default(DateTime);
- //TODO: Use TryConvertTo instead
+ // TODO: Use TryConvertTo instead
}
set
{
@@ -404,7 +404,7 @@ namespace Umbraco.Core.Models
return tryConvert.Result;
}
return default(DateTime);
- //TODO: Use TryConvertTo instead
+ // TODO: Use TryConvertTo instead
}
set
{
@@ -437,7 +437,7 @@ namespace Umbraco.Core.Models
return tryConvert.Result;
}
return default(DateTime);
- //TODO: Use TryConvertTo instead
+ // TODO: Use TryConvertTo instead
}
set
{
@@ -471,7 +471,7 @@ namespace Umbraco.Core.Models
return tryConvert.Result;
}
return default(int);
- //TODO: Use TryConvertTo instead
+ // TODO: Use TryConvertTo instead
}
set
{
diff --git a/src/Umbraco.Core/Models/MemberType.cs b/src/Umbraco.Core/Models/MemberType.cs
index bcc7e14fd7..1ce883d9a7 100644
--- a/src/Umbraco.Core/Models/MemberType.cs
+++ b/src/Umbraco.Core/Models/MemberType.cs
@@ -66,7 +66,7 @@ namespace Umbraco.Core.Models
// leading underscores which we don't want in this case.
// see : http://issues.umbraco.org/issue/U4-3968
- //TODO: BUT, I'm pretty sure we could do this with regards to underscores now:
+ // TODO: BUT, I'm pretty sure we could do this with regards to underscores now:
// .ToCleanString(CleanStringType.Alias | CleanStringType.UmbracoCase)
// Need to ask Stephen
diff --git a/src/Umbraco.Core/Models/Membership/IProfile.cs b/src/Umbraco.Core/Models/Membership/IProfile.cs
index 335faa6c11..7da095bb14 100644
--- a/src/Umbraco.Core/Models/Membership/IProfile.cs
+++ b/src/Umbraco.Core/Models/Membership/IProfile.cs
@@ -1,7 +1,7 @@
namespace Umbraco.Core.Models.Membership
{
///
- /// Defines the the User Profile interface
+ /// Defines the User Profile interface
///
public interface IProfile
{
diff --git a/src/Umbraco.Core/Models/Membership/UmbracoMembershipMember.cs b/src/Umbraco.Core/Models/Membership/UmbracoMembershipMember.cs
index ed3422d4f9..debce3afe5 100644
--- a/src/Umbraco.Core/Models/Membership/UmbracoMembershipMember.cs
+++ b/src/Umbraco.Core/Models/Membership/UmbracoMembershipMember.cs
@@ -44,7 +44,7 @@ namespace Umbraco.Core.Models.Membership
_isLockedOut = member.IsLockedOut;
_creationDate = member.CreateDate.ToUniversalTime();
_lastLoginDate = member.LastLoginDate.ToUniversalTime();
- //TODO: We currently don't really have any place to store this data!!
+ // TODO: We currently don't really have any place to store this data!!
_lastActivityDate = member.LastLoginDate.ToUniversalTime();
_lastPasswordChangedDate = member.LastPasswordChangeDate.ToUniversalTime();
_lastLockoutDate = member.LastLockoutDate.ToUniversalTime();
diff --git a/src/Umbraco.Core/Models/Membership/User.cs b/src/Umbraco.Core/Models/Membership/User.cs
index 650aa6cb29..7832390b92 100644
--- a/src/Umbraco.Core/Models/Membership/User.cs
+++ b/src/Umbraco.Core/Models/Membership/User.cs
@@ -27,7 +27,7 @@ namespace Umbraco.Core.Models.Membership
{
SessionTimeout = 60;
_userGroups = new HashSet();
- _language = Current.Configs.Global().DefaultUILanguage; //fixme inject somehow?
+ _language = Current.Configs.Global().DefaultUILanguage; // TODO: inject
_isApproved = true;
_isLockedOut = false;
_startContentIds = new int[] { };
@@ -242,7 +242,7 @@ namespace Umbraco.Core.Models.Membership
set { SetPropertyValueAndDetectChanges(value, ref _failedLoginAttempts, Ps.Value.FailedPasswordAttemptsSelector); }
}
- //TODO: Figure out how to support all of this! - we cannot have NotImplementedExceptions because these get used by the IMembershipMemberService service so
+ // TODO: Figure out how to support all of this! - we cannot have NotImplementedExceptions because these get used by the IMembershipMemberService service so
// we'll just have them as generic get/set which don't interact with the db.
[IgnoreDataMember]
diff --git a/src/Umbraco.Core/Models/Membership/UserGroup.cs b/src/Umbraco.Core/Models/Membership/UserGroup.cs
index db21c78438..e3e812f4c1 100644
--- a/src/Umbraco.Core/Models/Membership/UserGroup.cs
+++ b/src/Umbraco.Core/Models/Membership/UserGroup.cs
@@ -24,7 +24,7 @@ namespace Umbraco.Core.Models.Membership
private static readonly Lazy Ps = new Lazy();
- // ReSharper disable once ClassNeverInstantiated.Local // lazy-instanciated in Ps
+ // ReSharper disable once ClassNeverInstantiated.Local // lazy-instantiated in Ps
private class PropertySelectors
{
public readonly PropertyInfo NameSelector = ExpressionHelper.GetPropertyInfo(x => x.Name);
diff --git a/src/Umbraco.Core/Models/ObjectTypes.cs b/src/Umbraco.Core/Models/ObjectTypes.cs
index 2eb4d70a3a..dd943ee02b 100644
--- a/src/Umbraco.Core/Models/ObjectTypes.cs
+++ b/src/Umbraco.Core/Models/ObjectTypes.cs
@@ -76,7 +76,7 @@ namespace Umbraco.Core.Models
}
///
- /// Gets the Clr type corresponding to an object type Guid.
+ /// Gets the CLR type corresponding to an object type Guid.
///
public static Type GetClrType(Guid objectType)
{
@@ -145,7 +145,7 @@ namespace Umbraco.Core.Models
}
///
- /// Gets the Clr type corresponding to this Umbraco object type.
+ /// Gets the CLR type corresponding to this Umbraco object type.
///
public static Type GetClrType(this UmbracoObjectTypes objectType)
{
diff --git a/src/Umbraco.Core/Models/Packaging/CompiledPackage.cs b/src/Umbraco.Core/Models/Packaging/CompiledPackage.cs
index a852fcc997..f4ed11e09e 100644
--- a/src/Umbraco.Core/Models/Packaging/CompiledPackage.cs
+++ b/src/Umbraco.Core/Models/Packaging/CompiledPackage.cs
@@ -23,22 +23,22 @@ namespace Umbraco.Core.Models.Packaging
public string Author { get; set; }
public string AuthorUrl { get; set; }
public string Readme { get; set; }
- public string Control { get; set; }
+ public string PackageView { get; set; }
public string IconUrl { get; set; }
- public string Actions { get; set; } //fixme: Should we make this strongly typed to IEnumerable ?
+ public string Actions { get; set; } // TODO: Should we make this strongly typed to IEnumerable ?
public PreInstallWarnings Warnings { get; set; } = new PreInstallWarnings();
public List Files { get; set; } = new List();
- public IEnumerable Macros { get; set; } //fixme: make strongly typed
- public IEnumerable Templates { get; set; } //fixme: make strongly typed
- public IEnumerable Stylesheets { get; set; } //fixme: make strongly typed
- public IEnumerable DataTypes { get; set; } //fixme: make strongly typed
- public IEnumerable Languages { get; set; } //fixme: make strongly typed
- public IEnumerable DictionaryItems { get; set; } //fixme: make strongly typed
- public IEnumerable DocumentTypes { get; set; } //fixme: make strongly typed
+ public IEnumerable Macros { get; set; } // TODO: make strongly typed
+ public IEnumerable Templates { get; set; } // TODO: make strongly typed
+ public IEnumerable Stylesheets { get; set; } // TODO: make strongly typed
+ public IEnumerable DataTypes { get; set; } // TODO: make strongly typed
+ public IEnumerable Languages { get; set; } // TODO: make strongly typed
+ public IEnumerable DictionaryItems { get; set; } // TODO: make strongly typed
+ public IEnumerable DocumentTypes { get; set; } // TODO: make strongly typed
public IEnumerable Documents { get; set; }
}
}
diff --git a/src/Umbraco.Core/Models/Packaging/IPackageInfo.cs b/src/Umbraco.Core/Models/Packaging/IPackageInfo.cs
index 8722ee7811..eea56549f1 100644
--- a/src/Umbraco.Core/Models/Packaging/IPackageInfo.cs
+++ b/src/Umbraco.Core/Models/Packaging/IPackageInfo.cs
@@ -13,7 +13,12 @@ namespace Umbraco.Core.Models.Packaging
string Author { get; }
string AuthorUrl { get; }
string Readme { get; }
- string Control { get; } //fixme - this needs to be an angular view
+
+ ///
+ /// This is the angular view path that will be loaded when the package installs
+ ///
+ string PackageView { get; }
+
string IconUrl { get; }
}
}
diff --git a/src/Umbraco.Core/Models/Packaging/PackageDefinition.cs b/src/Umbraco.Core/Models/Packaging/PackageDefinition.cs
index c068c57b08..8c0ef79d0b 100644
--- a/src/Umbraco.Core/Models/Packaging/PackageDefinition.cs
+++ b/src/Umbraco.Core/Models/Packaging/PackageDefinition.cs
@@ -25,7 +25,7 @@ namespace Umbraco.Core.Models.Packaging
Actions = compiled.Actions,
Author = compiled.Author,
AuthorUrl = compiled.AuthorUrl,
- Control = compiled.Control,
+ PackageView = compiled.PackageView,
IconUrl = compiled.IconUrl,
License = compiled.License,
LicenseUrl = compiled.LicenseUrl,
@@ -115,9 +115,9 @@ namespace Umbraco.Core.Models.Packaging
[DataMember(Name = "files")]
public IList Files { get; set; } = new List();
- //fixme: Change this to angular view
- [DataMember(Name = "loadControl")]
- public string Control { get; set; } = string.Empty;
+ ///
+ [DataMember(Name = "packageView")]
+ public string PackageView { get; set; } = string.Empty;
[DataMember(Name = "actions")]
public string Actions { get; set; } = "";
@@ -127,38 +127,7 @@ namespace Umbraco.Core.Models.Packaging
[DataMember(Name = "iconUrl")]
public string IconUrl { get; set; } = string.Empty;
-
- public PackageDefinition Clone()
- {
- return new PackageDefinition
- {
- Id = Id,
- PackagePath = PackagePath,
- Name = Name,
- Files = new List(Files),
- UmbracoVersion = (Version) UmbracoVersion.Clone(),
- Version = Version,
- Url = Url,
- Readme = Readme,
- AuthorUrl = AuthorUrl,
- Author = Author,
- LicenseUrl = LicenseUrl,
- Actions = Actions,
- PackageId = PackageId,
- Control = Control,
- DataTypes = new List(DataTypes),
- IconUrl = IconUrl,
- License = License,
- Templates = new List(Templates),
- Languages = new List(Languages),
- Macros = new List(Macros),
- Stylesheets = new List(Stylesheets),
- DocumentTypes = new List(DocumentTypes),
- DictionaryItems = new List(DictionaryItems),
- ContentNodeId = ContentNodeId,
- ContentLoadChildNodes = ContentLoadChildNodes
- };
- }
+
}
diff --git a/src/Umbraco.Core/Models/Packaging/PreInstallWarnings.cs b/src/Umbraco.Core/Models/Packaging/PreInstallWarnings.cs
index f0acb2a46b..69c7a5641d 100644
--- a/src/Umbraco.Core/Models/Packaging/PreInstallWarnings.cs
+++ b/src/Umbraco.Core/Models/Packaging/PreInstallWarnings.cs
@@ -10,7 +10,7 @@ namespace Umbraco.Core.Models.Packaging
public IEnumerable UnsecureFiles { get; set; } = Enumerable.Empty();
public IEnumerable FilesReplaced { get; set; } = Enumerable.Empty();
- //TODO: Shouldn't we detect other conflicting entities too ?
+ // TODO: Shouldn't we detect other conflicting entities too ?
public IEnumerable ConflictingMacros { get; set; } = Enumerable.Empty();
public IEnumerable ConflictingTemplates { get; set; } = Enumerable.Empty();
public IEnumerable ConflictingStylesheets { get; set; } = Enumerable.Empty();
diff --git a/src/Umbraco.Core/Models/Property.cs b/src/Umbraco.Core/Models/Property.cs
index 0c71544111..11b5239a70 100644
--- a/src/Umbraco.Core/Models/Property.cs
+++ b/src/Umbraco.Core/Models/Property.cs
@@ -55,7 +55,7 @@ namespace Umbraco.Core.Models
///
public class PropertyValue
{
- //TODO: Either we allow change tracking at this class level, or we add some special change tracking collections to the Property
+ // TODO: Either we allow change tracking at this class level, or we add some special change tracking collections to the Property
// class to deal with change tracking which variants have changed
private string _culture;
@@ -103,7 +103,7 @@ namespace Umbraco.Core.Models
// ReSharper disable once ClassNeverInstantiated.Local
private class PropertySelectors
{
- //TODO: This allows us to track changes for an entire Property, but doesn't allow us to track changes at the variant level
+ // TODO: This allows us to track changes for an entire Property, but doesn't allow us to track changes at the variant level
public readonly PropertyInfo ValuesSelector = ExpressionHelper.GetPropertyInfo(x => x.Values);
public readonly DelegateEqualityComparer
bool IsDraft(string culture = null);
- // fixme - consider having an IsPublished flag too
- // so that when IsDraft is true, we can check whether there is a published version?
+ ///
+ /// Gets a value indicating whether the content is published.
+ ///
+ ///
+ /// A content is published when it has a published version.
+ /// When retrieving documents from cache in non-preview mode, IsPublished is always
+ /// true, as only published documents are returned. When retrieving in draft mode, IsPublished
+ /// can either be true (document has a published version) or false (document has no
+ /// published version).
+ /// It is therefore possible for both IsDraft and IsPublished to be true at the same
+ /// time, meaning that the content is the draft version, and a published version exists.
+ ///
+ bool IsPublished(string culture = null);
#endregion
diff --git a/src/Umbraco.Core/Models/PublishedContent/IPublishedModelFactory.cs b/src/Umbraco.Core/Models/PublishedContent/IPublishedModelFactory.cs
index 25d9643bed..ae4caf352e 100644
--- a/src/Umbraco.Core/Models/PublishedContent/IPublishedModelFactory.cs
+++ b/src/Umbraco.Core/Models/PublishedContent/IPublishedModelFactory.cs
@@ -24,10 +24,10 @@ namespace Umbraco.Core.Models.PublishedContent
IList CreateModelList(string alias);
///
- /// Maps a Clr type that may contain model types, to an actual Clr type.
+ /// Maps a CLR type that may contain model types, to an actual CLR type.
///
- /// The Clr type.
- /// The actual Clr type.
+ /// The CLR type.
+ /// The actual CLR type.
/// See for more details.
Type MapModelType(Type type);
}
diff --git a/src/Umbraco.Core/Models/PublishedContent/IPublishedProperty.cs b/src/Umbraco.Core/Models/PublishedContent/IPublishedProperty.cs
index cfab82213a..9a00e94d3e 100644
--- a/src/Umbraco.Core/Models/PublishedContent/IPublishedProperty.cs
+++ b/src/Umbraco.Core/Models/PublishedContent/IPublishedProperty.cs
@@ -29,7 +29,7 @@
/// Gets the source value of the property.
///
///
- /// The source value is whatever was passed to the property when it was instanciated, and it is
+ /// The source value is whatever was passed to the property when it was instantiated, and it is
/// somewhat implementation-dependent -- depending on how the IPublishedCache is implemented.
/// The XmlPublishedCache source values are strings exclusively since they come from the Xml cache.
/// For other caches that get their source value from the database, it would be either a string,
diff --git a/src/Umbraco.Core/Models/PublishedContent/IPublishedValueFallback.cs b/src/Umbraco.Core/Models/PublishedContent/IPublishedValueFallback.cs
index f30a53c8b6..23df9e485f 100644
--- a/src/Umbraco.Core/Models/PublishedContent/IPublishedValueFallback.cs
+++ b/src/Umbraco.Core/Models/PublishedContent/IPublishedValueFallback.cs
@@ -94,12 +94,17 @@
/// A fallback strategy.
/// An optional default value.
/// The fallback value.
+ /// The property that does not have a value.
/// A value indicating whether a fallback value could be provided.
///
/// This method is called whenever getting the property value for the specified alias, culture and
/// segment, either returned no property at all, or a property with HasValue(culture, segment) being false.
+ /// In an , because walking up the tree is possible, the content itself may not even
+ /// have a property with the specified alias, but such a property may exist up in the tree. The
+ /// parameter is used to return a property with no value. That can then be used to invoke a converter and get the
+ /// converter's interpretation of "no value".
///
- bool TryGetValue(IPublishedContent content, string alias, string culture, string segment, Fallback fallback, object defaultValue, out object value);
+ bool TryGetValue(IPublishedContent content, string alias, string culture, string segment, Fallback fallback, object defaultValue, out object value, out IPublishedProperty noValueProperty);
///
/// Tries to get a fallback value for a published content property.
@@ -112,11 +117,16 @@
/// A fallback strategy.
/// An optional default value.
/// The fallback value.
+ /// The property that does not have a value.
/// A value indicating whether a fallback value could be provided.
///
/// This method is called whenever getting the property value for the specified alias, culture and
/// segment, either returned no property at all, or a property with HasValue(culture, segment) being false.
+ /// In an , because walking up the tree is possible, the content itself may not even
+ /// have a property with the specified alias, but such a property may exist up in the tree. The
+ /// parameter is used to return a property with no value. That can then be used to invoke a converter and get the
+ /// converter's interpretation of "no value".
///
- bool TryGetValue(IPublishedContent content, string alias, string culture, string segment, Fallback fallback, T defaultValue, out T value);
+ bool TryGetValue(IPublishedContent content, string alias, string culture, string segment, Fallback fallback, T defaultValue, out T value, out IPublishedProperty noValueProperty);
}
}
diff --git a/src/Umbraco.Core/Models/PublishedContent/ModelType.cs b/src/Umbraco.Core/Models/PublishedContent/ModelType.cs
index a366742cc5..540abda2c5 100644
--- a/src/Umbraco.Core/Models/PublishedContent/ModelType.cs
+++ b/src/Umbraco.Core/Models/PublishedContent/ModelType.cs
@@ -9,7 +9,7 @@ namespace Umbraco.Core.Models.PublishedContent
{
///
///
- /// Represents the Clr type of a model.
+ /// Represents the CLR type of a model.
///
///
/// ModelType.For("alias")
@@ -43,11 +43,11 @@ namespace Umbraco.Core.Models.PublishedContent
=> new ModelType(alias);
///
- /// Gets the actual Clr type by replacing model types, if any.
+ /// Gets the actual CLR type by replacing model types, if any.
///
/// The type.
/// The model types map.
- /// The actual Clr type.
+ /// The actual CLR type.
public static Type Map(Type type, Dictionary modelTypes)
=> Map(type, modelTypes, false);
@@ -82,11 +82,11 @@ namespace Umbraco.Core.Models.PublishedContent
}
///
- /// Gets the actual Clr type name by replacing model types, if any.
+ /// Gets the actual CLR type name by replacing model types, if any.
///
/// The type.
/// The model types map.
- /// The actual Clr type name.
+ /// The actual CLR type name.
public static string MapToName(Type type, Dictionary map)
=> MapToName(type, map, false);
diff --git a/src/Umbraco.Core/Models/PublishedContent/NoopPublishedValueFallback.cs b/src/Umbraco.Core/Models/PublishedContent/NoopPublishedValueFallback.cs
index cd7b063d44..245bbd1d39 100644
--- a/src/Umbraco.Core/Models/PublishedContent/NoopPublishedValueFallback.cs
+++ b/src/Umbraco.Core/Models/PublishedContent/NoopPublishedValueFallback.cs
@@ -37,16 +37,18 @@
}
///
- public bool TryGetValue(IPublishedContent content, string alias, string culture, string segment, Fallback fallback, object defaultValue, out object value)
+ public bool TryGetValue(IPublishedContent content, string alias, string culture, string segment, Fallback fallback, object defaultValue, out object value, out IPublishedProperty noValueProperty)
{
value = default;
+ noValueProperty = default;
return false;
}
///
- public bool TryGetValue(IPublishedContent content, string alias, string culture, string segment, Fallback fallback, T defaultValue, out T value)
+ public bool TryGetValue(IPublishedContent content, string alias, string culture, string segment, Fallback fallback, T defaultValue, out T value, out IPublishedProperty noValueProperty)
{
value = default;
+ noValueProperty = default;
return false;
}
}
diff --git a/src/Umbraco.Core/Models/PublishedContent/PublishedContentEnumerable.cs b/src/Umbraco.Core/Models/PublishedContent/PublishedContentEnumerable.cs
deleted file mode 100644
index dc17265bb9..0000000000
--- a/src/Umbraco.Core/Models/PublishedContent/PublishedContentEnumerable.cs
+++ /dev/null
@@ -1,64 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Linq;
-
-namespace Umbraco.Core.Models.PublishedContent
-{
- // fixme imported from 7.6 needs better explaination of what it is
-
- ///
- /// The published content enumerable, this model is to allow ToString to be overriden for value converters to support legacy requests for string values
- ///
- public class PublishedContentEnumerable : IEnumerable
- {
- ///
- /// The items in the collection
- ///
- private readonly IEnumerable _items;
-
- ///
- /// Initializes a new instance of the class.
- ///
- ///
- /// The published content items
- ///
- public PublishedContentEnumerable(IEnumerable publishedContent)
- {
- _items = publishedContent ?? throw new ArgumentNullException(nameof(publishedContent));
- }
-
- ///
- /// The ToString method to convert the objects back to CSV
- ///
- ///
- /// The .
- ///
- public override string ToString()
- {
- return string.Join(",", _items.Select(x => x.Id));
- }
-
- ///
- /// The get enumerator.
- ///
- ///
- /// The .
- ///
- public IEnumerator GetEnumerator()
- {
- return _items.GetEnumerator();
- }
-
- ///
- /// The get enumerator.
- ///
- ///
- /// The .
- ///
- IEnumerator IEnumerable.GetEnumerator()
- {
- return GetEnumerator();
- }
- }
-}
diff --git a/src/Umbraco.Core/Models/PublishedContent/PublishedContentType.cs b/src/Umbraco.Core/Models/PublishedContent/PublishedContentType.cs
index f1937c1c0c..0798e9a4e0 100644
--- a/src/Umbraco.Core/Models/PublishedContent/PublishedContentType.cs
+++ b/src/Umbraco.Core/Models/PublishedContent/PublishedContentType.cs
@@ -20,7 +20,7 @@ namespace Umbraco.Core.Models.PublishedContent
/// Initializes a new instance of the class with a content type.
///
public PublishedContentType(IContentTypeComposition contentType, IPublishedContentTypeFactory factory)
- : this(contentType.Id, contentType.Alias, contentType.GetItemType(), contentType.CompositionAliases(), contentType.Variations)
+ : this(contentType.Id, contentType.Alias, contentType.GetItemType(), contentType.CompositionAliases(), contentType.Variations, contentType.IsElement)
{
var propertyTypes = contentType.CompositionPropertyTypes
.Select(x => factory.CreatePropertyType(this, x))
@@ -41,8 +41,8 @@ namespace Umbraco.Core.Models.PublishedContent
/// This constructor is for tests and is not intended to be used directly from application code.
/// Values are assumed to be consisted and are not checked.
///
- public PublishedContentType(int id, string alias, PublishedItemType itemType, IEnumerable compositionAliases, IEnumerable propertyTypes, ContentVariation variations)
- : this (id, alias, itemType, compositionAliases, variations)
+ public PublishedContentType(int id, string alias, PublishedItemType itemType, IEnumerable compositionAliases, IEnumerable propertyTypes, ContentVariation variations, bool isElement = false)
+ : this (id, alias, itemType, compositionAliases, variations, isElement)
{
var propertyTypesA = propertyTypes.ToArray();
foreach (var propertyType in propertyTypesA)
@@ -52,13 +52,14 @@ namespace Umbraco.Core.Models.PublishedContent
InitializeIndexes();
}
- private PublishedContentType(int id, string alias, PublishedItemType itemType, IEnumerable compositionAliases, ContentVariation variations)
+ private PublishedContentType(int id, string alias, PublishedItemType itemType, IEnumerable compositionAliases, ContentVariation variations, bool isElement)
{
Id = id;
Alias = alias;
ItemType = itemType;
CompositionAliases = new HashSet(compositionAliases, StringComparer.InvariantCultureIgnoreCase);
Variations = variations;
+ IsElement = isElement;
}
private void InitializeIndexes()
@@ -85,7 +86,7 @@ namespace Umbraco.Core.Models.PublishedContent
}
}
- // fixme - this list somehow also exists in constants, see memberTypeRepository => remove duplicate!
+ // TODO: this list somehow also exists in constants, see memberTypeRepository => remove duplicate!
private static readonly Dictionary BuiltinMemberProperties = new Dictionary
{
{ "Email", (Constants.DataTypes.Textbox, Constants.PropertyEditors.Aliases.TextBox) },
@@ -147,7 +148,8 @@ namespace Umbraco.Core.Models.PublishedContent
return -1;
}
- // virtual for unit tests - fixme explain
+ // virtual for unit tests
+ // TODO: explain why
///
/// Gets a property type.
///
@@ -157,7 +159,8 @@ namespace Umbraco.Core.Models.PublishedContent
return GetPropertyType(index);
}
- // virtual for unit tests - fixme explain
+ // virtual for unit tests
+ // TODO: explain why
///
/// Gets a property type.
///
@@ -166,6 +169,11 @@ namespace Umbraco.Core.Models.PublishedContent
return index >= 0 && index < _propertyTypes.Length ? _propertyTypes[index] : null;
}
+ ///
+ /// Gets a value indicating whether this content type is for an element.
+ ///
+ public bool IsElement { get; }
+
#endregion
}
}
diff --git a/src/Umbraco.Core/Models/PublishedContent/PublishedContentTypeFactory.cs b/src/Umbraco.Core/Models/PublishedContent/PublishedContentTypeFactory.cs
index 5de5842eda..abf4156d7f 100644
--- a/src/Umbraco.Core/Models/PublishedContent/PublishedContentTypeFactory.cs
+++ b/src/Umbraco.Core/Models/PublishedContent/PublishedContentTypeFactory.cs
@@ -32,15 +32,15 @@ namespace Umbraco.Core.Models.PublishedContent
}
// for tests
- internal PublishedContentType CreateContentType(int id, string alias, IEnumerable propertyTypes, ContentVariation variations = ContentVariation.Nothing)
+ internal PublishedContentType CreateContentType(int id, string alias, IEnumerable propertyTypes, ContentVariation variations = ContentVariation.Nothing, bool isElement = false)
{
- return new PublishedContentType(id, alias, PublishedItemType.Content, Enumerable.Empty(), propertyTypes, variations);
+ return new PublishedContentType(id, alias, PublishedItemType.Content, Enumerable.Empty(), propertyTypes, variations, isElement);
}
// for tests
- internal PublishedContentType CreateContentType(int id, string alias, IEnumerable compositionAliases, IEnumerable propertyTypes, ContentVariation variations = ContentVariation.Nothing)
+ internal PublishedContentType CreateContentType(int id, string alias, IEnumerable compositionAliases, IEnumerable propertyTypes, ContentVariation variations = ContentVariation.Nothing, bool isElement = false)
{
- return new PublishedContentType(id, alias, PublishedItemType.Content, compositionAliases, propertyTypes, variations);
+ return new PublishedContentType(id, alias, PublishedItemType.Content, compositionAliases, propertyTypes, variations, isElement);
}
///
@@ -79,7 +79,7 @@ namespace Umbraco.Core.Models.PublishedContent
}
if (!publishedDataTypes.TryGetValue(id, out var dataType))
- throw new ArgumentException("Not a valid datatype identifier.", nameof(id));
+ throw new ArgumentException($"Could not find a datatype with identifier {id}.", nameof(id));
return dataType;
}
diff --git a/src/Umbraco.Core/Models/PublishedContent/PublishedContentWrapped.cs b/src/Umbraco.Core/Models/PublishedContent/PublishedContentWrapped.cs
index 36755c8944..8bf8cec244 100644
--- a/src/Umbraco.Core/Models/PublishedContent/PublishedContentWrapped.cs
+++ b/src/Umbraco.Core/Models/PublishedContent/PublishedContentWrapped.cs
@@ -111,6 +111,9 @@ namespace Umbraco.Core.Models.PublishedContent
///
public virtual bool IsDraft(string culture = null) => _content.IsDraft(culture);
+ ///
+ public virtual bool IsPublished(string culture = null) => _content.IsPublished(culture);
+
#endregion
#region Tree
diff --git a/src/Umbraco.Core/Models/PublishedContent/PublishedDataType.cs b/src/Umbraco.Core/Models/PublishedContent/PublishedDataType.cs
index f3f10e63e2..566319ab74 100644
--- a/src/Umbraco.Core/Models/PublishedContent/PublishedDataType.cs
+++ b/src/Umbraco.Core/Models/PublishedContent/PublishedDataType.cs
@@ -31,7 +31,7 @@ namespace Umbraco.Core.Models.PublishedContent
public int Id { get; }
///
- /// Gets the dat type editor alias.
+ /// Gets the data type editor alias.
///
public string EditorAlias { get; }
diff --git a/src/Umbraco.Core/Models/PublishedContent/PublishedPropertyType.cs b/src/Umbraco.Core/Models/PublishedContent/PublishedPropertyType.cs
index e019f9a5d1..68892fd79a 100644
--- a/src/Umbraco.Core/Models/PublishedContent/PublishedPropertyType.cs
+++ b/src/Umbraco.Core/Models/PublishedContent/PublishedPropertyType.cs
@@ -12,7 +12,7 @@ namespace Umbraco.Core.Models.PublishedContent
/// if the property type changes, then a new class needs to be created.
public class PublishedPropertyType
{
- //fixme - API design review, should this be an interface?
+ // TODO: API design review, should this be an interface?
private readonly IPublishedModelFactory _publishedModelFactory;
private readonly PropertyValueConverterCollection _propertyValueConverters;
@@ -283,11 +283,11 @@ namespace Umbraco.Core.Models.PublishedContent
}
///
- /// Gets the property model Clr type.
+ /// Gets the property model CLR type.
///
///
- /// The model Clr type may be a type, or may contain types.
- /// For the actual Clr type, see .
+ /// The model CLR type may be a type, or may contain types.
+ /// For the actual CLR type, see .
///
public Type ModelClrType
{
@@ -299,12 +299,12 @@ namespace Umbraco.Core.Models.PublishedContent
}
///
- /// Gets the property Clr type.
+ /// Gets the property CLR type.
///
///
- /// Returns the actual Clr type which does not contain types.
+ /// Returns the actual CLR type which does not contain types.
/// Mapping from may throw if some instances
- /// could not be mapped to actual Clr types.
+ /// could not be mapped to actual CLR types.
///
public Type ClrType
{
diff --git a/src/Umbraco.Core/Models/Section.cs b/src/Umbraco.Core/Models/Section.cs
deleted file mode 100644
index 4b7f8309dd..0000000000
--- a/src/Umbraco.Core/Models/Section.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-namespace Umbraco.Core.Models
-{
- ///
- /// Represents a section defined in the app.config file.
- ///
- public class Section
- {
- public Section(string name, string @alias, int sortOrder)
- {
- Name = name;
- Alias = alias;
- SortOrder = sortOrder;
- }
-
- public Section()
- { }
-
- public string Name { get; set; }
- public string Alias { get; set; }
- public int SortOrder { get; set; }
- }
-}
diff --git a/src/Umbraco.Core/Models/ServerRegistration.cs b/src/Umbraco.Core/Models/ServerRegistration.cs
index 0e135f34d6..db0e9b8c3b 100644
--- a/src/Umbraco.Core/Models/ServerRegistration.cs
+++ b/src/Umbraco.Core/Models/ServerRegistration.cs
@@ -26,13 +26,13 @@ namespace Umbraco.Core.Models
}
///
- /// Initialiazes a new instance of the class.
+ /// Initializes a new instance of the class.
///
public ServerRegistration()
{ }
///
- /// Initialiazes a new instance of the class.
+ /// Initializes a new instance of the class.
///
/// The unique id of the server registration.
/// The server url.
@@ -54,7 +54,7 @@ namespace Umbraco.Core.Models
}
///
- /// Initialiazes a new instance of the class.
+ /// Initializes a new instance of the class.
///
/// The server url.
/// The unique server identity.
diff --git a/src/Umbraco.Core/Models/Trees/IBackOfficeSection.cs b/src/Umbraco.Core/Models/Trees/IBackOfficeSection.cs
new file mode 100644
index 0000000000..86e2a18fd5
--- /dev/null
+++ b/src/Umbraco.Core/Models/Trees/IBackOfficeSection.cs
@@ -0,0 +1,18 @@
+namespace Umbraco.Core.Models.Trees
+{
+ ///
+ /// Defines a back office section.
+ ///
+ public interface IBackOfficeSection
+ {
+ ///
+ /// Gets the alias of the section.
+ ///
+ string Alias { get; }
+
+ ///
+ /// Gets the name of the section.
+ ///
+ string Name { get; }
+ }
+}
diff --git a/src/Umbraco.Core/Models/UmbracoObjectTypes.cs b/src/Umbraco.Core/Models/UmbracoObjectTypes.cs
index ff080f2cc1..6f7272beee 100644
--- a/src/Umbraco.Core/Models/UmbracoObjectTypes.cs
+++ b/src/Umbraco.Core/Models/UmbracoObjectTypes.cs
@@ -5,7 +5,7 @@ using Umbraco.Core.CodeAnnotations;
namespace Umbraco.Core.Models
{
///
- /// Enum used to represent the Umbraco Object Types and thier associated GUIDs
+ /// Enum used to represent the Umbraco Object Types and their associated GUIDs
///
public enum UmbracoObjectTypes
{
diff --git a/src/Umbraco.Core/Models/UserExtensions.cs b/src/Umbraco.Core/Models/UserExtensions.cs
index ba4d8cf590..f9aa1113b3 100644
--- a/src/Umbraco.Core/Models/UserExtensions.cs
+++ b/src/Umbraco.Core/Models/UserExtensions.cs
@@ -47,19 +47,19 @@ namespace Umbraco.Core.Models
}
///
- /// Tries to lookup the user's gravatar to see if the endpoint can be reached, if so it returns the valid URL
+ /// Tries to lookup the user's Gravatar to see if the endpoint can be reached, if so it returns the valid URL
///
///
- ///
+ ///
///
/// A list of 5 different sized avatar URLs
///
- internal static string[] GetUserAvatarUrls(this IUser user, ICacheProvider staticCache)
+ internal static string[] GetUserAvatarUrls(this IUser user, IAppCache cache)
{
// If FIPS is required, never check the Gravatar service as it only supports MD5 hashing.
// Unfortunately, if the FIPS setting is enabled on Windows, using MD5 will throw an exception
// and the website will not run.
- // Also, check if the user has explicitly removed all avatars including a gravatar, this will be possible and the value will be "none"
+ // Also, check if the user has explicitly removed all avatars including a Gravatar, this will be possible and the value will be "none"
if (user.Avatar == "none" || CryptoConfig.AllowOnlyFipsAlgorithms)
{
return new string[0];
@@ -70,8 +70,8 @@ namespace Umbraco.Core.Models
var gravatarHash = user.Email.ToMd5();
var gravatarUrl = "https://www.gravatar.com/avatar/" + gravatarHash + "?d=404";
- //try gravatar
- var gravatarAccess = staticCache.GetCacheItem("UserAvatar" + user.Id, () =>
+ //try Gravatar
+ var gravatarAccess = cache.GetCacheItem("UserAvatar" + user.Id, () =>
{
// Test if we can reach this URL, will fail when there's network or firewall errors
var request = (HttpWebRequest)WebRequest.Create(gravatarUrl);
@@ -136,7 +136,7 @@ namespace Umbraco.Core.Models
try
{
var culture = CultureInfo.GetCultureInfo(userLanguage.Replace("_", "-"));
- //TODO: This is a hack because we store the user language as 2 chars instead of the full culture
+ // TODO: This is a hack because we store the user language as 2 chars instead of the full culture
// which is actually stored in the language files (which are also named with 2 chars!) so we need to attempt
// to convert to a supported full culture
var result = textService.ConvertToSupportedCultureWithRegionCode(culture);
diff --git a/src/Umbraco.Core/NetworkHelper.cs b/src/Umbraco.Core/NetworkHelper.cs
index 8f310ccf0c..8f7c7c1eb8 100644
--- a/src/Umbraco.Core/NetworkHelper.cs
+++ b/src/Umbraco.Core/NetworkHelper.cs
@@ -38,7 +38,7 @@ namespace Umbraco.Core
catch
{
//if we get here it means we cannot access the machine name
- throw new ApplicationException("Cannot resolve the current machine name eithe by Environment.MachineName or by Dns.GetHostname()");
+ throw new ApplicationException("Cannot resolve the current machine name either by Environment.MachineName or by Dns.GetHostname()");
}
}
}
diff --git a/src/Umbraco.Core/ObjectExtensions.cs b/src/Umbraco.Core/ObjectExtensions.cs
index 1bc2fb48a5..68bc9c923d 100644
--- a/src/Umbraco.Core/ObjectExtensions.cs
+++ b/src/Umbraco.Core/ObjectExtensions.cs
@@ -143,7 +143,7 @@ namespace Umbraco.Core
// Special case for empty strings for bools/dates which should return null if an empty string.
if (input is string inputString)
{
- //TODO: Why the check against only bool/date when a string is null/empty? In what scenario can we convert to another type when the string is null or empty other than just being null?
+ // TODO: Why the check against only bool/date when a string is null/empty? In what scenario can we convert to another type when the string is null or empty other than just being null?
if (string.IsNullOrEmpty(inputString) && (underlying == typeof(DateTime) || underlying == typeof(bool)))
{
return Attempt.Succeed(null);
@@ -153,7 +153,7 @@ namespace Umbraco.Core
// Recursively call into this method with the inner (not-nullable) type and handle the outcome
var inner = input.TryConvertTo(underlying);
- // And if sucessful, fall on through to rewrap in a nullable; if failed, pass on the exception
+ // And if successful, fall on through to rewrap in a nullable; if failed, pass on the exception
if (inner.Success)
{
input = inner.Result; // Now fall on through...
@@ -216,7 +216,7 @@ namespace Umbraco.Core
return Attempt.Succeed(input);
}
- // Re-check convertables since we altered the input through recursion
+ // Re-check convertibles since we altered the input through recursion
if (input is IConvertible convertible2)
{
return Attempt.Succeed(Convert.ChangeType(convertible2, target));
@@ -391,7 +391,7 @@ namespace Umbraco.Core
}
internal static void CheckThrowObjectDisposed(this IDisposable disposable, bool isDisposed, string objectname)
{
- //TODO: Localise this exception
+ // TODO: Localize this exception
if (isDisposed)
throw new ObjectDisposedException(objectname);
}
diff --git a/src/Umbraco.Web/_Legacy/PackageActions/allowDoctype.cs b/src/Umbraco.Core/PackageActions/AllowDoctype.cs
similarity index 94%
rename from src/Umbraco.Web/_Legacy/PackageActions/allowDoctype.cs
rename to src/Umbraco.Core/PackageActions/AllowDoctype.cs
index f4b206a9ad..2e37061c31 100644
--- a/src/Umbraco.Web/_Legacy/PackageActions/allowDoctype.cs
+++ b/src/Umbraco.Core/PackageActions/AllowDoctype.cs
@@ -1,14 +1,10 @@
-using System;
-using System.Collections;
+using System.Collections;
using System.Linq;
-using System.Xml;
using System.Xml.Linq;
-using Umbraco.Core;
+using Umbraco.Core.Composing;
using Umbraco.Core.Models;
-using Umbraco.Core._Legacy.PackageActions;
-using Umbraco.Web.Composing;
-namespace Umbraco.Web._Legacy.PackageActions
+namespace Umbraco.Core.PackageActions
{
///
/// This class implements the IPackageAction Interface, used to execute code when packages are installed.
diff --git a/src/Umbraco.Core/_Legacy/PackageActions/IPackageAction.cs b/src/Umbraco.Core/PackageActions/IPackageAction.cs
similarity index 80%
rename from src/Umbraco.Core/_Legacy/PackageActions/IPackageAction.cs
rename to src/Umbraco.Core/PackageActions/IPackageAction.cs
index b58ea34a60..d4dfb4079b 100644
--- a/src/Umbraco.Core/_Legacy/PackageActions/IPackageAction.cs
+++ b/src/Umbraco.Core/PackageActions/IPackageAction.cs
@@ -1,8 +1,7 @@
-using System.Xml;
using System.Xml.Linq;
using Umbraco.Core.Composing;
-namespace Umbraco.Core._Legacy.PackageActions
+namespace Umbraco.Core.PackageActions
{
public interface IPackageAction : IDiscoverable
{
diff --git a/src/Umbraco.Core/_Legacy/PackageActions/PackageActionCollection.cs b/src/Umbraco.Core/PackageActions/PackageActionCollection.cs
similarity index 86%
rename from src/Umbraco.Core/_Legacy/PackageActions/PackageActionCollection.cs
rename to src/Umbraco.Core/PackageActions/PackageActionCollection.cs
index a38c8cea56..813695f84c 100644
--- a/src/Umbraco.Core/_Legacy/PackageActions/PackageActionCollection.cs
+++ b/src/Umbraco.Core/PackageActions/PackageActionCollection.cs
@@ -1,7 +1,7 @@
using System.Collections.Generic;
using Umbraco.Core.Composing;
-namespace Umbraco.Core._Legacy.PackageActions
+namespace Umbraco.Core.PackageActions
{
public sealed class PackageActionCollection : BuilderCollectionBase
{
diff --git a/src/Umbraco.Core/_Legacy/PackageActions/PackageActionCollectionBuilder.cs b/src/Umbraco.Core/PackageActions/PackageActionCollectionBuilder.cs
similarity index 85%
rename from src/Umbraco.Core/_Legacy/PackageActions/PackageActionCollectionBuilder.cs
rename to src/Umbraco.Core/PackageActions/PackageActionCollectionBuilder.cs
index 2f73a2b489..fdb118ae06 100644
--- a/src/Umbraco.Core/_Legacy/PackageActions/PackageActionCollectionBuilder.cs
+++ b/src/Umbraco.Core/PackageActions/PackageActionCollectionBuilder.cs
@@ -1,6 +1,6 @@
using Umbraco.Core.Composing;
-namespace Umbraco.Core._Legacy.PackageActions
+namespace Umbraco.Core.PackageActions
{
internal class PackageActionCollectionBuilder : LazyCollectionBuilderBase
{
diff --git a/src/Umbraco.Web/_Legacy/PackageActions/publishRootDocument.cs b/src/Umbraco.Core/PackageActions/PublishRootDocument.cs
similarity index 89%
rename from src/Umbraco.Web/_Legacy/PackageActions/publishRootDocument.cs
rename to src/Umbraco.Core/PackageActions/PublishRootDocument.cs
index f4bd7dd4fc..55955a4c8f 100644
--- a/src/Umbraco.Web/_Legacy/PackageActions/publishRootDocument.cs
+++ b/src/Umbraco.Core/PackageActions/PublishRootDocument.cs
@@ -1,11 +1,7 @@
-using System;
-using System.Xml;
-using System.Xml.Linq;
-using Umbraco.Core;
-using Umbraco.Core._Legacy.PackageActions;
-using Umbraco.Web.Composing;
+using System.Xml.Linq;
+using Umbraco.Core.Composing;
-namespace Umbraco.Web._Legacy.PackageActions
+namespace Umbraco.Core.PackageActions
{
///
/// This class implements the IPackageAction Interface, used to execute code when packages are installed.
@@ -35,7 +31,7 @@ namespace Umbraco.Web._Legacy.PackageActions
{
if (rootDoc.Name.Trim() == documentName.Trim() && rootDoc.ContentType != null)
{
- // fixme variants?
+ // TODO: variants?
Current.Services.ContentService.SaveAndPublishBranch(rootDoc, true);
break;
}
diff --git a/src/Umbraco.Core/Packaging/CompiledPackageXmlParser.cs b/src/Umbraco.Core/Packaging/CompiledPackageXmlParser.cs
index 0d533cfbc2..8dccf73814 100644
--- a/src/Umbraco.Core/Packaging/CompiledPackageXmlParser.cs
+++ b/src/Umbraco.Core/Packaging/CompiledPackageXmlParser.cs
@@ -51,7 +51,7 @@ namespace Umbraco.Core.Packaging
IconUrl = package.Element("iconUrl")?.Value,
UmbracoVersion = new Version((int)requirements.Element("major"), (int)requirements.Element("minor"), (int)requirements.Element("patch")),
UmbracoVersionRequirementsType = requirements.AttributeValue("type").IsNullOrWhiteSpace() ? RequirementsType.Legacy : Enum.Parse(requirements.AttributeValue("type"), true),
- Control = package.Element("control")?.Value,
+ PackageView = xml.Root.Element("view")?.Value,
Actions = xml.Root.Element("Actions")?.ToString(SaveOptions.None) ?? "", //take the entire outer xml value
Files = xml.Root.Element("files")?.Elements("file")?.Select(CompiledPackageFile.Create).ToList() ?? new List(),
Macros = xml.Root.Element("Macros")?.Elements("macro") ?? Enumerable.Empty(),
@@ -153,7 +153,7 @@ namespace Umbraco.Core.Packaging
{
if (actionsElement == null) return Enumerable.Empty();
- //invariant check ... because people can realy enter anything :/
+ //invariant check ... because people can really enter anything :/
if (!string.Equals("actions", actionsElement.Name.LocalName, StringComparison.InvariantCultureIgnoreCase))
throw new FormatException("Must be \"\" as root");
@@ -161,7 +161,7 @@ namespace Umbraco.Core.Packaging
var actionElementName = actionsElement.Elements().First().Name.LocalName;
- //invariant check ... because people can realy enter anything :/
+ //invariant check ... because people can really enter anything :/
if (!string.Equals("action", actionElementName, StringComparison.InvariantCultureIgnoreCase))
throw new FormatException("Must be \"
- /// This will run the uninstallation sequence for this
+ /// This will run the uninstall sequence for this
///
///
///
diff --git a/src/Umbraco.Core/Packaging/PackageActionRunner.cs b/src/Umbraco.Core/Packaging/PackageActionRunner.cs
index 38275d5f0a..8434f52f30 100644
--- a/src/Umbraco.Core/Packaging/PackageActionRunner.cs
+++ b/src/Umbraco.Core/Packaging/PackageActionRunner.cs
@@ -2,12 +2,12 @@
using System.Collections.Generic;
using System.Xml.Linq;
using Umbraco.Core.Logging;
-using Umbraco.Core._Legacy.PackageActions;
+using Umbraco.Core.PackageActions;
namespace Umbraco.Core.Packaging
{
///
- /// Package actions are executed on packge install / uninstall.
+ /// Package actions are executed on package install / uninstall.
///
internal class PackageActionRunner : IPackageActionRunner
{
diff --git a/src/Umbraco.Core/Packaging/PackageDataInstallation.cs b/src/Umbraco.Core/Packaging/PackageDataInstallation.cs
index 2e9fee9595..a569954629 100644
--- a/src/Umbraco.Core/Packaging/PackageDataInstallation.cs
+++ b/src/Umbraco.Core/Packaging/PackageDataInstallation.cs
@@ -100,7 +100,7 @@ namespace Umbraco.Core.Packaging
//Order the DocumentTypes before removing them
if (contentTypes.Any())
{
- //TODO: I don't think this ordering is necessary
+ // TODO: I don't think this ordering is necessary
var orderedTypes = (from contentType in contentTypes
orderby contentType.ParentId descending, contentType.Id descending
select contentType).ToList();
@@ -182,7 +182,7 @@ namespace Umbraco.Core.Packaging
/// Optional parent Id for the content being imported
/// A dictionary of already imported document types (basically used as a cache)
/// Optional Id of the user performing the import
- /// An enumrable list of generated content
+ /// An enumerable list of generated content
public IEnumerable ImportContent(CompiledPackageDocument packageDocument, int parentId, IDictionary importedDocumentTypes, int userId)
{
var element = packageDocument.XmlData;
@@ -343,7 +343,7 @@ namespace Umbraco.Core.Packaging
///
/// Xml to import
/// Optional id of the User performing the operation. Default is zero (admin).
- /// An enumrable list of generated ContentTypes
+ /// An enumerable list of generated ContentTypes
public IEnumerable ImportDocumentTypes(IEnumerable docTypeElements, int userId)
{
return ImportDocumentTypes(docTypeElements.ToList(), true, userId);
@@ -355,12 +355,12 @@ namespace Umbraco.Core.Packaging
/// Xml to import
/// Boolean indicating whether or not to import the
/// Optional id of the User performing the operation. Default is zero (admin).
- /// An enumrable list of generated ContentTypes
+ /// An enumerable list of generated ContentTypes
public IEnumerable ImportDocumentTypes(IReadOnlyCollection unsortedDocumentTypes, bool importStructure, int userId)
{
var importedContentTypes = new Dictionary();
- //When you are importing a single doc type we have to assume that the depedencies are already there.
+ //When you are importing a single doc type we have to assume that the dependencies are already there.
//Otherwise something like uSync won't work.
var graph = new TopoGraph>(x => x.Key, x => x.Dependencies);
var isSingleDocTypeImport = unsortedDocumentTypes.Count == 1;
@@ -437,7 +437,7 @@ namespace Umbraco.Core.Packaging
if (importStructure)
{
var updatedContentTypes = new List();
- //Update the structure here - we can't do it untill all DocTypes have been created
+ //Update the structure here - we can't do it until all DocTypes have been created
foreach (var documentType in documentTypes)
{
var alias = documentType.Element("Info").Element("Alias").Value;
@@ -710,7 +710,7 @@ namespace Umbraco.Core.Packaging
// This means that the property will not be created.
if (dataTypeDefinition == null)
{
- //TODO: We should expose this to the UI during install!
+ // TODO: We should expose this to the UI during install!
_logger.Warn("Packager: Error handling creation of PropertyType '{PropertyType}'. Could not find DataTypeDefintion with unique id '{DataTypeDefinitionId}' nor one referencing the DataType with a property editor alias (or legacy control id) '{PropertyEditorAlias}'. Did the package creator forget to package up custom datatypes? This property will be converted to a label/readonly editor if one exists.",
property.Element("Name").Value, dataTypeDefinitionId, property.Element("Type").Value.Trim());
@@ -796,7 +796,7 @@ namespace Umbraco.Core.Packaging
///
/// Xml to import
/// Optional id of the user
- /// An enumrable list of generated DataTypeDefinitions
+ /// An enumerable list of generated DataTypeDefinitions
public IEnumerable ImportDataTypes(IReadOnlyCollection dataTypeElements, int userId)
{
var dataTypes = new List();
@@ -815,7 +815,7 @@ namespace Umbraco.Core.Packaging
parentId = importedFolders[dataTypeDefinitionName];
var definition = _dataTypeService.GetDataType(dataTypeDefinitionId);
- //If the datatypedefinition doesn't already exist we create a new new according to the one in the package xml
+ //If the datatype definition doesn't already exist we create a new according to the one in the package xml
if (definition == null)
{
var databaseType = databaseTypeAttribute?.Value.EnumParse(true) ?? ValueStorageType.Ntext;
@@ -1195,7 +1195,7 @@ namespace Umbraco.Core.Packaging
///
/// Xml to import
/// Optional user id
- /// An enumrable list of generated Templates
+ /// An enumerable list of generated Templates
public IEnumerable ImportTemplates(IReadOnlyCollection templateElements, int userId)
{
var templates = new List();
@@ -1234,10 +1234,7 @@ namespace Umbraco.Core.Packaging
var alias = templateElement.Element("Alias").Value;
var design = templateElement.Element("Design").Value;
var masterElement = templateElement.Element("Master");
-
- var isMasterPage = IsMasterPageSyntax(design);
- var path = isMasterPage ? MasterpagePath(alias) : ViewPath(alias);
-
+
var existingTemplate = _fileService.GetTemplate(alias) as Template;
var template = existingTemplate ?? new Template(templateName, alias);
template.Content = design;
@@ -1257,23 +1254,11 @@ namespace Umbraco.Core.Packaging
return templates;
}
-
- private bool IsMasterPageSyntax(string code)
- {
- return Regex.IsMatch(code, @"<%@\s*Master", RegexOptions.IgnoreCase) ||
- code.InvariantContains("("packageGuid"),
IconUrl = xml.AttributeValue("iconUrl") ?? string.Empty,
UmbracoVersion = xml.AttributeValue("umbVersion"),
+ PackageView = xml.AttributeValue("view") ?? string.Empty,
License = xml.Element("license")?.Value ?? string.Empty,
LicenseUrl = xml.Element("license")?.AttributeValue("url") ?? string.Empty,
Author = xml.Element("author")?.Value ?? string.Empty,
@@ -49,8 +50,7 @@ namespace Umbraco.Core.Packaging
Languages = xml.Element("languages")?.Value.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList() ?? new List(),
DictionaryItems = xml.Element("dictionaryitems")?.Value.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList() ?? new List(),
DataTypes = xml.Element("datatypes")?.Value.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList() ?? new List(),
- Files = xml.Element("files")?.Elements("file").Select(x => x.Value).ToList() ?? new List(),
- Control = xml.Element("loadcontrol")?.Value ?? string.Empty
+ Files = xml.Element("files")?.Elements("file").Select(x => x.Value).ToList() ?? new List()
};
return retVal;
@@ -77,6 +77,7 @@ namespace Umbraco.Core.Packaging
new XAttribute("iconUrl", def.IconUrl ?? string.Empty),
new XAttribute("umbVersion", def.UmbracoVersion),
new XAttribute("packageGuid", def.PackageId),
+ new XAttribute("view", def.PackageView ?? string.Empty),
new XElement("license",
new XCData(def.License ?? string.Empty),
@@ -100,8 +101,7 @@ namespace Umbraco.Core.Packaging
new XElement("macros", string.Join(",", def.Macros ?? Array.Empty())),
new XElement("files", (def.Files ?? Array.Empty()).Where(x => !x.IsNullOrWhiteSpace()).Select(x => new XElement("file", x))),
new XElement("languages", string.Join(",", def.Languages ?? Array.Empty())),
- new XElement("dictionaryitems", string.Join(",", def.DictionaryItems ?? Array.Empty())),
- new XElement("loadcontrol", def.Control ?? string.Empty)); //fixme: no more loadcontrol, needs to be an angular view
+ new XElement("dictionaryitems", string.Join(",", def.DictionaryItems ?? Array.Empty())));
return packageXml;
}
diff --git a/src/Umbraco.Core/Packaging/PackageExtraction.cs b/src/Umbraco.Core/Packaging/PackageExtraction.cs
index 48093da45f..d3150f4409 100644
--- a/src/Umbraco.Core/Packaging/PackageExtraction.cs
+++ b/src/Umbraco.Core/Packaging/PackageExtraction.cs
@@ -56,7 +56,7 @@ namespace Umbraco.Core.Packaging
// Check if the file is a valid package
if (alowedExtension.All(ae => ae.InvariantEquals(extension) == false))
{
- throw new ArgumentException("Error - file isn't a package. only extentions: \"{string.Join(", ", alowedExtension)}\" is allowed");
+ throw new ArgumentException("Error - file isn't a package. only extensions: \"{string.Join(", ", alowedExtension)}\" is allowed");
}
}
diff --git a/src/Umbraco.Core/Packaging/PackageFileInstallation.cs b/src/Umbraco.Core/Packaging/PackageFileInstallation.cs
index 7c0891175b..29afc11d83 100644
--- a/src/Umbraco.Core/Packaging/PackageFileInstallation.cs
+++ b/src/Umbraco.Core/Packaging/PackageFileInstallation.cs
@@ -65,7 +65,7 @@ namespace Umbraco.Core.Packaging
var file = IOHelper.FindFile(item);
if (file != null)
{
- //TODO: Surely this should be ~/ ?
+ // TODO: Surely this should be ~/ ?
file = file.EnsureStartsWith("/");
var filePath = IOHelper.MapPath(file);
diff --git a/src/Umbraco.Core/Packaging/PackagesRepository.cs b/src/Umbraco.Core/Packaging/PackagesRepository.cs
index 249d02a320..05f67b3ed6 100644
--- a/src/Umbraco.Core/Packaging/PackagesRepository.cs
+++ b/src/Umbraco.Core/Packaging/PackagesRepository.cs
@@ -161,30 +161,30 @@ namespace Umbraco.Core.Packaging
try
{
//Init package file
- var packageManifest = CreatePackageManifest(out var manifestRoot, out var filesXml);
+ var compiledPackageXml = CreateCompiledPackageXml(out var root, out var filesXml);
//Info section
- manifestRoot.Add(GetPackageInfoXml(definition));
+ root.Add(GetPackageInfoXml(definition));
- PackageDocumentsAndTags(definition, manifestRoot);
- PackageDocumentTypes(definition, manifestRoot);
- PackageTemplates(definition, manifestRoot);
- PackageStylesheets(definition, manifestRoot);
- PackageMacros(definition, manifestRoot, filesXml, temporaryPath);
- PackageDictionaryItems(definition, manifestRoot);
- PackageLanguages(definition, manifestRoot);
- PackageDataTypes(definition, manifestRoot);
+ PackageDocumentsAndTags(definition, root);
+ PackageDocumentTypes(definition, root);
+ PackageTemplates(definition, root);
+ PackageStylesheets(definition, root);
+ PackageMacros(definition, root, filesXml, temporaryPath);
+ PackageDictionaryItems(definition, root);
+ PackageLanguages(definition, root);
+ PackageDataTypes(definition, root);
//Files
foreach (var fileName in definition.Files)
- AppendFileToManifest(fileName, temporaryPath, filesXml);
+ AppendFileToPackage(fileName, temporaryPath, filesXml);
- //Load control on install...
- if (!string.IsNullOrEmpty(definition.Control))
+ //Load view on install...
+ if (!string.IsNullOrEmpty(definition.PackageView))
{
- var control = new XElement("control", definition.Control);
- AppendFileToManifest(definition.Control, temporaryPath, filesXml);
- manifestRoot.Add(control);
+ var control = new XElement("view", definition.PackageView);
+ AppendFileToPackage(definition.PackageView, temporaryPath, filesXml);
+ root.Add(control);
}
//Actions
@@ -196,20 +196,20 @@ namespace Umbraco.Core.Packaging
//this will be formatted like a full xml block like ... and we want the child nodes
var parsed = XElement.Parse(definition.Actions);
actionsXml.Add(parsed.Elements());
- manifestRoot.Add(actionsXml);
+ root.Add(actionsXml);
}
catch (Exception e)
{
- _logger.Warn(e, "Could not add package actions to the package manifest, the xml did not parse");
+ _logger.Warn(e, "Could not add package actions to the package, the xml did not parse");
}
}
- var manifestFileName = temporaryPath + "/package.xml";
+ var packageXmlFileName = temporaryPath + "/package.xml";
- if (File.Exists(manifestFileName))
- File.Delete(manifestFileName);
+ if (File.Exists(packageXmlFileName))
+ File.Delete(packageXmlFileName);
- packageManifest.Save(manifestFileName);
+ compiledPackageXml.Save(packageXmlFileName);
// check if there's a packages directory below media
@@ -242,7 +242,7 @@ namespace Umbraco.Core.Packaging
throw new InvalidOperationException("Validation failed, there is invalid data on the model: " + string.Join(", ", results.Select(x => x.ErrorMessage)));
}
- private void PackageDataTypes(PackageDefinition definition, XContainer manifestRoot)
+ private void PackageDataTypes(PackageDefinition definition, XContainer root)
{
var dataTypes = new XElement("DataTypes");
foreach (var dtId in definition.DataTypes)
@@ -252,10 +252,10 @@ namespace Umbraco.Core.Packaging
if (dataType == null) continue;
dataTypes.Add(_serializer.Serialize(dataType));
}
- manifestRoot.Add(dataTypes);
+ root.Add(dataTypes);
}
- private void PackageLanguages(PackageDefinition definition, XContainer manifestRoot)
+ private void PackageLanguages(PackageDefinition definition, XContainer root)
{
var languages = new XElement("Languages");
foreach (var langId in definition.Languages)
@@ -265,10 +265,10 @@ namespace Umbraco.Core.Packaging
if (lang == null) continue;
languages.Add(_serializer.Serialize(lang));
}
- manifestRoot.Add(languages);
+ root.Add(languages);
}
- private void PackageDictionaryItems(PackageDefinition definition, XContainer manifestRoot)
+ private void PackageDictionaryItems(PackageDefinition definition, XContainer root)
{
var dictionaryItems = new XElement("DictionaryItems");
foreach (var dictionaryId in definition.DictionaryItems)
@@ -278,10 +278,10 @@ namespace Umbraco.Core.Packaging
if (di == null) continue;
dictionaryItems.Add(_serializer.Serialize(di, false));
}
- manifestRoot.Add(dictionaryItems);
+ root.Add(dictionaryItems);
}
- private void PackageMacros(PackageDefinition definition, XContainer manifestRoot, XContainer filesXml, string temporaryPath)
+ private void PackageMacros(PackageDefinition definition, XContainer root, XContainer filesXml, string temporaryPath)
{
var macros = new XElement("Macros");
foreach (var macroId in definition.Macros)
@@ -291,14 +291,14 @@ namespace Umbraco.Core.Packaging
var macroXml = GetMacroXml(outInt, out var macro);
if (macroXml == null) continue;
macros.Add(macroXml);
- //if the macro has a file copy it to the manifest
+ //if the macro has a file copy it to the xml
if (!string.IsNullOrEmpty(macro.MacroSource))
- AppendFileToManifest(macro.MacroSource, temporaryPath, filesXml);
+ AppendFileToPackage(macro.MacroSource, temporaryPath, filesXml);
}
- manifestRoot.Add(macros);
+ root.Add(macros);
}
- private void PackageStylesheets(PackageDefinition definition, XContainer manifestRoot)
+ private void PackageStylesheets(PackageDefinition definition, XContainer root)
{
var stylesheetsXml = new XElement("Stylesheets");
foreach (var stylesheetName in definition.Stylesheets)
@@ -308,10 +308,10 @@ namespace Umbraco.Core.Packaging
if (xml != null)
stylesheetsXml.Add(xml);
}
- manifestRoot.Add(stylesheetsXml);
+ root.Add(stylesheetsXml);
}
- private void PackageTemplates(PackageDefinition definition, XContainer manifestRoot)
+ private void PackageTemplates(PackageDefinition definition, XContainer root)
{
var templatesXml = new XElement("Templates");
foreach (var templateId in definition.Templates)
@@ -321,10 +321,10 @@ namespace Umbraco.Core.Packaging
if (template == null) continue;
templatesXml.Add(_serializer.Serialize(template));
}
- manifestRoot.Add(templatesXml);
+ root.Add(templatesXml);
}
- private void PackageDocumentTypes(PackageDefinition definition, XContainer manifestRoot)
+ private void PackageDocumentTypes(PackageDefinition definition, XContainer root)
{
var contentTypes = new HashSet();
var docTypesXml = new XElement("DocumentTypes");
@@ -338,10 +338,10 @@ namespace Umbraco.Core.Packaging
foreach (var contentType in contentTypes)
docTypesXml.Add(_serializer.Serialize(contentType));
- manifestRoot.Add(docTypesXml);
+ root.Add(docTypesXml);
}
- private void PackageDocumentsAndTags(PackageDefinition definition, XContainer manifestRoot)
+ private void PackageDocumentsAndTags(PackageDefinition definition, XContainer root)
{
//Documents and tags
if (string.IsNullOrEmpty(definition.ContentNodeId) == false && int.TryParse(definition.ContentNodeId, out var contentNodeId))
@@ -356,13 +356,13 @@ namespace Umbraco.Core.Packaging
//Create the Documents/DocumentSet node
- manifestRoot.Add(
+ root.Add(
new XElement("Documents",
new XElement("DocumentSet",
new XAttribute("importMode", "root"),
contentXml)));
- //TODO: I guess tags has been broken for a very long time for packaging, we should get this working again sometime
+ // TODO: I guess tags has been broken for a very long time for packaging, we should get this working again sometime
////Create the TagProperties node - this is used to store a definition for all
//// document properties that are tags, this ensures that we can re-import tags properly
//XmlNode tagProps = new XElement("TagProperties");
@@ -438,12 +438,12 @@ namespace Umbraco.Core.Packaging
}
///
- /// Appends a file to package manifest and copies the file to the correct folder.
+ /// Appends a file to package and copies the file to the correct folder.
///
/// The path.
/// The package directory.
/// The files xml node
- private static void AppendFileToManifest(string path, string packageDirectory, XContainer filesXml)
+ private static void AppendFileToPackage(string path, string packageDirectory, XContainer filesXml)
{
if (!path.StartsWith("~/") && !path.StartsWith("/"))
path = "~/" + path;
@@ -505,7 +505,7 @@ namespace Umbraco.Core.Packaging
/// Converts a umbraco stylesheet to a package xml node
///
/// The name of the stylesheet.
- /// if set to true [incluce properties].
+ /// if set to true [include properties].
///
private XElement GetStylesheetXml(string name, bool includeProperties)
{
@@ -584,12 +584,12 @@ namespace Umbraco.Core.Packaging
return info;
}
- private static XDocument CreatePackageManifest(out XElement root, out XElement files)
+ private static XDocument CreateCompiledPackageXml(out XElement root, out XElement files)
{
files = new XElement("files");
root = new XElement("umbPackage", files);
- var packageManifest = new XDocument(root);
- return packageManifest;
+ var compiledPackageXml = new XDocument(root);
+ return compiledPackageXml;
}
private XDocument EnsureStorage(out string packagesFile)
diff --git a/src/Umbraco.Core/Persistence/BulkDataReader.cs b/src/Umbraco.Core/Persistence/BulkDataReader.cs
index 6ede6a1859..1eaa88ee88 100644
--- a/src/Umbraco.Core/Persistence/BulkDataReader.cs
+++ b/src/Umbraco.Core/Persistence/BulkDataReader.cs
@@ -160,7 +160,7 @@ namespace Umbraco.Core.Persistence
/// A helper method to support .
///
///
- /// This methds does extensive argument checks. These errors will cause hard to diagnose exceptions in latter
+ /// This methods does extensive argument checks. These errors will cause hard to diagnose exceptions in latter
/// processing so it is important to detect them when they can be easily associated with the code defect.
///
///
diff --git a/src/Umbraco.Core/Persistence/Constants-DatabaseSchema.cs b/src/Umbraco.Core/Persistence/Constants-DatabaseSchema.cs
index 9eb4c3f90f..7898a9997a 100644
--- a/src/Umbraco.Core/Persistence/Constants-DatabaseSchema.cs
+++ b/src/Umbraco.Core/Persistence/Constants-DatabaseSchema.cs
@@ -14,13 +14,13 @@ namespace Umbraco.Core
public const string Node = /*TableNamePrefix*/ "umbraco" + "Node";
public const string NodeData = /*TableNamePrefix*/ "cms" + "ContentNu";
- public const string NodeXml = /*TableNamePrefix*/ "cms" + "ContentXml";
- public const string NodePreviewXml = /*TableNamePrefix*/ "cms" + "PreviewXml"; // fixme dbfix kill merge with ContentXml
+ public const string NodeXml = /*TableNamePrefix*/ "cms" + "ContentXml"; // TODO: get rid of these with the xml cache
+ public const string NodePreviewXml = /*TableNamePrefix*/ "cms" + "PreviewXml"; // TODO: get rid of these with the xml cache
- public const string ContentType = /*TableNamePrefix*/ "cms" + "ContentType"; // fixme dbfix rename and split uElementType, uDocumentType
+ public const string ContentType = /*TableNamePrefix*/ "cms" + "ContentType";
public const string ContentChildType = /*TableNamePrefix*/ "cms" + "ContentTypeAllowedContentType";
- public const string DocumentType = /*TableNamePrefix*/ "cms" + "DocumentType"; // fixme dbfix must rename corresponding DTO
- public const string ElementTypeTree = /*TableNamePrefix*/ "cms" + "ContentType2ContentType"; // fixme dbfix why can't we just use uNode for this?
+ public const string DocumentType = /*TableNamePrefix*/ "cms" + "DocumentType";
+ public const string ElementTypeTree = /*TableNamePrefix*/ "cms" + "ContentType2ContentType";
public const string DataType = TableNamePrefix + "DataType";
public const string Template = /*TableNamePrefix*/ "cms" + "Template";
diff --git a/src/Umbraco.Core/Persistence/Constants-DbProviderNames.cs b/src/Umbraco.Core/Persistence/Constants-DbProviderNames.cs
index b79269d80e..8e81a5acf8 100644
--- a/src/Umbraco.Core/Persistence/Constants-DbProviderNames.cs
+++ b/src/Umbraco.Core/Persistence/Constants-DbProviderNames.cs
@@ -6,7 +6,6 @@ namespace Umbraco.Core
public static class DbProviderNames
{
public const string SqlServer = "System.Data.SqlClient";
- public const string MySql = "MySql.Data.MySqlClient";
public const string SqlCe = "System.Data.SqlServerCe.4.0";
}
}
diff --git a/src/Umbraco.Core/Persistence/DatabaseAnnotations/ForeignKeyAttribute.cs b/src/Umbraco.Core/Persistence/DatabaseAnnotations/ForeignKeyAttribute.cs
index 35cb4a8087..fceb32d609 100644
--- a/src/Umbraco.Core/Persistence/DatabaseAnnotations/ForeignKeyAttribute.cs
+++ b/src/Umbraco.Core/Persistence/DatabaseAnnotations/ForeignKeyAttribute.cs
@@ -16,7 +16,7 @@ namespace Umbraco.Core.Persistence.DatabaseAnnotations
internal string OnUpdate { get; set; }
///
- /// Gets or sets the name of the foreign key refence
+ /// Gets or sets the name of the foreign key reference
///
///
/// Overrides the default naming of a foreign key reference:
diff --git a/src/Umbraco.Core/Persistence/DatabaseModelDefinitions/DbIndexDefinition.cs b/src/Umbraco.Core/Persistence/DatabaseModelDefinitions/DbIndexDefinition.cs
index f447d6a560..3c6915dc34 100644
--- a/src/Umbraco.Core/Persistence/DatabaseModelDefinitions/DbIndexDefinition.cs
+++ b/src/Umbraco.Core/Persistence/DatabaseModelDefinitions/DbIndexDefinition.cs
@@ -3,7 +3,7 @@
namespace Umbraco.Core.Persistence.DatabaseModelDefinitions
{
///
- /// Represents a database index definition retreived by querying the database
+ /// Represents a database index definition retrieved by querying the database
///
internal class DbIndexDefinition
{
diff --git a/src/Umbraco.Core/Persistence/DatabaseModelDefinitions/DefinitionFactory.cs b/src/Umbraco.Core/Persistence/DatabaseModelDefinitions/DefinitionFactory.cs
index 5a0e44a281..e2d3ac97ae 100644
--- a/src/Umbraco.Core/Persistence/DatabaseModelDefinitions/DefinitionFactory.cs
+++ b/src/Umbraco.Core/Persistence/DatabaseModelDefinitions/DefinitionFactory.cs
@@ -109,12 +109,6 @@ namespace Umbraco.Core.Persistence.DatabaseModelDefinitions
var constraintAttribute = propertyInfo.FirstAttribute();
if (constraintAttribute != null)
{
- //Special case for MySQL as it can't have multiple default DateTime values, which
- //is what the umbracoServer table definition is trying to create
- if (sqlSyntax is MySqlSyntaxProvider && definition.TableName == "umbracoServer" &&
- definition.TableName.ToLowerInvariant() == "lastNotifiedDate".ToLowerInvariant())
- return definition;
-
definition.ConstraintName = constraintAttribute.Name ?? string.Empty;
definition.DefaultValue = constraintAttribute.Default ?? string.Empty;
}
diff --git a/src/Umbraco.Core/Persistence/DbConnectionExtensions.cs b/src/Umbraco.Core/Persistence/DbConnectionExtensions.cs
index 8f501c0aaa..20586cb6f4 100644
--- a/src/Umbraco.Core/Persistence/DbConnectionExtensions.cs
+++ b/src/Umbraco.Core/Persistence/DbConnectionExtensions.cs
@@ -4,7 +4,6 @@ using System.Data.Common;
using System.Data.SqlClient;
using System.Data.SqlServerCe;
using System.Linq;
-using MySql.Data.MySqlClient;
using StackExchange.Profiling.Data;
using Umbraco.Core.Composing;
using Umbraco.Core.Logging;
@@ -19,12 +18,6 @@ namespace Umbraco.Core.Persistence
var builder = new DbConnectionStringBuilder { ConnectionString = connectionString };
var allKeys = builder.Keys.Cast();
- var mySql = new[] { "Server", "Database", "Uid", "Pwd" };
- if (mySql.All(x => allKeys.InvariantContains(x)))
- {
- return Constants.DbProviderNames.MySql;
- }
-
if (allKeys.InvariantContains("Data Source")
//this dictionary is case insensitive
&& builder["Data source"].ToString().InvariantContains(".sdf"))
@@ -38,7 +31,6 @@ namespace Umbraco.Core.Persistence
public static bool IsConnectionAvailable(string connectionString, string providerName)
{
if (providerName != Constants.DbProviderNames.SqlCe
- && providerName != Constants.DbProviderNames.MySql
&& providerName != Constants.DbProviderNames.SqlServer)
throw new NotSupportedException($"Provider \"{providerName}\" is not supported.");
@@ -108,11 +100,6 @@ namespace Umbraco.Core.Persistence
var builder = new SqlCeConnectionStringBuilder(connection.ConnectionString);
return $"DataSource: {builder.DataSource}";
}
- case MySqlConnection _:
- {
- var builder = new MySqlConnectionStringBuilder(connection.ConnectionString);
- return $"Server: {builder.Server}, Database: {builder.Database}";
- }
}
}
catch (Exception ex)
diff --git a/src/Umbraco.Core/Persistence/Dtos/ContentVersionCultureVariationDto.cs b/src/Umbraco.Core/Persistence/Dtos/ContentVersionCultureVariationDto.cs
index 1dca820a6c..65d677d240 100644
--- a/src/Umbraco.Core/Persistence/Dtos/ContentVersionCultureVariationDto.cs
+++ b/src/Umbraco.Core/Persistence/Dtos/ContentVersionCultureVariationDto.cs
@@ -33,10 +33,10 @@ namespace Umbraco.Core.Persistence.Dtos
[Column("name")]
public string Name { get; set; }
- [Column("date")] // fixme: db rename to 'updateDate'
+ [Column("date")] // TODO: db rename to 'updateDate'
public DateTime UpdateDate { get; set; }
- [Column("availableUserId")] // fixme: db rename to 'updateDate'
+ [Column("availableUserId")] // TODO: db rename to 'updateDate'
[ForeignKey(typeof(UserDto))]
[NullSetting(NullSetting = NullSettings.Null)]
public int? UpdateUserId { get => _updateUserId == 0 ? null : _updateUserId; set => _updateUserId = value; } //return null if zero
diff --git a/src/Umbraco.Core/Persistence/Dtos/ContentVersionDto.cs b/src/Umbraco.Core/Persistence/Dtos/ContentVersionDto.cs
index a13bf921d9..3c2c3deda4 100644
--- a/src/Umbraco.Core/Persistence/Dtos/ContentVersionDto.cs
+++ b/src/Umbraco.Core/Persistence/Dtos/ContentVersionDto.cs
@@ -21,16 +21,16 @@ namespace Umbraco.Core.Persistence.Dtos
[ForeignKey(typeof(ContentDto))]
public int NodeId { get; set; }
- [Column("versionDate")] // fixme: db rename to 'updateDate'
+ [Column("versionDate")] // TODO: db rename to 'updateDate'
[Constraint(Default = SystemMethods.CurrentDateTime)]
public DateTime VersionDate { get; set; }
- [Column("userId")] // fixme: db rename to 'updateUserId'
+ [Column("userId")] // TODO: db rename to 'updateUserId'
[ForeignKey(typeof(UserDto))]
[NullSetting(NullSetting = NullSettings.Null)]
public int? UserId { get => _userId == 0 ? null : _userId; set => _userId = value; } //return null if zero
- //fixme - we need an index on this it is used almost always in querying and sorting
+ // TODO: we need an index on this it is used almost always in querying and sorting
[Column("current")]
public bool Current { get; set; }
diff --git a/src/Umbraco.Core/Persistence/Dtos/DataTypeDto.cs b/src/Umbraco.Core/Persistence/Dtos/DataTypeDto.cs
index cc51ab19ee..d270c7b732 100644
--- a/src/Umbraco.Core/Persistence/Dtos/DataTypeDto.cs
+++ b/src/Umbraco.Core/Persistence/Dtos/DataTypeDto.cs
@@ -14,7 +14,7 @@ namespace Umbraco.Core.Persistence.Dtos
public int NodeId { get; set; }
[Column("propertyEditorAlias")]
- public string EditorAlias { get; set; } // fixme - length?!
+ public string EditorAlias { get; set; } // TODO: should this have a length
[Column("dbType")]
[Length(50)]
diff --git a/src/Umbraco.Core/Persistence/Dtos/LogDto.cs b/src/Umbraco.Core/Persistence/Dtos/LogDto.cs
index 9a710c1fec..bfd96426e2 100644
--- a/src/Umbraco.Core/Persistence/Dtos/LogDto.cs
+++ b/src/Umbraco.Core/Persistence/Dtos/LogDto.cs
@@ -35,12 +35,12 @@ namespace Umbraco.Core.Persistence.Dtos
[NullSetting(NullSetting = NullSettings.Null)]
public string EntityType { get; set; }
- //TODO: Should we have an index on this since we allow searching on it?
+ // TODO: Should we have an index on this since we allow searching on it?
[Column("Datestamp")]
[Constraint(Default = SystemMethods.CurrentDateTime)]
public DateTime Datestamp { get; set; }
- //TODO: Should we have an index on this since we allow searching on it?
+ // TODO: Should we have an index on this since we allow searching on it?
[Column("logHeader")]
[Length(50)]
public string Header { get; set; }
diff --git a/src/Umbraco.Core/Persistence/Dtos/MemberTypeReadOnlyDto.cs b/src/Umbraco.Core/Persistence/Dtos/MemberTypeReadOnlyDto.cs
index f9e70cce18..c4ea6a10fd 100644
--- a/src/Umbraco.Core/Persistence/Dtos/MemberTypeReadOnlyDto.cs
+++ b/src/Umbraco.Core/Persistence/Dtos/MemberTypeReadOnlyDto.cs
@@ -66,13 +66,13 @@ namespace Umbraco.Core.Persistence.Dtos
public bool AllowAtRoot { get; set; }
/* PropertyTypes */
- //TODO Add PropertyTypeDto (+MemberTypeDto and DataTypeDto as one) ReadOnly list
+ // TODO: Add PropertyTypeDto (+MemberTypeDto and DataTypeDto as one) ReadOnly list
[ResultColumn]
[Reference(ReferenceType.Many, ReferenceMemberName = "ContentTypeId")]
public List PropertyTypes { get; set; }
/* PropertyTypeGroups */
- //TODO Add PropertyTypeGroupDto ReadOnly list
+ // TODO: Add PropertyTypeGroupDto ReadOnly list
[ResultColumn]
[Reference(ReferenceType.Many, ReferenceMemberName = "ContentTypeNodeId")]
public List PropertyTypeGroups { get; set; }
diff --git a/src/Umbraco.Core/Persistence/Dtos/NodeDto.cs b/src/Umbraco.Core/Persistence/Dtos/NodeDto.cs
index 56da821360..5800efb97a 100644
--- a/src/Umbraco.Core/Persistence/Dtos/NodeDto.cs
+++ b/src/Umbraco.Core/Persistence/Dtos/NodeDto.cs
@@ -45,7 +45,7 @@ namespace Umbraco.Core.Persistence.Dtos
[Index(IndexTypes.NonClustered, Name = "IX_" + TableName + "_Trashed")]
public bool Trashed { get; set; }
- [Column("nodeUser")] // fixme: db rename to 'createUserId'
+ [Column("nodeUser")] // TODO: db rename to 'createUserId'
[ForeignKey(typeof(UserDto))]
[NullSetting(NullSetting = NullSettings.Null)]
public int? UserId { get => _userId == 0 ? null : _userId; set => _userId = value; } //return null if zero
@@ -54,7 +54,7 @@ namespace Umbraco.Core.Persistence.Dtos
[NullSetting(NullSetting = NullSettings.Null)]
public string Text { get; set; }
- [Column("nodeObjectType")] // fixme: db rename to 'objectType'
+ [Column("nodeObjectType")] // TODO: db rename to 'objectType'
[NullSetting(NullSetting = NullSettings.Null)]
[Index(IndexTypes.NonClustered, Name = "IX_" + TableName + "_ObjectType")]
public Guid? NodeObjectType { get; set; }
diff --git a/src/Umbraco.Core/Persistence/Dtos/User2UserGroupDto.cs b/src/Umbraco.Core/Persistence/Dtos/User2UserGroupDto.cs
index 6705153ffb..dabac9dabf 100644
--- a/src/Umbraco.Core/Persistence/Dtos/User2UserGroupDto.cs
+++ b/src/Umbraco.Core/Persistence/Dtos/User2UserGroupDto.cs
@@ -16,22 +16,4 @@ namespace Umbraco.Core.Persistence.Dtos
[ForeignKey(typeof(UserGroupDto))]
public int UserGroupId { get; set; }
}
-
- [TableName(Constants.DatabaseSchema.Tables.User2UserGroup)]
- [ExplicitColumns]
- internal class User2UserGroupReadOnlyDto
- {
- [Column("userId")]
- [PrimaryKeyColumn(AutoIncrement = false, Name = "PK_user2userGroup", OnColumns = "userId, userGroupId")]
- [ForeignKey(typeof(UserDto))]
- public int UserId { get; set; }
-
- [Column("userGroupId")]
- [ForeignKey(typeof(UserGroupDto))]
- public int UserGroupId { get; set; }
-
- [ResultColumn]
- [Reference(ReferenceType.Foreign)] // fixme
- public UserGroupDto UserGroupDto { get; set; }
- }
}
diff --git a/src/Umbraco.Core/Persistence/EntityNotFoundException.cs b/src/Umbraco.Core/Persistence/EntityNotFoundException.cs
index 49e85046a0..e0fe778fa6 100644
--- a/src/Umbraco.Core/Persistence/EntityNotFoundException.cs
+++ b/src/Umbraco.Core/Persistence/EntityNotFoundException.cs
@@ -7,7 +7,7 @@ using System.Threading.Tasks;
namespace Umbraco.Core.Persistence
{
- //TODO: Would be good to use this exception type anytime we cannot find an entity
+ // TODO: Would be good to use this exception type anytime we cannot find an entity
///
/// An exception used to indicate that an umbraco entity could not be found
diff --git a/src/Umbraco.Core/Persistence/Factories/ContentBaseFactory.cs b/src/Umbraco.Core/Persistence/Factories/ContentBaseFactory.cs
index 7fe1d44921..434e0393cd 100644
--- a/src/Umbraco.Core/Persistence/Factories/ContentBaseFactory.cs
+++ b/src/Umbraco.Core/Persistence/Factories/ContentBaseFactory.cs
@@ -49,7 +49,7 @@ namespace Umbraco.Core.Persistence.Factories
content.Published = dto.Published;
content.Edited = dto.Edited;
- // fixme - shall we get published infos or not?
+ // TODO: shall we get published infos or not?
//if (dto.Published)
if (publishedVersionDto != null)
{
@@ -89,7 +89,7 @@ namespace Umbraco.Core.Persistence.Factories
content.Key = nodeDto.UniqueId;
content.VersionId = contentVersionDto.Id;
- // fixme missing names?
+ // TODO: missing names?
content.Path = nodeDto.Path;
content.Level = nodeDto.Level;
@@ -130,7 +130,7 @@ namespace Umbraco.Core.Persistence.Factories
content.Key = nodeDto.UniqueId;
content.VersionId = contentVersionDto.Id;
- // fixme missing names?
+ // TODO: missing names?
content.Path = nodeDto.Path;
content.Level = nodeDto.Level;
@@ -187,7 +187,7 @@ namespace Umbraco.Core.Persistence.Factories
}
///
- /// Buils a dto from an IMedia item.
+ /// Builds a dto from an IMedia item.
///
public static MediaDto BuildDto(IMedia entity)
{
@@ -204,7 +204,7 @@ namespace Umbraco.Core.Persistence.Factories
}
///
- /// Buils a dto from an IMember item.
+ /// Builds a dto from an IMember item.
///
public static MemberDto BuildDto(IMember entity)
{
@@ -294,7 +294,7 @@ namespace Umbraco.Core.Persistence.Factories
private static MediaVersionDto BuildMediaVersionDto(IMedia entity, ContentDto contentDto)
{
// try to get a path from the string being stored for media
- // fixme - only considering umbracoFile ?!
+ // TODO: only considering umbracoFile
TryMatch(entity.GetValue("umbracoFile"), out var path);
@@ -309,11 +309,11 @@ namespace Umbraco.Core.Persistence.Factories
return dto;
}
- // fixme - this should NOT be here?!
+ // TODO: this should NOT be here?!
// more dark magic ;-(
internal static bool TryMatch(string text, out string path)
{
- //fixme: In v8 we should allow exposing this via the property editor in a much nicer way so that the property editor
+ // In v8 we should allow exposing this via the property editor in a much nicer way so that the property editor
// can tell us directly what any URL is for a given property if it contains an asset
path = null;
diff --git a/src/Umbraco.Core/Persistence/Factories/MemberTypeReadOnlyFactory.cs b/src/Umbraco.Core/Persistence/Factories/MemberTypeReadOnlyFactory.cs
index cbbcb03649..8e3c7db3b0 100644
--- a/src/Umbraco.Core/Persistence/Factories/MemberTypeReadOnlyFactory.cs
+++ b/src/Umbraco.Core/Persistence/Factories/MemberTypeReadOnlyFactory.cs
@@ -43,7 +43,7 @@ namespace Umbraco.Core.Persistence.Factories
var propertyTypes = GetPropertyTypes(dto, memberType, standardPropertyTypes);
- //By Convention we add 9 stnd PropertyTypes - This is only here to support loading of types that didn't have these conventions before.
+ //By Convention we add 9 standard PropertyTypes - This is only here to support loading of types that didn't have these conventions before.
foreach (var standardPropertyType in standardPropertyTypes)
{
if (dto.PropertyTypes.Any(x => x.Alias.Equals(standardPropertyType.Key))) continue;
diff --git a/src/Umbraco.Core/Persistence/Factories/PropertyFactory.cs b/src/Umbraco.Core/Persistence/Factories/PropertyFactory.cs
index 728441964a..d83650d798 100644
--- a/src/Umbraco.Core/Persistence/Factories/PropertyFactory.cs
+++ b/src/Umbraco.Core/Persistence/Factories/PropertyFactory.cs
@@ -31,7 +31,7 @@ namespace Umbraco.Core.Persistence.Factories
property.Id = propDto.Id;
property.FactorySetValue(languageRepository.GetIsoCodeById(propDto.LanguageId), propDto.Segment, propDto.VersionId == publishedVersionId, propDto.Value);
}
-
+
}
property.ResetDirtyProperties(false);
@@ -104,7 +104,7 @@ namespace Umbraco.Core.Persistence.Factories
/// The properties to map
///
/// out parameter indicating that one or more properties have been edited
- /// out parameter containing a collection of of edited cultures when the contentVariation varies by culture
+ /// out parameter containing a collection of edited cultures when the contentVariation varies by culture
///
public static IEnumerable BuildDtos(ContentVariation contentVariation, int currentVersionId, int publishedVersionId, IEnumerable properties,
ILanguageRepository languageRepository, out bool edited, out HashSet editedCultures)
@@ -116,6 +116,9 @@ namespace Umbraco.Core.Persistence.Factories
var entityVariesByCulture = contentVariation.VariesByCulture();
+ // create dtos for each property values, but only for values that do actually exist
+ // ie have a non-null value, everything else is just ignored and won't have a db row
+
foreach (var property in properties)
{
if (property.PropertyType.IsPublishing)
@@ -135,10 +138,6 @@ namespace Umbraco.Core.Persistence.Factories
if (propertyValue.EditedValue != null)
propertyDataDtos.Add(BuildDto(currentVersionId, property, languageRepository.GetIdByIsoCode(propertyValue.Culture), propertyValue.Segment, propertyValue.EditedValue));
- // deal with missing edit value (fix inconsistencies)
- else if (propertyValue.PublishedValue != null)
- propertyDataDtos.Add(BuildDto(currentVersionId, property, languageRepository.GetIdByIsoCode(propertyValue.Culture), propertyValue.Segment, propertyValue.PublishedValue));
-
// use explicit equals here, else object comparison fails at comparing eg strings
var sameValues = propertyValue.PublishedValue == null ? propertyValue.EditedValue == null : propertyValue.PublishedValue.Equals(propertyValue.EditedValue);
edited |= !sameValues;
@@ -150,7 +149,7 @@ namespace Umbraco.Core.Persistence.Factories
editedCultures.Add(propertyValue.Culture); // report culture as edited
}
- // flag culture as edited if it contains an edited invariant property
+ // flag culture as edited if it contains an edited invariant property
if (propertyValue.Culture == null //invariant property
&& !sameValues // and edited and published are different
&& entityVariesByCulture) //only when the entity is variant
@@ -160,7 +159,6 @@ namespace Umbraco.Core.Persistence.Factories
editedCultures.Add(defaultCulture);
}
-
}
}
else
diff --git a/src/Umbraco.Core/Persistence/LocalDb.cs b/src/Umbraco.Core/Persistence/LocalDb.cs
index 6eb9cbc443..55d6565344 100644
--- a/src/Umbraco.Core/Persistence/LocalDb.cs
+++ b/src/Umbraco.Core/Persistence/LocalDb.cs
@@ -275,7 +275,7 @@ namespace Umbraco.Core.Persistence
///
/// The database should not exist in the LocalDb instance.
/// It will be attached with its name being its MDF filename (full path), uppercased, when
- /// the first connection is opened, and remain attached until explicitely detached.
+ /// the first connection is opened, and remain attached until explicitly detached.
///
public string GetAttachedConnectionString(string databaseName, string filesPath)
{
@@ -317,8 +317,8 @@ namespace Umbraco.Core.Persistence
if (dbname == "master" || dbname == "tempdb" || dbname == "model" || dbname == "msdb")
continue;
- // fixme - shall we deal with stale databases?
- // fixme - is it always ok to assume file names?
+ // TODO: shall we deal with stale databases?
+ // TODO: is it always ok to assume file names?
//var mdf = database.Value;
//var ldf = mdf.Replace(".mdf", "_log.ldf");
//if (staleOnly && File.Exists(mdf) && File.Exists(ldf))
diff --git a/src/Umbraco.Core/Persistence/Mappers/UserTypeMapper.cs b/src/Umbraco.Core/Persistence/Mappers/UserTypeMapper.cs
deleted file mode 100644
index 40fce123b7..0000000000
--- a/src/Umbraco.Core/Persistence/Mappers/UserTypeMapper.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-//using System.Collections.Concurrent;
-//using Umbraco.Core.Models.Membership;
-//using Umbraco.Core.Models.Rdbms;
-
-//namespace Umbraco.Core.Persistence.Mappers
-//{
-// ///
-// /// Represents a to DTO mapper used to translate the properties of the public api
-// /// implementation to that of the database's DTO as sql: [tableName].[columnName].
-// ///
-// [MapperFor(typeof(IUserType))]
-// [MapperFor(typeof(UserType))]
-// public sealed class UserTypeMapper : BaseMapper
-// {
-// private static readonly ConcurrentDictionary PropertyInfoCacheInstance = new ConcurrentDictionary();
-
-// internal override ConcurrentDictionary PropertyInfoCache => PropertyInfoCacheInstance;
-
-// protected override void BuildMap()
-// {
-// CacheMap(src => src.Id, dto => dto.Id);
-// CacheMap(src => src.Alias, dto => dto.Alias);
-// CacheMap(src => src.Name, dto => dto.Name);
-// CacheMap(src => src.Permissions, dto => dto.DefaultPermissions);
-// }
-// }
-//}
-// fixme remoev this file
diff --git a/src/Umbraco.Core/Persistence/NPocoDatabaseExtensions-Bulk.cs b/src/Umbraco.Core/Persistence/NPocoDatabaseExtensions-Bulk.cs
index 77b412ef2b..09f754c47a 100644
--- a/src/Umbraco.Core/Persistence/NPocoDatabaseExtensions-Bulk.cs
+++ b/src/Umbraco.Core/Persistence/NPocoDatabaseExtensions-Bulk.cs
@@ -17,7 +17,7 @@ namespace Umbraco.Core.Persistence
///
public static partial class NPocoDatabaseExtensions
{
- // todo: review NPoco native InsertBulk to replace the code below
+ // TODO: review NPoco native InsertBulk to replace the code below
///
/// Bulk-inserts records within a transaction.
@@ -71,10 +71,6 @@ namespace Umbraco.Core.Persistence
? BulkInsertRecordsSqlServer(database, pocoData, recordsA)
: BulkInsertRecordsWithCommands(database, recordsA);
}
-
- if (database.DatabaseType.IsMySql())
- return BulkInsertRecordsWithCommands(database, recordsA);
-
throw new NotSupportedException();
}
@@ -181,8 +177,8 @@ namespace Umbraco.Core.Persistence
using (var command = database.CreateCommand(database.Connection, CommandType.TableDirect, string.Empty))
{
command.CommandText = pocoData.TableInfo.TableName;
- command.CommandType = CommandType.TableDirect; // fixme - why repeat?
- // fixme - not supporting transactions?
+ command.CommandType = CommandType.TableDirect; // TODO: why repeat?
+ // TODO: not supporting transactions?
//cmd.Transaction = GetTypedTransaction(db.Connection.);
var count = 0;
diff --git a/src/Umbraco.Core/Persistence/NPocoDatabaseExtensions.cs b/src/Umbraco.Core/Persistence/NPocoDatabaseExtensions.cs
index b81e68e567..248f91284f 100644
--- a/src/Umbraco.Core/Persistence/NPocoDatabaseExtensions.cs
+++ b/src/Umbraco.Core/Persistence/NPocoDatabaseExtensions.cs
@@ -32,31 +32,7 @@ namespace Umbraco.Core.Persistence
//
// works in READ COMMITED, TSQL & SQLCE lock the constraint even if it does not exist, so INSERT is OK
//
- // proper way to do it with MySQL
- // IF EXISTS (SELECT ... FROM table WHERE ... FOR UPDATE)
- // BEGIN
- // UPDATE table SET ... WHERE ...
- // END
- // ELSE
- // BEGIN
- // INSERT INTO table (...) VALUES (...)
- // END
- //
- // MySQL locks the constraint ONLY if it exists, so INSERT may fail...
- // in theory, happens in READ COMMITTED but not REPEATABLE READ
- // http://www.percona.com/blog/2012/08/28/differences-between-read-committed-and-repeatable-read-transaction-isolation-levels/
- // but according to
- // http://dev.mysql.com/doc/refman/5.0/en/set-transaction.html
- // it won't work for exact index value (only ranges) so really...
- //
- // MySQL should do
- // INSERT INTO table (...) VALUES (...) ON DUPLICATE KEY UPDATE ...
- //
- // also the lock is released when the transaction is committed
- // not sure if that can have unexpected consequences on our code?
- //
- // so... for the time being, let's do with that somewhat crazy solution below...
- // todo: use the proper database syntax, not this kludge
+ // TODO: use the proper database syntax, not this kludge
///
/// Safely inserts a record, or updates if it exists, based on a unique constraint.
@@ -66,7 +42,7 @@ namespace Umbraco.Core.Persistence
/// The action that executed, either an insert or an update. If an insert occurred and a PK value got generated, the poco object
/// passed in will contain the updated value.
///
- /// We cannot rely on database-specific options such as MySql ON DUPLICATE KEY UPDATE or MSSQL MERGE WHEN MATCHED because SQLCE
+ /// We cannot rely on database-specific options because SQLCE
/// does not support any of them. Ideally this should be achieved with proper transaction isolation levels but that would mean revisiting
/// isolation levels globally. We want to keep it simple for the time being and manage it manually.
/// We handle it by trying to update, then insert, etc. until something works, or we get bored.
@@ -89,7 +65,7 @@ namespace Umbraco.Core.Persistence
/// The action that executed, either an insert or an update. If an insert occurred and a PK value got generated, the poco object
/// passed in will contain the updated value.
///
- /// We cannot rely on database-specific options such as MySql ON DUPLICATE KEY UPDATE or MSSQL MERGE WHEN MATCHED because SQLCE
+ /// We cannot rely on database-specific options because SQLCE
/// does not support any of them. Ideally this should be achieved with proper transaction isolation levels but that would mean revisiting
/// isolation levels globally. We want to keep it simple for the time being and manage it manually.
/// We handle it by trying to update, then insert, etc. until something works, or we get bored.
@@ -105,7 +81,7 @@ namespace Umbraco.Core.Persistence
if (poco == null)
throw new ArgumentNullException(nameof(poco));
- // fixme - NPoco has a Save method that works with the primary key
+ // TODO: NPoco has a Save method that works with the primary key
// in any case, no point trying to update if there's no primary key!
// try to update
diff --git a/src/Umbraco.Core/Persistence/NPocoDatabaseTypeExtensions.cs b/src/Umbraco.Core/Persistence/NPocoDatabaseTypeExtensions.cs
index bd44c095fa..70909e2874 100644
--- a/src/Umbraco.Core/Persistence/NPocoDatabaseTypeExtensions.cs
+++ b/src/Umbraco.Core/Persistence/NPocoDatabaseTypeExtensions.cs
@@ -4,11 +4,6 @@ namespace Umbraco.Core.Persistence
{
internal static class NPocoDatabaseTypeExtensions
{
- public static bool IsMySql(this DatabaseType databaseType)
- {
- return databaseType is NPoco.DatabaseTypes.MySqlDatabaseType;
- }
-
public static bool IsSqlServer(this DatabaseType databaseType)
{
// note that because SqlServerDatabaseType is the base class for
diff --git a/src/Umbraco.Core/Persistence/NPocoSqlExtensions.cs b/src/Umbraco.Core/Persistence/NPocoSqlExtensions.cs
index 7aa8b707be..23d818f0b3 100644
--- a/src/Umbraco.Core/Persistence/NPocoSqlExtensions.cs
+++ b/src/Umbraco.Core/Persistence/NPocoSqlExtensions.cs
@@ -496,7 +496,7 @@ namespace Umbraco.Core.Persistence
public static Sql On(this Sql.SqlJoinClause sqlJoin,
Expression> leftField, Expression> rightField)
{
- // fixme - ugly - should define on SqlContext!
+ // TODO: ugly - should define on SqlContext!
var xLeft = new Sql(sqlJoin.SqlContext).Columns(leftField);
var xRight = new Sql(sqlJoin.SqlContext).Columns(rightField);
@@ -816,7 +816,7 @@ namespace Umbraco.Core.Persistence
///
/// The type of the Dto to select.
/// The origin Sql.
- /// An expression speficying the reference.
+ /// An expression specifying the reference.
/// An expression to apply to the Sql statement before adding the reference selection.
/// The Sql statement.
/// The expression applies to the Sql statement before the reference selection
@@ -1063,17 +1063,6 @@ namespace Umbraco.Core.Persistence
/// The Sql statement.
public static Sql ForUpdate(this Sql sql)
{
- // MySql wants "FOR UPDATE" at the end, and T-Sql wants "WITH (UPDLOCK)" in the FROM statement,
- // and we want to implement it in the least expensive way, so parsing the entire string here is
- // a no, so we use reflection to work on the Sql expression before it is built.
- // TODO propose a clean way to do that type of thing in NPoco
-
- if (sql.SqlContext.DatabaseType.IsMySql())
- {
- sql.Append("FOR UPDATE");
- return sql;
- }
-
// go find the first FROM clause, and append the lock hint
Sql s = sql;
var updated = false;
@@ -1191,7 +1180,7 @@ namespace Umbraco.Core.Persistence
private static string GetTableName(this Type type)
{
- // todo: returning string.Empty for now
+ // TODO: returning string.Empty for now
// BUT the code bits that calls this method cannot deal with string.Empty so we
// should either throw, or fix these code bits...
var attr = type.FirstAttribute();
diff --git a/src/Umbraco.Core/Persistence/PocoDataDataReader.cs b/src/Umbraco.Core/Persistence/PocoDataDataReader.cs
index 7bfc31f66c..1d7d301b87 100644
--- a/src/Umbraco.Core/Persistence/PocoDataDataReader.cs
+++ b/src/Umbraco.Core/Persistence/PocoDataDataReader.cs
@@ -90,7 +90,7 @@ namespace Umbraco.Core.Persistence
}
else
{
- //get the SqlDbType from the clr type
+ //get the SqlDbType from the CLR type
sqlDbType = _sqlSyntaxProvider.GetSqlDbType(col.PropertyType);
}
diff --git a/src/Umbraco.Core/Persistence/Querying/ExpressionVisitorBase.cs b/src/Umbraco.Core/Persistence/Querying/ExpressionVisitorBase.cs
index 16bfc9b164..d04930fa92 100644
--- a/src/Umbraco.Core/Persistence/Querying/ExpressionVisitorBase.cs
+++ b/src/Umbraco.Core/Persistence/Querying/ExpressionVisitorBase.cs
@@ -10,7 +10,8 @@ using Umbraco.Core.Composing;
namespace Umbraco.Core.Persistence.Querying
{
- // fixme.npoco - are we basically duplicating entire parts of NPoco just because of SqlSyntax ?!
+ // TODO: are we basically duplicating entire parts of NPoco just because of SqlSyntax ?!
+ // try to use NPoco's version !
///
/// An expression tree parser to create SQL statements and SQL parameters based on a strongly typed expression.
@@ -268,7 +269,7 @@ namespace Umbraco.Core.Persistence.Querying
protected virtual string VisitNew(NewExpression newExpression)
{
- // TODO : check !
+ // TODO: check !
var member = Expression.Convert(newExpression, typeof(object));
var lambda = Expression.Lambda>(member);
try
@@ -661,7 +662,7 @@ namespace Umbraco.Core.Persistence.Querying
// sql 'COALESCE(x,fb) = COALESCE(y,fb)' - of course, fb must be a value outside
// of x and y range - and if that is not possible, then a manual comparison need
// to be written
- //TODO support SqlNullableEquals with 0 parameters, using the full syntax below
+ // TODO: support SqlNullableEquals with 0 parameters, using the full syntax below
case "SqlNullableEquals":
var compareTo = Visit(m.Arguments[1]);
var fallback = Visit(m.Arguments[2]);
diff --git a/src/Umbraco.Core/Persistence/Querying/ModelToSqlExpressionVisitor.cs b/src/Umbraco.Core/Persistence/Querying/ModelToSqlExpressionVisitor.cs
index 9f57e61db9..a353f01f5b 100644
--- a/src/Umbraco.Core/Persistence/Querying/ModelToSqlExpressionVisitor.cs
+++ b/src/Umbraco.Core/Persistence/Querying/ModelToSqlExpressionVisitor.cs
@@ -79,7 +79,7 @@ namespace Umbraco.Core.Persistence.Querying
return string.Empty;
}
- //TODO: When m.Expression.NodeType == ExpressionType.Constant and it's an expression like: content => aliases.Contains(content.ContentType.Alias);
+ // TODO: When m.Expression.NodeType == ExpressionType.Constant and it's an expression like: content => aliases.Contains(content.ContentType.Alias);
// then an SQL parameter will be added for aliases as an array, however in SqlIn on the subclass it will manually add these SqlParameters anyways,
// however the query will still execute because the SQL that is written will only contain the correct indexes of SQL parameters, this would be ignored,
// I'm just unsure right now due to time constraints how to make it correct. It won't matter right now and has been working already with this bug but I've
diff --git a/src/Umbraco.Core/Persistence/Repositories/IContentTypeRepositoryBase.cs b/src/Umbraco.Core/Persistence/Repositories/IContentTypeRepositoryBase.cs
index cc9b86c56b..69b0698a96 100644
--- a/src/Umbraco.Core/Persistence/Repositories/IContentTypeRepositoryBase.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/IContentTypeRepositoryBase.cs
@@ -16,7 +16,7 @@ namespace Umbraco.Core.Persistence.Repositories
///
/// The original alias.
/// The original alias with a number appended to it, so that it is unique.
- /// Unique accross all content, media and member types.
+ /// Unique across all content, media and member types.
string GetUniqueAlias(string alias);
diff --git a/src/Umbraco.Core/Persistence/Repositories/IPartialViewMacroRepository.cs b/src/Umbraco.Core/Persistence/Repositories/IPartialViewMacroRepository.cs
index fd83ffdfcc..b360f9b1a5 100644
--- a/src/Umbraco.Core/Persistence/Repositories/IPartialViewMacroRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/IPartialViewMacroRepository.cs
@@ -1,6 +1,6 @@
namespace Umbraco.Core.Persistence.Repositories
{
- // this only exists to differenciate with IPartialViewRepository in IoC
+ // this only exists to differentiate with IPartialViewRepository in IoC
// without resorting to constants, names, whatever - and IPartialViewRepository
// is implemented by PartialViewRepository and IPartialViewMacroRepository by
// PartialViewMacroRepository - just to inject the proper filesystem.
diff --git a/src/Umbraco.Core/Persistence/Repositories/ITemplateRepository.cs b/src/Umbraco.Core/Persistence/Repositories/ITemplateRepository.cs
index 4bab445bee..2e9bdcfc4a 100644
--- a/src/Umbraco.Core/Persistence/Repositories/ITemplateRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/ITemplateRepository.cs
@@ -1,6 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
+using System.Collections.Generic;
using System.IO;
using Umbraco.Core.Models;
@@ -18,21 +16,6 @@ namespace Umbraco.Core.Persistence.Repositories
IEnumerable GetDescendants(int masterTemplateId);
IEnumerable GetDescendants(string alias);
- ///
- /// This checks what the default rendering engine is set in config but then also ensures that there isn't already
- /// a template that exists in the opposite rendering engine's template folder, then returns the appropriate
- /// rendering engine to use.
- ///
- ///
- ///
- /// The reason this is required is because for example, if you have a master page file already existing under ~/masterpages/Blah.aspx
- /// and then you go to create a template in the tree called Blah and the default rendering engine is MVC, it will create a Blah.cshtml
- /// empty template in ~/Views. This means every page that is using Blah will go to MVC and render an empty page.
- /// This is mostly related to installing packages since packages install file templates to the file system and then create the
- /// templates in business logic. Without this, it could cause the wrong rendering engine to be used for a package.
- ///
- RenderingEngine DetermineTemplateRenderingEngine(ITemplate template);
-
///
/// Validates a
///
diff --git a/src/Umbraco.Core/Persistence/Repositories/IUserGroupRepository.cs b/src/Umbraco.Core/Persistence/Repositories/IUserGroupRepository.cs
index fa4b21dbc8..85fa8d894b 100644
--- a/src/Umbraco.Core/Persistence/Repositories/IUserGroupRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/IUserGroupRepository.cs
@@ -26,14 +26,14 @@ namespace Umbraco.Core.Persistence.Repositories
void AddOrUpdateGroupWithUsers(IUserGroup userGroup, int[] userIds);
///
- /// Gets explicilty defined permissions for the group for specified entities
+ /// Gets explicitly defined permissions for the group for specified entities
///
///
/// Array of entity Ids, if empty will return permissions for the group for all entities
EntityPermissionCollection GetPermissions(int[] groupIds, params int[] entityIds);
///
- /// Gets explicilt and default permissions (if requested) permissions for the group for specified entities
+ /// Gets explicit and default permissions (if requested) permissions for the group for specified entities
///
///
/// If true will include the group's default permissions if no permissions are explicitly assigned
diff --git a/src/Umbraco.Core/Persistence/Repositories/IUserRepository.cs b/src/Umbraco.Core/Persistence/Repositories/IUserRepository.cs
index c9ed1af558..0ec7972d08 100644
--- a/src/Umbraco.Core/Persistence/Repositories/IUserRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/IUserRepository.cs
@@ -51,7 +51,7 @@ namespace Umbraco.Core.Persistence.Repositories
///
/// A filter to only include users that do not belong to these user groups
///
- /// Optional parameter to filter by specfied user state
+ /// Optional parameter to filter by specified user state
///
IEnumerable GetPagedResultsByQuery(IQuery query, long pageIndex, int pageSize, out long totalRecords,
Expression> orderBy, Direction orderDirection = Direction.Ascending,
diff --git a/src/Umbraco.Core/Persistence/Repositories/Implement/AuditEntryRepository.cs b/src/Umbraco.Core/Persistence/Repositories/Implement/AuditEntryRepository.cs
index 77759ea2da..1486935e2a 100644
--- a/src/Umbraco.Core/Persistence/Repositories/Implement/AuditEntryRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/Implement/AuditEntryRepository.cs
@@ -21,7 +21,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
///
/// Initializes a new instance of the class.
///
- public AuditEntryRepository(IScopeAccessor scopeAccessor, CacheHelper cache, ILogger logger)
+ public AuditEntryRepository(IScopeAccessor scopeAccessor, AppCaches cache, ILogger logger)
: base(scopeAccessor, cache, logger)
{ }
diff --git a/src/Umbraco.Core/Persistence/Repositories/Implement/AuditRepository.cs b/src/Umbraco.Core/Persistence/Repositories/Implement/AuditRepository.cs
index 45f083bc6b..cda89fd89a 100644
--- a/src/Umbraco.Core/Persistence/Repositories/Implement/AuditRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/Implement/AuditRepository.cs
@@ -15,7 +15,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
internal class AuditRepository : NPocoRepositoryBase, IAuditRepository
{
public AuditRepository(IScopeAccessor scopeAccessor, ILogger logger)
- : base(scopeAccessor, CacheHelper.NoCache, logger)
+ : base(scopeAccessor, AppCaches.NoCache, logger)
{ }
protected override void PersistNewItem(IAuditItem entity)
diff --git a/src/Umbraco.Core/Persistence/Repositories/Implement/ConsentRepository.cs b/src/Umbraco.Core/Persistence/Repositories/Implement/ConsentRepository.cs
index 3794bf183a..8df9bf686d 100644
--- a/src/Umbraco.Core/Persistence/Repositories/Implement/ConsentRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/Implement/ConsentRepository.cs
@@ -20,7 +20,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
///
/// Initializes a new instance of the class.
///
- public ConsentRepository(IScopeAccessor scopeAccessor, CacheHelper cache, ILogger logger)
+ public ConsentRepository(IScopeAccessor scopeAccessor, AppCaches cache, ILogger logger)
: base(scopeAccessor, cache, logger)
{ }
@@ -86,7 +86,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
Database.Update(dto);
entity.ResetDirtyProperties();
- IsolatedCache.ClearCacheItem(RepositoryCacheKeys.GetKey(entity.Id));
+ IsolatedCache.Clear(RepositoryCacheKeys.GetKey(entity.Id));
}
///
diff --git a/src/Umbraco.Core/Persistence/Repositories/Implement/ContentRepositoryBase.cs b/src/Umbraco.Core/Persistence/Repositories/Implement/ContentRepositoryBase.cs
index bd7943ff1d..821f0941fc 100644
--- a/src/Umbraco.Core/Persistence/Repositories/Implement/ContentRepositoryBase.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/Implement/ContentRepositoryBase.cs
@@ -33,7 +33,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
where TEntity : class, IUmbracoEntity
where TRepository : class, IRepository
{
- protected ContentRepositoryBase(IScopeAccessor scopeAccessor, CacheHelper cache, ILanguageRepository languageRepository, ILogger logger)
+ protected ContentRepositoryBase(IScopeAccessor scopeAccessor, AppCaches cache, ILanguageRepository languageRepository, ILogger logger)
: base(scopeAccessor, cache, logger)
{
LanguageRepository = languageRepository;
@@ -43,7 +43,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
protected ILanguageRepository LanguageRepository { get; }
- protected PropertyEditorCollection PropertyEditors => Current.PropertyEditors; // fixme inject
+ protected PropertyEditorCollection PropertyEditors => Current.PropertyEditors; // TODO: inject
#region Versions
@@ -73,7 +73,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
// deletes a specific version
public virtual void DeleteVersion(int versionId)
{
- // fixme test object node type?
+ // TODO: test object node type?
// get the version we want to delete
var template = SqlContext.Templates.Get("Umbraco.Core.VersionableRepository.GetVersion", tsql =>
@@ -95,7 +95,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
// deletes all versions of an entity, older than a date.
public virtual void DeleteVersions(int nodeId, DateTime versionDate)
{
- // fixme test object node type?
+ // TODO: test object node type?
// get the versions we want to delete, excluding the current one
var template = SqlContext.Templates.Get("Umbraco.Core.VersionableRepository.GetVersions", tsql =>
@@ -240,7 +240,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
}
}
- // FIXME should we do it when un-publishing? or?
+ // TODO: should we do it when un-publishing? or?
///
/// Clears tags for an item.
///
@@ -277,7 +277,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
var (dbfield, _) = SqlContext.VisitDto(x => x.NodeId);
if (ordering.IsCustomField || !ordering.OrderBy.InvariantEquals("id"))
{
- psql.OrderBy(GetAliasedField(dbfield, sql)); // fixme why aliased?
+ psql.OrderBy(GetAliasedField(dbfield, sql));
}
// create prepared sql
@@ -374,7 +374,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
return GetAliasedField(SqlSyntax.GetFieldName(x => x.Text), sql);
// "variantName" alias is defined in DocumentRepository.GetBaseQuery
- // fixme - what if it is NOT a document but a ... media or whatever?
+ // TODO: what if it is NOT a document but a ... media or whatever?
// previously, we inserted the join+select *here* so we were sure to have it,
// but now that's not the case anymore!
return "variantName";
@@ -515,7 +515,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
}
// now we have
- // - the definitinos
+ // - the definitions
// - all property data dtos
// - tag editors
// and we need to build the proper property collections
@@ -620,7 +620,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
#region UnitOfWork Events
- //fixme: The reason these events are in the repository is for legacy, the events should exist at the service
+ // TODO: The reason these events are in the repository is for legacy, the events should exist at the service
// level now since we can fire these events within the transaction... so move the events to service level
public class ScopedEntityEventArgs : EventArgs
@@ -736,8 +736,6 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
public T Content { get; set; }
}
- // fixme copied from 7.6
-
///
/// For Paging, repositories must support returning different query for the query type specified
///
@@ -745,207 +743,6 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
///
protected abstract Sql GetBaseQuery(QueryType queryType);
- /*
- internal class DocumentDefinitionCollection : KeyedCollection
- {
- private readonly bool _includeAllVersions;
-
- ///
- /// Constructor specifying if all versions should be allowed, in that case the key for the collection becomes the versionId (GUID)
- ///
- ///
- public DocumentDefinitionCollection(bool includeAllVersions = false)
- {
- _includeAllVersions = includeAllVersions;
- }
-
- protected override ValueType GetKeyForItem(DocumentDefinition item)
- {
- return _includeAllVersions ? (ValueType)item.Version : item.Id;
- }
-
- ///
- /// if this key already exists if it does then we need to check
- /// if the existing item is 'older' than the new item and if that is the case we'll replace the older one
- ///
- ///
- ///
- public bool AddOrUpdate(DocumentDefinition item)
- {
- //if we are including all versions then just add, we aren't checking for latest
- if (_includeAllVersions)
- {
- Add(item);
- return true;
- }
-
- if (Dictionary == null)
- {
- Add(item);
- return true;
- }
-
- var key = GetKeyForItem(item);
- if (TryGetValue(key, out DocumentDefinition found))
- {
- //it already exists and it's older so we need to replace it
- if (item.VersionId <= found.VersionId) return false;
-
- var currIndex = Items.IndexOf(found);
- if (currIndex == -1)
- throw new IndexOutOfRangeException("Could not find the item in the list: " + found.Version);
-
- //replace the current one with the newer one
- SetItem(currIndex, item);
- return true;
- }
-
- Add(item);
- return true;
- }
-
- public bool TryGetValue(ValueType key, out DocumentDefinition val)
- {
- if (Dictionary != null)
- return Dictionary.TryGetValue(key, out val);
-
- val = null;
- return false;
- }
- }
-
- ///
- /// Implements a Guid comparer that respect the Sql engine ordering.
- ///
- ///
- /// MySql sorts Guids as strings, but MSSQL sorts guids based on a weird byte sections order
- /// This comparer compares Guids using the corresponding Sql syntax method, ie the method of the underlying Sql engine.
- /// see http://stackoverflow.com/questions/7810602/sql-server-guid-sort-algorithm-why
- /// see https://blogs.msdn.microsoft.com/sqlprogrammability/2006/11/06/how-are-guids-compared-in-sql-server-2005/
- ///
- private class DocumentDefinitionComparer : IComparer
- {
- private readonly bool _mySql;
-
- public DocumentDefinitionComparer(ISqlSyntaxProvider sqlSyntax)
- {
- _mySql = sqlSyntax is MySqlSyntaxProvider;
- }
-
- public int Compare(Guid x, Guid y)
- {
- // MySql sorts Guids as string (ie normal, same as .NET) whereas MSSQL
- // sorts them on a weird byte sections order
- return _mySql ? x.CompareTo(y) : new SqlGuid(x).CompareTo(new SqlGuid(y));
- }
- }
-
- internal class DocumentDefinition
- {
- ///
- /// Initializes a new instance of the class.
- ///
- public DocumentDefinition(DocumentDto dto, IContentTypeComposition composition)
- {
- DocumentDto = dto;
- ContentVersionDto = dto.ContentVersionDto;
- Composition = composition;
- }
-
- public DocumentDefinition(ContentVersionDto dto, IContentTypeComposition composition)
- {
- ContentVersionDto = dto;
- Composition = composition;
- }
-
- public DocumentDto DocumentDto { get; }
- public ContentVersionDto ContentVersionDto { get; }
-
- public int Id => ContentVersionDto.NodeId;
-
- public Guid Version => DocumentDto?.VersionId ?? ContentVersionDto.VersionId;
-
- // This is used to determien which version is the most recent
- public int VersionId => ContentVersionDto.Id;
-
- public DateTime VersionDate => ContentVersionDto.VersionDate;
-
- public DateTime CreateDate => ContentVersionDto.ContentDto.NodeDto.CreateDate;
-
- public IContentTypeComposition Composition { get; set; }
- }
-
- // Represents a query that may contain paging information.
- internal class PagingSqlQuery
- {
- // the original query sql
- public Sql QuerySql { get; }
-
- public PagingSqlQuery(Sql querySql)
- {
- QuerySql = querySql;
- }
-
- protected PagingSqlQuery(Sql querySql, int pageSize)
- : this(querySql)
- {
- HasPaging = pageSize > 0;
- }
-
- // whether the paging query is actually paging
- public bool HasPaging { get; }
-
- // the paging sql
- public virtual Sql BuildPagedQuery(string columns)
- {
- throw new InvalidOperationException("This query has no paging information.");
- }
- }
-
- ///
- /// Represents a query that may contain paging information.
- ///
- ///
- internal class PagingSqlQuery : PagingSqlQuery // fixme what's here?
- {
- private readonly Database _db;
- private readonly long _pageIndex;
- private readonly int _pageSize;
-
- // fixme - don't capture a db instance here!
- // instead, should have an extension method, so one can do
- // sql = db.BuildPageQuery(pagingQuery, columns)
- public PagingSqlQuery(Database db, Sql querySql, long pageIndex, int pageSize)
- : base(querySql, pageSize)
- {
- _db = db;
- _pageIndex = pageIndex;
- _pageSize = pageSize;
- }
-
- ///
- /// Creates a paged query based on the original query and subtitutes the selectColumns specified
- ///
- ///
- ///
- // build a page query
- public override Sql BuildPagedQuery(string columns)
- {
- if (HasPaging == false)
- throw new InvalidOperationException("This query has no paging information.");
-
- // substitutes the original "SELECT ..." with "SELECT {columns}" ie only
- // select the specified columns - fixme why?
- var sql = $"SELECT {columns} {QuerySql.SQL.Substring(QuerySql.SQL.IndexOf("FROM", StringComparison.Ordinal))}";
-
- // and then build the page query
- var args = QuerySql.Arguments;
- _db.BuildPageQueries(_pageIndex * _pageSize, _pageSize, sql, ref args, out string unused, out string sqlPage);
- return new Sql(sqlPage, args);
- }
- }
- */
-
#endregion
#region Utilities
diff --git a/src/Umbraco.Core/Persistence/Repositories/Implement/ContentTypeRepository.cs b/src/Umbraco.Core/Persistence/Repositories/Implement/ContentTypeRepository.cs
index 4bec3160a7..a9bb097346 100644
--- a/src/Umbraco.Core/Persistence/Repositories/Implement/ContentTypeRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/Implement/ContentTypeRepository.cs
@@ -19,7 +19,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
{
private readonly ITemplateRepository _templateRepository;
- public ContentTypeRepository(IScopeAccessor scopeAccessor, CacheHelper cache, ILogger logger, ITemplateRepository templateRepository)
+ public ContentTypeRepository(IScopeAccessor scopeAccessor, AppCaches cache, ILogger logger, ITemplateRepository templateRepository)
: base(scopeAccessor, cache, logger)
{
_templateRepository = templateRepository;
@@ -79,11 +79,10 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
var translator = new SqlTranslator(sqlClause, query);
var sql = translator.Translate();
- // fixme - insane! GetBaseQuery does not even return a proper??? oh well...
var dtos = Database.Fetch(sql);
return
- //This returns a lookup from the GetAll cached looup
+ //This returns a lookup from the GetAll cached lookup
(dtos.Any()
? GetMany(dtos.DistinctBy(x => x.ContentTypeDto.NodeId).Select(x => x.ContentTypeDto.NodeId).ToArray())
: Enumerable.Empty())
diff --git a/src/Umbraco.Core/Persistence/Repositories/Implement/ContentTypeRepositoryBase.cs b/src/Umbraco.Core/Persistence/Repositories/Implement/ContentTypeRepositoryBase.cs
index 683df047f8..7f41d2a456 100644
--- a/src/Umbraco.Core/Persistence/Repositories/Implement/ContentTypeRepositoryBase.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/Implement/ContentTypeRepositoryBase.cs
@@ -28,7 +28,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
internal abstract class ContentTypeRepositoryBase : NPocoRepositoryBase, IReadRepository
where TEntity : class, IContentTypeComposition
{
- protected ContentTypeRepositoryBase(IScopeAccessor scopeAccessor, CacheHelper cache, ILogger logger)
+ protected ContentTypeRepositoryBase(IScopeAccessor scopeAccessor, AppCaches cache, ILogger logger)
: base(scopeAccessor, cache, logger)
{ }
@@ -103,7 +103,6 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
.On(left => left.DataTypeId, right => right.NodeId);
var translator = new SqlTranslator(sqlClause, query);
- // fixme v8 are we sorting only for 7.6 relators?
var sql = translator.Translate()
.OrderBy(x => x.PropertyTypeGroupId);
@@ -121,7 +120,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
{
var dto = ContentTypeFactory.BuildContentTypeDto(entity);
- //Cannot add a duplicate content type type
+ //Cannot add a duplicate content type
var exists = Database.ExecuteScalar(@"SELECT COUNT(*) FROM cmsContentType
INNER JOIN umbracoNode ON cmsContentType.nodeId = umbracoNode.id
WHERE cmsContentType." + SqlSyntax.GetQuotedColumnName("alias") + @"= @alias
@@ -272,7 +271,7 @@ AND umbracoNode.id <> @id",
compositionBase.RemovedContentTypeKeyTracker != null &&
compositionBase.RemovedContentTypeKeyTracker.Any())
{
- //TODO: Could we do the below with bulk SQL statements instead of looking everything up and then manipulating?
+ // TODO: Could we do the below with bulk SQL statements instead of looking everything up and then manipulating?
// find Content based on the current ContentType
var sql = Sql()
@@ -292,7 +291,7 @@ AND umbracoNode.id <> @id",
// based on the PropertyTypes that belong to the removed ContentType.
foreach (var contentDto in contentDtos)
{
- //TODO: This could be done with bulk SQL statements
+ // TODO: This could be done with bulk SQL statements
foreach (var propertyType in propertyTypes)
{
var nodeId = contentDto.NodeId;
@@ -344,8 +343,7 @@ AND umbracoNode.id <> @id",
List orphanPropertyTypeIds = null;
if (entity.IsPropertyDirty("PropertyGroups"))
{
- // todo
- // we used to try to propagate tabs renaming downstream, relying on ParentId, but
+ // TODO: we used to try to propagate tabs renaming downstream, relying on ParentId, but
// 1) ParentId makes no sense (if a tab can be inherited from multiple composition
// types) so we would need to figure things out differently, visiting downstream
// content types and looking for tabs with the same name...
@@ -439,7 +437,7 @@ AND umbracoNode.id <> @id",
case ContentVariation.CultureAndSegment:
case ContentVariation.Segment:
default:
- throw new NotSupportedException(); //TODO: Support this
+ throw new NotSupportedException(); // TODO: Support this
}
}
@@ -629,7 +627,7 @@ AND umbracoNode.id <> @id",
///
private void ClearScheduledPublishing(IContentTypeComposition contentType)
{
- //TODO: Fill this in when scheduled publishing is enabled for variants
+ // TODO: Fill this in when scheduled publishing is enabled for variants
}
///
@@ -672,7 +670,7 @@ AND umbracoNode.id <> @id",
case ContentVariation.CultureAndSegment:
case ContentVariation.Segment:
default:
- throw new NotSupportedException(); //TODO: Support this
+ throw new NotSupportedException(); // TODO: Support this
}
}
}
@@ -755,7 +753,7 @@ AND umbracoNode.id <> @id",
case ContentVariation.CultureAndSegment:
case ContentVariation.Segment:
default:
- throw new NotSupportedException(); //TODO: Support this
+ throw new NotSupportedException(); // TODO: Support this
}
}
@@ -764,7 +762,6 @@ AND umbracoNode.id <> @id",
{
// note: important to use SqlNullableEquals for nullable types, cannot directly compare language identifiers
- // fixme - should we batch then?
var whereInArgsCount = propertyTypeIds.Count + (contentTypeIds?.Count ?? 0);
if (whereInArgsCount > 2000)
throw new NotSupportedException("Too many property/content types.");
@@ -903,7 +900,6 @@ AND umbracoNode.id <> @id",
{
// note: important to use SqlNullableEquals for nullable types, cannot directly compare language identifiers
//
- // fixme - should we batch then?
var whereInArgsCount = propertyTypeIds.Count + (contentTypeIds?.Count ?? 0);
if (whereInArgsCount > 2000)
throw new NotSupportedException("Too many property/content types.");
@@ -1041,7 +1037,7 @@ AND umbracoNode.id <> @id",
var dtos = Database.Fetch(sql);
- //TODO Move this to a PropertyTypeFactory
+ // TODO: Move this to a PropertyTypeFactory
var list = new List();
foreach (var dto in dtos.Where(x => x.PropertyTypeGroupId <= 0))
{
@@ -1320,7 +1316,7 @@ AND umbracoNode.id <> @id",
parentMediaTypeIds = new Dictionary>();
var mappedMediaTypes = new List();
- //loop through each result and fill in our required values, each row will contain different requried data than the rest.
+ //loop through each result and fill in our required values, each row will contain different required data than the rest.
// it is much quicker to iterate each result and populate instead of looking up the values over and over in the result like
// we used to do.
var queue = new Queue(result);
@@ -1727,7 +1723,7 @@ ORDER BY contentTypeId, groupId, id";
}
///
- /// Gets all entities of the spefified type
+ /// Gets all entities of the specified type
///
///
///
@@ -1751,7 +1747,7 @@ ORDER BY contentTypeId, groupId, id";
public string GetUniqueAlias(string alias)
{
- // alias is unique accross ALL content types!
+ // alias is unique across ALL content types!
var aliasColumn = SqlSyntax.GetQuotedColumnName("alias");
var aliases = Database.Fetch(@"SELECT cmsContentType." + aliasColumn + @" FROM cmsContentType
INNER JOIN umbracoNode ON cmsContentType.nodeId = umbracoNode.id
diff --git a/src/Umbraco.Core/Persistence/Repositories/Implement/DataTypeContainerRepository.cs b/src/Umbraco.Core/Persistence/Repositories/Implement/DataTypeContainerRepository.cs
index f23b6df5e2..752b641bc3 100644
--- a/src/Umbraco.Core/Persistence/Repositories/Implement/DataTypeContainerRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/Implement/DataTypeContainerRepository.cs
@@ -6,7 +6,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
{
class DataTypeContainerRepository : EntityContainerRepository, IDataTypeContainerRepository
{
- public DataTypeContainerRepository(IScopeAccessor scopeAccessor, CacheHelper cache, ILogger logger)
+ public DataTypeContainerRepository(IScopeAccessor scopeAccessor, AppCaches cache, ILogger logger)
: base(scopeAccessor, cache, logger, Constants.ObjectTypes.DataTypeContainer)
{ }
}
diff --git a/src/Umbraco.Core/Persistence/Repositories/Implement/DataTypeRepository.cs b/src/Umbraco.Core/Persistence/Repositories/Implement/DataTypeRepository.cs
index 4556c78fe6..3de9e3c99b 100644
--- a/src/Umbraco.Core/Persistence/Repositories/Implement/DataTypeRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/Implement/DataTypeRepository.cs
@@ -26,8 +26,8 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
{
private readonly Lazy _editors;
- // fixme temp fixing circular dependencies with LAZY but is this the right place?
- public DataTypeRepository(IScopeAccessor scopeAccessor, CacheHelper cache, Lazy editors, ILogger logger)
+ // TODO: https://github.com/umbraco/Umbraco-CMS/issues/4237 - get rid of Lazy injection and fix circular dependencies
+ public DataTypeRepository(IScopeAccessor scopeAccessor, AppCaches cache, Lazy editors, ILogger logger)
: base(scopeAccessor, cache, logger)
{
_editors = editors;
@@ -111,7 +111,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
//ensure a datatype has a unique name before creating it
entity.Name = EnsureUniqueNodeName(entity.Name);
- //TODO: should the below be removed?
+ // TODO: should the below be removed?
//Cannot add a duplicate data type
var existsSql = Sql()
.SelectCount()
diff --git a/src/Umbraco.Core/Persistence/Repositories/Implement/DictionaryRepository.cs b/src/Umbraco.Core/Persistence/Repositories/Implement/DictionaryRepository.cs
index 8f5ad70c32..be1e28fcc1 100644
--- a/src/Umbraco.Core/Persistence/Repositories/Implement/DictionaryRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/Implement/DictionaryRepository.cs
@@ -18,7 +18,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
///
internal class DictionaryRepository : NPocoRepositoryBase, IDictionaryRepository
{
- public DictionaryRepository(IScopeAccessor scopeAccessor, CacheHelper cache, ILogger logger)
+ public DictionaryRepository(IScopeAccessor scopeAccessor, AppCaches cache, ILogger logger)
: base(scopeAccessor, cache, logger)
{ }
@@ -174,8 +174,8 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
entity.ResetDirtyProperties();
//Clear the cache entries that exist by uniqueid/item key
- IsolatedCache.ClearCacheItem(RepositoryCacheKeys.GetKey(entity.ItemKey));
- IsolatedCache.ClearCacheItem(RepositoryCacheKeys.GetKey(entity.Key));
+ IsolatedCache.Clear(RepositoryCacheKeys.GetKey(entity.ItemKey));
+ IsolatedCache.Clear(RepositoryCacheKeys.GetKey(entity.Key));
}
protected override void PersistDeletedItem(IDictionaryItem entity)
@@ -186,8 +186,8 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
Database.Delete("WHERE id = @Id", new { Id = entity.Key });
//Clear the cache entries that exist by uniqueid/item key
- IsolatedCache.ClearCacheItem(RepositoryCacheKeys.GetKey(entity.ItemKey));
- IsolatedCache.ClearCacheItem(RepositoryCacheKeys.GetKey(entity.Key));
+ IsolatedCache.Clear(RepositoryCacheKeys.GetKey(entity.ItemKey));
+ IsolatedCache.Clear(RepositoryCacheKeys.GetKey(entity.Key));
entity.DeleteDate = DateTime.Now;
}
@@ -203,8 +203,8 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
Database.Delete("WHERE id = @Id", new { Id = dto.UniqueId });
//Clear the cache entries that exist by uniqueid/item key
- IsolatedCache.ClearCacheItem(RepositoryCacheKeys.GetKey(dto.Key));
- IsolatedCache.ClearCacheItem(RepositoryCacheKeys.GetKey(dto.UniqueId));
+ IsolatedCache.Clear(RepositoryCacheKeys.GetKey(dto.Key));
+ IsolatedCache.Clear(RepositoryCacheKeys.GetKey(dto.UniqueId));
}
}
@@ -224,13 +224,13 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
public IDictionaryItem Get(Guid uniqueId)
{
- var uniqueIdRepo = new DictionaryByUniqueIdRepository(this, ScopeAccessor, GlobalCache, Logger);
+ var uniqueIdRepo = new DictionaryByUniqueIdRepository(this, ScopeAccessor, AppCaches, Logger);
return uniqueIdRepo.Get(uniqueId);
}
public IDictionaryItem Get(string key)
{
- var keyRepo = new DictionaryByKeyRepository(this, ScopeAccessor, GlobalCache, Logger);
+ var keyRepo = new DictionaryByKeyRepository(this, ScopeAccessor, AppCaches, Logger);
return keyRepo.Get(key);
}
@@ -290,7 +290,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
{
private readonly DictionaryRepository _dictionaryRepository;
- public DictionaryByUniqueIdRepository(DictionaryRepository dictionaryRepository, IScopeAccessor scopeAccessor, CacheHelper cache, ILogger logger)
+ public DictionaryByUniqueIdRepository(DictionaryRepository dictionaryRepository, IScopeAccessor scopeAccessor, AppCaches cache, ILogger logger)
: base(scopeAccessor, cache, logger)
{
_dictionaryRepository = dictionaryRepository;
@@ -343,7 +343,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
{
private readonly DictionaryRepository _dictionaryRepository;
- public DictionaryByKeyRepository(DictionaryRepository dictionaryRepository, IScopeAccessor scopeAccessor, CacheHelper cache, ILogger logger)
+ public DictionaryByKeyRepository(DictionaryRepository dictionaryRepository, IScopeAccessor scopeAccessor, AppCaches cache, ILogger logger)
: base(scopeAccessor, cache, logger)
{
_dictionaryRepository = dictionaryRepository;
diff --git a/src/Umbraco.Core/Persistence/Repositories/Implement/DocumentBlueprintRepository.cs b/src/Umbraco.Core/Persistence/Repositories/Implement/DocumentBlueprintRepository.cs
index 1d24cfd2dc..d137d7ac76 100644
--- a/src/Umbraco.Core/Persistence/Repositories/Implement/DocumentBlueprintRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/Implement/DocumentBlueprintRepository.cs
@@ -11,18 +11,19 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
///
///
/// It would be nicer if we could separate most of this down into a smaller version of the ContentRepository class, however to do that
- /// requires quite a lot of work since we'd need to re-organize the interhitance quite a lot or create a helper class to perform a lot of the underlying logic.
+ /// requires quite a lot of work since we'd need to re-organize the inheritance quite a lot or create a helper class to perform a lot of the underlying logic.
///
/// TODO: Create a helper method to contain most of the underlying logic for the ContentRepository
///
internal class DocumentBlueprintRepository : DocumentRepository, IDocumentBlueprintRepository
{
- public DocumentBlueprintRepository(IScopeAccessor scopeAccessor, CacheHelper cacheHelper, ILogger logger, IContentTypeRepository contentTypeRepository, ITemplateRepository templateRepository, ITagRepository tagRepository, ILanguageRepository languageRepository, IContentSection settings)
- : base(scopeAccessor, cacheHelper, logger, contentTypeRepository, templateRepository, tagRepository, languageRepository, settings)
+ public DocumentBlueprintRepository(IScopeAccessor scopeAccessor, AppCaches appCaches, ILogger logger, IContentTypeRepository contentTypeRepository, ITemplateRepository templateRepository, ITagRepository tagRepository, ILanguageRepository languageRepository)
+ : base(scopeAccessor, appCaches, logger, contentTypeRepository, templateRepository, tagRepository, languageRepository)
{
- EnsureUniqueNaming = false; // duplicates are allowed
}
+ protected override bool EnsureUniqueNaming => false; // duplicates are allowed
+
protected override Guid NodeObjectTypeId => Constants.ObjectTypes.DocumentBlueprint;
}
}
diff --git a/src/Umbraco.Core/Persistence/Repositories/Implement/DocumentRepository.cs b/src/Umbraco.Core/Persistence/Repositories/Implement/DocumentRepository.cs
index 054ab8cb4b..6af7031883 100644
--- a/src/Umbraco.Core/Persistence/Repositories/Implement/DocumentRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/Implement/DocumentRepository.cs
@@ -25,30 +25,32 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
private readonly IContentTypeRepository _contentTypeRepository;
private readonly ITemplateRepository _templateRepository;
private readonly ITagRepository _tagRepository;
- private readonly CacheHelper _cacheHelper;
+ private readonly AppCaches _appCaches;
private PermissionRepository _permissionRepository;
private readonly ContentByGuidReadRepository _contentByGuidReadRepository;
private readonly IScopeAccessor _scopeAccessor;
- public DocumentRepository(IScopeAccessor scopeAccessor, CacheHelper cacheHelper, ILogger logger, IContentTypeRepository contentTypeRepository, ITemplateRepository templateRepository, ITagRepository tagRepository, ILanguageRepository languageRepository, IContentSection settings)
- : base(scopeAccessor, cacheHelper, languageRepository, logger)
+ public DocumentRepository(IScopeAccessor scopeAccessor, AppCaches appCaches, ILogger logger, IContentTypeRepository contentTypeRepository, ITemplateRepository templateRepository, ITagRepository tagRepository, ILanguageRepository languageRepository)
+ : base(scopeAccessor, appCaches, languageRepository, logger)
{
_contentTypeRepository = contentTypeRepository ?? throw new ArgumentNullException(nameof(contentTypeRepository));
_templateRepository = templateRepository ?? throw new ArgumentNullException(nameof(templateRepository));
_tagRepository = tagRepository ?? throw new ArgumentNullException(nameof(tagRepository));
- _cacheHelper = cacheHelper;
+ _appCaches = appCaches;
_scopeAccessor = scopeAccessor;
- _contentByGuidReadRepository = new ContentByGuidReadRepository(this, scopeAccessor, cacheHelper, logger);
- EnsureUniqueNaming = settings.EnsureUniqueNaming;
+ _contentByGuidReadRepository = new ContentByGuidReadRepository(this, scopeAccessor, appCaches, logger);
}
protected override DocumentRepository This => this;
- public bool EnsureUniqueNaming { get; set; }
+ ///
+ /// Default is to always ensure all documents have unique names
+ ///
+ protected virtual bool EnsureUniqueNaming { get; } = true;
// note: is ok to 'new' the repo here as it's a sub-repo really
private PermissionRepository PermissionRepository => _permissionRepository
- ?? (_permissionRepository = new PermissionRepository(_scopeAccessor, _cacheHelper, Logger));
+ ?? (_permissionRepository = new PermissionRepository(_scopeAccessor, _appCaches, Logger));
#region Repository Base
@@ -90,7 +92,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
private void AddGetByQueryOrderBy(Sql sql)
{
- sql // fixme why - this should be Path
+ sql
.OrderBy(x => x.Level)
.OrderBy(x => x.SortOrder);
}
@@ -148,7 +150,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
.On((left, right) => left.Id == right.Id && right.Published, "pcv", "pdv"), "pcv")
.On((left, right) => left.NodeId == right.NodeId, aliasRight: "pcv")
- //fixme - should we be joining this when the query type is not single/many?
+ // TODO: should we be joining this when the query type is not single/many?
// left join on optional culture variation
//the magic "[[[ISOCODE]]]" parameter value will be replaced in ContentRepositoryBase.GetPage() by the actual ISO code
.LeftJoin(nested =>
@@ -171,13 +173,11 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
return sql;
}
- // fixme - kill, eventually
protected override Sql GetBaseQuery(bool isCount)
{
return GetBaseQuery(isCount ? QueryType.Count : QueryType.Single);
}
- // fixme - kill, eventually
// ah maybe not, that what's used for eg Exists in base repo
protected override string GetBaseWhereClause()
{
@@ -251,7 +251,6 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
// raise event first else potential FK issues
OnUowRemovingVersion(new ScopedVersionEventArgs(AmbientScope, id, versionId));
- // fixme - syntax + ...
Database.Delete("WHERE versionId = @versionId", new { versionId });
Database.Delete("WHERE id = @versionId", new { versionId });
Database.Delete("WHERE id = @versionId", new { versionId });
@@ -263,7 +262,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
protected override void PersistNewItem(IContent entity)
{
- // fixme - stop doing this - sort out IContent vs Content
+ // TODO: https://github.com/umbraco/Umbraco-CMS/issues/4234 - sort out IContent vs Content
// however, it's not just so we have access to AddingEntity
// there are tons of things at the end of the methods, that can only work with a true Content
// and basically, the repository requires a Content, not an IContent
@@ -280,7 +279,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
SanitizeNames(content, publishing);
// ensure that strings don't contain characters that are invalid in xml
- // fixme - do we really want to keep doing this here?
+ // TODO: do we really want to keep doing this here?
entity.SanitizeEntityPropertiesForXmlStorage();
// create the dto
@@ -439,7 +438,6 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
protected override void PersistUpdatedItem(IContent entity)
{
- // fixme - stop doing this - sort out IContent vs Content
// however, it's not just so we have access to AddingEntity
// there are tons of things at the end of the methods, that can only work with a true Content
// and basically, the repository requires a Content, not an IContent
@@ -451,7 +449,6 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
return; // no change to save, do nothing, don't even update dates
// whatever we do, we must check that we are saving the current version
- // fixme maybe we can just fetch Current (bool)
var version = Database.Fetch(SqlContext.Sql().Select().From().Where(x => x.Id == content.VersionId)).FirstOrDefault();
if (version == null || !version.Current)
throw new InvalidOperationException("Cannot save a non-current version.");
@@ -471,7 +468,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
SanitizeNames(content, publishing);
// ensure that strings don't contain characters that are invalid in xml
- // fixme - do we really want to keep doing this here?
+ // TODO: do we really want to keep doing this here?
entity.SanitizeEntityPropertiesForXmlStorage();
// if parent has changed, get path, level and sort order
@@ -550,7 +547,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
edited = true;
(editedCultures ?? (editedCultures = new HashSet(StringComparer.OrdinalIgnoreCase))).Add(culture);
- // fixme - change tracking
+ // TODO: change tracking
// at the moment, we don't do any dirty tracking on property values, so we don't know whether the
// culture has just been edited or not, so we don't update its update date - that date only changes
// when the name is set, and it all works because the controller does it - but, if someone uses a
@@ -566,8 +563,8 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
var deleteDocumentVariations = Sql().Delete