V15/task/cleanup obsolete (#17433)

* Replace obsolete UserGroup Alias consts to key equivalent in tests

* Update use of usergroup alias consts to key equivalent in IsSystemgroup extension method

* Obsolete (internally) unused helper function which purpose doesn't even seem true

* Prepped EmbedProviders for proper removal of non async methods and unneeded proxy methods

* Remove obsoleted UmbracoPath and updated internal references

* Corrected  mistake and updated unittets

* Update usergroup tests that use aliases for "system" groups

* Replace more uses of globalsettings.UmbracoPath

* Remove GetDateType by key non async

* Cleanup some usages of hostingEnvironment.MapPathContentRoot

* More easy obsoletion cleanup

* Small Typeload cleanup

* More obsolete removal

* Deploy obsoletion cleanup

* Remove obsolete methods from OEmbedProviderBase.cs

---------

Co-authored-by: Zeegaan <skrivdetud@gmail.com>
This commit is contained in:
Sven Geusens
2024-11-07 12:20:22 +01:00
committed by GitHub
parent 669c585ac4
commit e7eb14d310
75 changed files with 436 additions and 916 deletions

View File

@@ -51,7 +51,7 @@ public class BackOfficeLoginController : Controller
if (string.IsNullOrEmpty(model.UmbracoUrl))
{
model.UmbracoUrl = _hostingEnvironment.ToAbsolute(_globalSettings.UmbracoPath);
model.UmbracoUrl = _hostingEnvironment.ToAbsolute(Constants.System.DefaultUmbracoPath);
}
if (string.IsNullOrEmpty(model.ReturnUrl))

View File

@@ -1,20 +0,0 @@
using Microsoft.EntityFrameworkCore;
using Umbraco.Cms.Core.DependencyInjection;
using Umbraco.Cms.Persistence.EFCore;
namespace Umbraco.Extensions;
public static class BackOfficeAuthBuilderOpenIddictExtensions
{
[Obsolete("This is no longer used and will be removed in V15. Instead use the overload that specifies the DbContext type.")]
public static IUmbracoBuilder AddUmbracoEFCoreDbContext(this IUmbracoBuilder builder)
{
builder.Services.AddUmbracoEFCoreContext<UmbracoDbContext>((options, connectionString, providerName) =>
{
// Register the entity sets needed by OpenIddict.
options.UseOpenIddict();
});
return builder;
}
}

View File

@@ -14,45 +14,6 @@ public static class UmbracoEFCoreServiceCollectionExtensions
{
public delegate void DefaultEFCoreOptionsAction(DbContextOptionsBuilder options, string? providerName, string? connectionString);
[Obsolete("Use AddUmbracoDbContext<T>(this IServiceCollection services, Action<DbContextOptionsBuilder>? optionsAction = null) instead.")]
public static IServiceCollection AddUmbracoEFCoreContext<T>(this IServiceCollection services, DefaultEFCoreOptionsAction? defaultEFCoreOptionsAction = null)
where T : DbContext
{
services.AddPooledDbContextFactory<T>((provider, builder) => SetupDbContext(defaultEFCoreOptionsAction, provider, builder));
services.AddTransient(services => services.GetRequiredService<IDbContextFactory<T>>().CreateDbContext());
services.AddUnique<IAmbientEFCoreScopeStack<T>, AmbientEFCoreScopeStack<T>>();
services.AddUnique<IEFCoreScopeAccessor<T>, EFCoreScopeAccessor<T>>();
services.AddUnique<IEFCoreScopeProvider<T>, EFCoreScopeProvider<T>>();
services.AddSingleton<IDistributedLockingMechanism, SqliteEFCoreDistributedLockingMechanism<T>>();
services.AddSingleton<IDistributedLockingMechanism, SqlServerEFCoreDistributedLockingMechanism<T>>();
return services;
}
[Obsolete("Use AddUmbracoDbContext<T>(this IServiceCollection services, Action<DbContextOptionsBuilder>? optionsAction = null) instead.")]
public static IServiceCollection AddUmbracoEFCoreContext<T>(this IServiceCollection services, string connectionString, string providerName, DefaultEFCoreOptionsAction? defaultEFCoreOptionsAction = null)
where T : DbContext
{
// Replace data directory
string? dataDirectory = AppDomain.CurrentDomain.GetData(Constants.System.DataDirectoryName)?.ToString();
if (string.IsNullOrEmpty(dataDirectory) is false)
{
connectionString = connectionString.Replace(Constants.System.DataDirectoryPlaceholder, dataDirectory);
}
services.AddPooledDbContextFactory<T>(options => defaultEFCoreOptionsAction?.Invoke(options, providerName, connectionString));
services.AddTransient(services => services.GetRequiredService<IDbContextFactory<T>>().CreateDbContext());
services.AddUnique<IAmbientEFCoreScopeStack<T>, AmbientEFCoreScopeStack<T>>();
services.AddUnique<IEFCoreScopeAccessor<T>, EFCoreScopeAccessor<T>>();
services.AddUnique<IEFCoreScopeProvider<T>, EFCoreScopeProvider<T>>();
services.AddSingleton<IDistributedLockingMechanism, SqliteEFCoreDistributedLockingMechanism<T>>();
services.AddSingleton<IDistributedLockingMechanism, SqlServerEFCoreDistributedLockingMechanism<T>>();
return services;
}
/// <summary>
/// Adds a EFCore DbContext with all the services needed to integrate with Umbraco scopes.
/// </summary>
@@ -149,26 +110,4 @@ public static class UmbracoEFCoreServiceCollectionExtensions
builder.UseDatabaseProvider(connectionStrings.ProviderName, connectionStrings.ConnectionString);
}
[Obsolete]
private static void SetupDbContext(DefaultEFCoreOptionsAction? defaultEFCoreOptionsAction, IServiceProvider provider, DbContextOptionsBuilder builder)
{
ConnectionStrings connectionStrings = GetConnectionStringAndProviderName(provider);
defaultEFCoreOptionsAction?.Invoke(builder, connectionStrings.ConnectionString, connectionStrings.ProviderName);
}
[Obsolete]
private static ConnectionStrings GetConnectionStringAndProviderName(IServiceProvider serviceProvider)
{
ConnectionStrings connectionStrings = serviceProvider.GetRequiredService<IOptionsMonitor<ConnectionStrings>>().CurrentValue;
// Replace data directory
string? dataDirectory = AppDomain.CurrentDomain.GetData(Constants.System.DataDirectoryName)?.ToString();
if (string.IsNullOrEmpty(dataDirectory) is false)
{
connectionStrings.ConnectionString = connectionStrings.ConnectionString?.Replace(Constants.System.DataDirectoryPlaceholder, dataDirectory);
}
return connectionStrings;
}
}

View File

@@ -1,35 +0,0 @@
// Copyright (c) Umbraco.
// See LICENSE for more details.
namespace Umbraco.Cms.Core.Actions;
/// <summary>
/// This action is invoked when children to a document is being sent to published (by an editor without publishrights).
/// </summary>
[Obsolete("Scheduled for removal in v13")]
public class ActionToPublish : IAction
{
/// <inheritdoc cref="IAction.ActionLetter"/>
public const string ActionLetter = "Umb.Document.SendForApproval";
/// <inheritdoc cref="IAction.ActionAlias"/>
public const string ActionAlias = "sendtopublish";
/// <inheritdoc/>
public string Letter => ActionLetter;
/// <inheritdoc/>
public string Alias => ActionAlias;
/// <inheritdoc />
public string Category => Constants.Conventions.PermissionCategories.ContentCategory;
/// <inheritdoc />
public string Icon => "icon-outbox";
/// <inheritdoc />
public bool ShowInNotifier => true;
/// <inheritdoc />
public bool CanBePermissionAssigned => true;
}

View File

@@ -26,7 +26,7 @@ internal sealed class DataTypeConfigurationCache : IDataTypeConfigurationCache
var cacheKey = GetCacheKey(key);
if (_memoryCache.TryGetValue(cacheKey, out T? configuration) is false)
{
IDataType? dataType = _dataTypeService.GetDataType(key);
IDataType? dataType = _dataTypeService.GetAsync(key).GetAwaiter().GetResult();
configuration = dataType?.ConfigurationAs<T>();
// Only cache if data type was found (but still cache null configurations)

View File

@@ -367,16 +367,6 @@ public sealed class ContentCacheRefresher : PayloadCacheRefresherBase<ContentCac
// TODO (V14): Change into a record
public class JsonPayload
{
public JsonPayload()
{ }
[Obsolete("Use the default constructor and property initializers.")]
public JsonPayload(int id, Guid? key, TreeChangeTypes changeTypes)
{
Id = id;
Key = key;
ChangeTypes = changeTypes;
}
public int Id { get; init; }

View File

@@ -27,39 +27,6 @@ public sealed class TypeLoader
private IEnumerable<Assembly>? _assemblies;
/// <summary>
/// Initializes a new instance of the <see cref="TypeLoader" /> class.
/// </summary>
[Obsolete("Please use an alternative constructor.")]
public TypeLoader(
ITypeFinder typeFinder,
IRuntimeHash runtimeHash,
IAppPolicyCache runtimeCache,
DirectoryInfo localTempPath,
ILogger<TypeLoader> logger,
IProfiler profiler,
IEnumerable<Assembly>? assembliesToScan = null)
: this(typeFinder, logger, assembliesToScan)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="TypeLoader" /> class.
/// </summary>
[Obsolete("Please use an alternative constructor.")]
public TypeLoader(
ITypeFinder typeFinder,
IRuntimeHash runtimeHash,
IAppPolicyCache runtimeCache,
DirectoryInfo localTempPath,
ILogger<TypeLoader> logger,
IProfiler profiler,
bool detectChanges,
IEnumerable<Assembly>? assembliesToScan = null)
: this(typeFinder, logger, assembliesToScan)
{
}
public TypeLoader(
ITypeFinder typeFinder,
ILogger<TypeLoader> logger,
@@ -100,18 +67,6 @@ public sealed class TypeLoader
[Obsolete("This will be removed in a future version.")]
public IEnumerable<TypeList> TypeLists => _types.Values;
/// <summary>
/// Sets a type list.
/// </summary>
/// <remarks>For unit tests.</remarks>
// internal for tests
[Obsolete("This will be removed in a future version.")]
public void AddTypeList(TypeList typeList)
{
Type tobject = typeof(object); // CompositeTypeTypeKey does not support null values
_types[new CompositeTypeTypeKey(typeList.BaseType ?? tobject, typeList.AttributeType ?? tobject)] = typeList;
}
#region Get Assembly Attributes
/// <summary>
@@ -136,34 +91,6 @@ public sealed class TypeLoader
#region Cache
// internal for tests
[Obsolete("This will be removed in a future version.")]
public Attempt<IEnumerable<string>> TryGetCached(Type baseType, Type attributeType) =>
Attempt<IEnumerable<string>>.Fail();
// internal for tests
[Obsolete("This will be removed in a future version.")]
public Dictionary<(string, string), IEnumerable<string>>? ReadCache() => null;
// internal for tests
[Obsolete("This will be removed in a future version.")]
public string? GetTypesListFilePath() => null;
// internal for tests
[Obsolete("This will be removed in a future version.")]
public void WriteCache()
{
}
/// <summary>
/// Clears cache.
/// </summary>
/// <remarks>Generally only used for resetting cache, for example during the install process.</remarks>
[Obsolete("This will be removed in a future version.")]
public void ClearTypesCache()
{
}
#endregion
#region Get Types

View File

@@ -22,7 +22,7 @@ public static class GlobalSettingsExtensions
return _backOfficePath;
}
_backOfficePath = hostingEnvironment.ToAbsolute(globalSettings.UmbracoPath);
_backOfficePath = hostingEnvironment.ToAbsolute(Constants.System.DefaultUmbracoPath);
return _backOfficePath;
}
@@ -54,9 +54,9 @@ public static class GlobalSettingsExtensions
this GlobalSettings globalSettings,
IHostingEnvironment hostingEnvironment)
{
var path = string.IsNullOrEmpty(globalSettings.UmbracoPath)
var path = string.IsNullOrEmpty(Constants.System.DefaultUmbracoPath)
? string.Empty
: hostingEnvironment.ToAbsolute(globalSettings.UmbracoPath);
: hostingEnvironment.ToAbsolute(Constants.System.DefaultUmbracoPath);
if (path.IsNullOrWhiteSpace())
{

View File

@@ -76,16 +76,6 @@ public class GlobalSettings
[DefaultValue(StaticVersionCheckPeriod)]
public int VersionCheckPeriod { get; set; } = StaticVersionCheckPeriod;
/// <summary>
/// Gets or sets a value for the Umbraco back-office path.
/// </summary>
[Obsolete($"UmbracoPath is no longer configurable, use Constants.System.DefaultUmbracoPath instead. This property is scheduled for removal in a future version.")]
public string UmbracoPath
{
get => Constants.System.DefaultUmbracoPath;
set { }
}
/// <summary>
/// Gets or sets a value for the Umbraco icons path.
/// </summary>

View File

@@ -19,7 +19,7 @@ public class NuCacheSettings
/// <summary>
/// Gets or sets a value defining the BTree block size.
/// </summary>
[Obsolete("This property is no longer used")]
[Obsolete("This property is no longer used. Scheduled for removal in v16")]
public int? BTreeBlockSize { get; set; }
/// <summary>

View File

@@ -95,13 +95,6 @@ public class SecuritySettings
[DefaultValue(StaticUserDefaultLockoutTimeInMinutes)]
public int UserDefaultLockoutTimeInMinutes { get; set; } = StaticUserDefaultLockoutTimeInMinutes;
/// <summary>
/// Gets or sets a value indicating whether to allow editing invariant properties from a non-default language variation.
/// </summary>
[Obsolete("Use ContentSettings.AllowEditFromInvariant instead")]
[DefaultValue(StaticAllowEditInvariantFromNonDefault)]
public bool AllowEditInvariantFromNonDefault { get; set; } = StaticAllowEditInvariantFromNonDefault;
/// <summary>
/// Gets or sets a value indicating whether to allow concurrent logins.
/// </summary>

View File

@@ -60,10 +60,6 @@ public class WebRoutingSettings
[DefaultValue(StaticValidateAlternativeTemplates)]
public bool ValidateAlternativeTemplates { get; set; } = StaticValidateAlternativeTemplates;
[Obsolete("Use DisableFindContentByIdentifierPath instead. This will be removed in Umbraco 15." )]
[DefaultValue(StaticDisableFindContentByIdPath)]
public bool DisableFindContentByIdPath { get; set; } = StaticDisableFindContentByIdPath;
[DefaultValue(StaticDisableFindContentByIdentifierPath)]
public bool DisableFindContentByIdentifierPath { get; set; } = StaticDisableFindContentByIdentifierPath;
/// <summary>

View File

@@ -1,6 +1,8 @@
using Microsoft.Extensions.Hosting;
using Umbraco.Cms.Core.Configuration.Models;
using Umbraco.Cms.Core.Exceptions;
using Umbraco.Cms.Core.Hosting;
using Umbraco.Cms.Core.Extensions;
using IHostingEnvironment = Umbraco.Cms.Core.Hosting.IHostingEnvironment;
namespace Umbraco.Extensions;
@@ -8,6 +10,22 @@ public static class ModelsBuilderConfigExtensions
{
private static string? _modelsDirectoryAbsolute;
public static string ModelsDirectoryAbsolute(
this ModelsBuilderSettings modelsBuilderConfig,
IHostEnvironment hostEnvironment)
{
if (_modelsDirectoryAbsolute is null)
{
var modelsDirectory = modelsBuilderConfig.ModelsDirectory;
var root = hostEnvironment.MapPathContentRoot("~/");
_modelsDirectoryAbsolute = GetModelsDirectory(root, modelsDirectory, modelsBuilderConfig.AcceptUnsafeModelsDirectory);
}
return _modelsDirectoryAbsolute;
}
[Obsolete("Use the non obsoleted equivalent instead. Scheduled for removal in v16")]
public static string ModelsDirectoryAbsolute(
this ModelsBuilderSettings modelsBuilderConfig,
IHostingEnvironment hostingEnvironment)

View File

@@ -49,27 +49,35 @@ public static partial class Constants
/// <summary>
/// The key of the admin group
/// </summary>
public static readonly Guid AdminGroupKey = new("E5E7F6C8-7F9C-4B5B-8D5D-9E1E5A4F7E4D");
public static readonly Guid AdminGroupKey = new(AdminGroupKeyString);
internal const string AdminGroupKeyString = "E5E7F6C8-7F9C-4B5B-8D5D-9E1E5A4F7E4D";
/// <summary>
/// The key of the editor group
/// </summary>
public static readonly Guid EditorGroupKey = new("44DC260E-B4D4-4DD9-9081-EEC5598F1641");
public static readonly Guid EditorGroupKey = new(EditorGroupKeyString);
internal const string EditorGroupKeyString = "44DC260E-B4D4-4DD9-9081-EEC5598F1641";
/// <summary>
/// The key of the sensitive data group
/// </summary>
public static readonly Guid SensitiveDataGroupKey = new("8C6AD70F-D307-4E4A-AF58-72C2E4E9439D");
public static readonly Guid SensitiveDataGroupKey = new(SensitiveDataGroupKeyString);
internal const string SensitiveDataGroupKeyString = "8C6AD70F-D307-4E4A-AF58-72C2E4E9439D";
/// <summary>
/// The key of the translator group
/// </summary>
public static readonly Guid TranslatorGroupKey = new("F2012E4C-D232-4BD1-8EAE-4384032D97D8");
public static readonly Guid TranslatorGroupKey = new(TranslatorGroupString);
internal const string TranslatorGroupString = "F2012E4C-D232-4BD1-8EAE-4384032D97D8";
/// <summary>
/// The key of the writer group
/// </summary>
public static readonly Guid WriterGroupKey = new("9FC2A16F-528C-46D6-A014-75BF4EC2480C");
public static readonly Guid WriterGroupKey = new(WriterGroupKeyString);
internal const string WriterGroupKeyString = "9FC2A16F-528C-46D6-A014-75BF4EC2480C";
public const string BackOfficeAuthenticationType = "UmbracoBackOffice";
public const string BackOfficeExternalAuthenticationType = "UmbracoExternalCookie";

View File

@@ -5,9 +5,6 @@ namespace Umbraco.Cms.Core.DeliveryApi;
public interface IApiRichTextElementParser
{
// NOTE: remember to also remove the default implementation of the method overload when this one is removed.
[Obsolete($"Please use the overload that accepts {nameof(RichTextBlockModel)}. Will be removed in V15.")]
IRichTextElement? Parse(string html);
IRichTextElement? Parse(string html, RichTextBlockModel? richTextBlockModel) => null;
IRichTextElement? Parse(string html, RichTextBlockModel? richTextBlockModel);
}

View File

@@ -109,20 +109,6 @@ public static partial class UmbracoBuilderExtensions
builder.Services.Configure<CacheEntrySettings>(Constants.Configuration.NamedOptions.CacheEntry.Document,
builder.Config.GetSection($"{Constants.Configuration.ConfigCacheEntry}:{Constants.Configuration.NamedOptions.CacheEntry.Document}"));
// TODO: Remove this in V12
// This is to make the move of the AllowEditInvariantFromNonDefault setting from SecuritySettings to ContentSettings backwards compatible
// If there is a value in security settings, but no value in content setting we'll use that value, otherwise content settings always wins.
builder.Services.Configure<ContentSettings>(settings =>
{
var securitySettingsValue = builder.Config.GetSection($"{Constants.Configuration.ConfigSecurity}").GetValue<bool?>(nameof(SecuritySettings.AllowEditInvariantFromNonDefault));
var contentSettingsValue = builder.Config.GetSection($"{Constants.Configuration.ConfigContent}").GetValue<bool?>(nameof(ContentSettings.AllowEditInvariantFromNonDefault));
if (securitySettingsValue is not null && contentSettingsValue is null)
{
settings.AllowEditInvariantFromNonDefault = securitySettingsValue.Value;
}
});
return builder;
}
}

View File

@@ -63,6 +63,7 @@ namespace Umbraco.Cms.Core.DependencyInjection
public ILoggerFactory BuilderLoggerFactory { get; }
/// <inheritdoc />
[Obsolete("Only here to comply with obsolete implementation. Scheduled for removal in v16")]
public IHostingEnvironment? BuilderHostingEnvironment { get; }
public IProfiler Profiler { get; }
@@ -79,6 +80,7 @@ namespace Umbraco.Cms.Core.DependencyInjection
/// <summary>
/// Initializes a new instance of the <see cref="UmbracoBuilder"/> class.
/// </summary>
[Obsolete("Use a non obsolete constructor instead. Scheduled for removal in v16")]
public UmbracoBuilder(
IServiceCollection services,
IConfiguration config,
@@ -99,6 +101,27 @@ namespace Umbraco.Cms.Core.DependencyInjection
AddCoreServices();
}
/// <summary>
/// Initializes a new instance of the <see cref="UmbracoBuilder"/> class.
/// </summary>
public UmbracoBuilder(
IServiceCollection services,
IConfiguration config,
TypeLoader typeLoader,
ILoggerFactory loggerFactory,
IProfiler profiler,
AppCaches appCaches)
{
Services = services;
Config = config;
BuilderLoggerFactory = loggerFactory;
Profiler = profiler;
AppCaches = appCaches;
TypeLoader = typeLoader;
AddCoreServices();
}
/// <summary>
/// Gets a collection builder (and registers the collection).
/// </summary>

View File

@@ -19,18 +19,6 @@ public interface IDataTypeConfigurationConnector
/// </value>
IEnumerable<string> PropertyEditorAliases { get; }
/// <summary>
/// Gets the artifact configuration value corresponding to a data type configuration and gather dependencies.
/// </summary>
/// <param name="dataType">The data type.</param>
/// <param name="dependencies">The dependencies.</param>
/// <param name="contextCache">The context cache.</param>
/// <returns>
/// The artifact configuration value.
/// </returns>
[Obsolete("Use ToArtifactAsync() instead. This method will be removed in a future version.")]
string? ToArtifact(IDataType dataType, ICollection<ArtifactDependency> dependencies, IContextCache contextCache);
/// <summary>
/// Gets the artifact configuration value corresponding to a data type configuration and gather dependencies.
/// </summary>
@@ -41,22 +29,11 @@ public interface IDataTypeConfigurationConnector
/// <returns>
/// A task that represents the asynchronous operation. The task result contains the artifact configuration value.
/// </returns>
Task<string?> ToArtifactAsync(IDataType dataType, ICollection<ArtifactDependency> dependencies, IContextCache contextCache, CancellationToken cancellationToken = default)
#pragma warning disable CS0618 // Type or member is obsolete
=> Task.FromResult(ToArtifact(dataType, dependencies, contextCache)); // TODO: Remove default implementation in v15
#pragma warning restore CS0618 // Type or member is obsolete
/// <summary>
/// Gets the data type configuration corresponding to an artifact configuration value.
/// </summary>
/// <param name="dataType">The data type.</param>
/// <param name="configuration">The artifact configuration value.</param>
/// <param name="contextCache">The context cache.</param>
/// <returns>
/// The data type configuration.
/// </returns>
[Obsolete("Use FromArtifactAsync() instead. This method will be removed in a future version.")]
IDictionary<string, object> FromArtifact(IDataType dataType, string? configuration, IContextCache contextCache);
Task<string?> ToArtifactAsync(
IDataType dataType,
ICollection<ArtifactDependency> dependencies,
IContextCache contextCache,
CancellationToken cancellationToken = default);
/// <summary>
/// Gets the data type configuration corresponding to an artifact configuration value.
@@ -68,8 +45,9 @@ public interface IDataTypeConfigurationConnector
/// <returns>
/// A task that represents the asynchronous operation. The task result contains the data type configuration.
/// </returns>
Task<IDictionary<string, object>> FromArtifactAsync(IDataType dataType, string? configuration, IContextCache contextCache, CancellationToken cancellationToken = default)
#pragma warning disable CS0618 // Type or member is obsolete
=> Task.FromResult(FromArtifact(dataType, configuration, contextCache)); // TODO: Remove default implementation in v15
#pragma warning restore CS0618 // Type or member is obsolete
Task<IDictionary<string, object>> FromArtifactAsync(
IDataType dataType,
string? configuration,
IContextCache contextCache,
CancellationToken cancellationToken = default);
}

View File

@@ -6,19 +6,6 @@ namespace Umbraco.Cms.Core.Deploy;
/// </summary>
public interface IFileSource
{
/// <summary>
/// Gets the content of a file as a stream.
/// </summary>
/// <param name="udi">A file entity identifier.</param>
/// <returns>
/// A stream with read access to the file content.
/// </returns>
/// <remarks>
/// <para>Returns null if no content could be read.</para>
/// <para>The caller should ensure that the stream is properly closed/disposed.</para>
/// </remarks>
[Obsolete("Use GetFileStreamAsync() instead. This method will be removed in a future version.")]
Stream GetFileStream(StringUdi udi);
/// <summary>
/// Gets the content of a file as a stream.
@@ -34,19 +21,6 @@ public interface IFileSource
/// </remarks>
Task<Stream> GetFileStreamAsync(StringUdi udi, CancellationToken token);
/// <summary>
/// Gets the content of a file as a string.
/// </summary>
/// <param name="udi">A file entity identifier.</param>
/// <returns>
/// A string containing the file content.
/// </returns>
/// <remarks>
/// Returns null if no content could be read.
/// </remarks>
[Obsolete("Use GetFileContentAsync() instead. This method will be removed in a future version.")]
string GetFileContent(StringUdi udi);
/// <summary>
/// Gets the content of a file as a string.
/// </summary>
@@ -60,16 +34,6 @@ public interface IFileSource
/// </remarks>
Task<string> GetFileContentAsync(StringUdi udi, CancellationToken token);
/// <summary>
/// Gets the length of a file.
/// </summary>
/// <param name="udi">A file entity identifier.</param>
/// <returns>
/// The length of the file, or -1 if the file does not exist.
/// </returns>
[Obsolete("Use GetFileLengthAsync() instead. This method will be removed in a future version.")]
long GetFileLength(StringUdi udi);
/// <summary>
/// Gets the length of a file.
/// </summary>
@@ -80,15 +44,6 @@ public interface IFileSource
/// </returns>
Task<long> GetFileLengthAsync(StringUdi udi, CancellationToken token);
/// <summary>
/// Gets files and store them using a file store.
/// </summary>
/// <param name="udis">The UDIs of the files to get.</param>
/// <param name="continueOnFileNotFound">A flag indicating whether to continue if a file isn't found or to stop and throw a FileNotFoundException.</param>
/// <param name="fileTypes">A collection of file types which can store the files.</param>
[Obsolete("Use GetFilesAsync() instead. This method will be removed in a future version.")]
void GetFiles(IEnumerable<StringUdi> udis, bool continueOnFileNotFound, IFileTypeCollection fileTypes);
/// <summary>
/// Gets files and store them using a file store.
/// </summary>

View File

@@ -13,16 +13,6 @@ public interface IFileType
/// </value>
bool CanSetPhysical { get; }
/// <summary>
/// Gets the stream.
/// </summary>
/// <param name="udi">The UDI.</param>
/// <returns>
/// The stream.
/// </returns>
[Obsolete("Use GetStreamAsync() instead. This method will be removed in a future version.")]
Stream GetStream(StringUdi udi);
/// <summary>
/// Gets the stream as an asynchronous operation.
/// </summary>
@@ -51,14 +41,6 @@ public interface IFileType
/// </returns>
long GetLength(StringUdi udi);
/// <summary>
/// Sets the stream.
/// </summary>
/// <param name="udi">The UDI.</param>
/// <param name="stream">The stream.</param>
[Obsolete("Use SetStreamAsync() instead. This method will be removed in a future version.")]
void SetStream(StringUdi udi, Stream stream);
/// <summary>
/// Sets the stream as an asynchronous operation.
/// </summary>

View File

@@ -5,21 +5,6 @@ namespace Umbraco.Cms.Core.Deploy;
/// </summary>
public interface IImageSourceParser
{
/// <summary>
/// Parses an Umbraco property value and produces an artifact property value.
/// </summary>
/// <param name="value">The property value.</param>
/// <param name="dependencies">A list of dependencies.</param>
/// <param name="contextCache">The context cache.</param>
/// <returns>
/// The parsed value.
/// </returns>
/// <remarks>
/// Turns src="/media/..." into src="umb://media/..." and adds the corresponding udi to the dependencies.
/// </remarks>
[Obsolete("Use ToArtifactAsync() instead. This method will be removed in a future version.")]
string ToArtifact(string value, ICollection<Udi> dependencies, IContextCache contextCache);
/// <summary>
/// Parses an Umbraco property value and produces an artifact property value.
/// </summary>
@@ -33,24 +18,7 @@ public interface IImageSourceParser
/// <remarks>
/// Turns src="/media/..." into src="umb://media/..." and adds the corresponding udi to the dependencies.
/// </remarks>
Task<string> ToArtifactAsync(string value, ICollection<Udi> dependencies, IContextCache contextCache, CancellationToken cancellationToken = default)
#pragma warning disable CS0618 // Type or member is obsolete
=> Task.FromResult(ToArtifact(value, dependencies, contextCache)); // TODO: Remove default implementation in v15
#pragma warning restore CS0618 // Type or member is obsolete
/// <summary>
/// Parses an artifact property value and produces an Umbraco property value.
/// </summary>
/// <param name="value">The artifact property value.</param>
/// <param name="contextCache">The context cache.</param>
/// <returns>
/// The parsed value.
/// </returns>
/// <remarks>
/// Turns umb://media/... into /media/....
/// </remarks>
[Obsolete("Use FromArtifactAsync() instead. This method will be removed in a future version.")]
string FromArtifact(string value, IContextCache contextCache);
Task<string> ToArtifactAsync(string value, ICollection<Udi> dependencies, IContextCache contextCache, CancellationToken cancellationToken = default);
/// <summary>
/// Parses an artifact property value and produces an Umbraco property value.
@@ -64,8 +32,5 @@ public interface IImageSourceParser
/// <remarks>
/// Turns umb://media/... into /media/....
/// </remarks>
Task<string> FromArtifactAsync(string value, IContextCache contextCache, CancellationToken cancellationToken = default)
#pragma warning disable CS0618 // Type or member is obsolete
=> Task.FromResult(FromArtifact(value, contextCache)); // TODO: Remove default implementation in v15
#pragma warning restore CS0618 // Type or member is obsolete
Task<string> FromArtifactAsync(string value, IContextCache contextCache, CancellationToken cancellationToken = default);
}

View File

@@ -5,21 +5,6 @@ namespace Umbraco.Cms.Core.Deploy;
/// </summary>
public interface ILocalLinkParser
{
/// <summary>
/// Parses an Umbraco property value and produces an artifact property value.
/// </summary>
/// <param name="value">The property value.</param>
/// <param name="dependencies">A list of dependencies.</param>
/// <param name="contextCache">The context cache.</param>
/// <returns>
/// The parsed value.
/// </returns>
/// <remarks>
/// Turns {{localLink:1234}} into {{localLink:umb://{type}/{id}}} and adds the corresponding udi to the dependencies.
/// </remarks>
[Obsolete("Use ToArtifactAsync() instead. This method will be removed in a future version.")]
string ToArtifact(string value, ICollection<Udi> dependencies, IContextCache contextCache);
/// <summary>
/// Parses an Umbraco property value and produces an artifact property value.
/// </summary>
@@ -33,24 +18,7 @@ public interface ILocalLinkParser
/// <remarks>
/// Turns {{localLink:1234}} into {{localLink:umb://{type}/{id}}} and adds the corresponding udi to the dependencies.
/// </remarks>
Task<string> ToArtifactAsync(string value, ICollection<Udi> dependencies, IContextCache contextCache, CancellationToken cancellationToken = default)
#pragma warning disable CS0618 // Type or member is obsolete
=> Task.FromResult(ToArtifact(value, dependencies, contextCache)); // TODO: Remove default implementation in v15
#pragma warning restore CS0618 // Type or member is obsolete
/// <summary>
/// Parses an artifact property value and produces an Umbraco property value.
/// </summary>
/// <param name="value">The artifact property value.</param>
/// <param name="contextCache">The context cache.</param>
/// <returns>
/// The parsed value.
/// </returns>
/// <remarks>
/// Turns {{localLink:umb://{type}/{id}}} into {{localLink:1234}}.
/// </remarks>
[Obsolete("Use FromArtifactAsync() instead. This method will be removed in a future version.")]
string FromArtifact(string value, IContextCache contextCache);
Task<string> ToArtifactAsync(string value, ICollection<Udi> dependencies, IContextCache contextCache, CancellationToken cancellationToken = default);
/// <summary>
/// Parses an artifact property value and produces an Umbraco property value.
@@ -64,8 +32,5 @@ public interface ILocalLinkParser
/// <remarks>
/// Turns {{localLink:umb://{type}/{id}}} into {{localLink:1234}}.
/// </remarks>
Task<string> FromArtifactAsync(string value, IContextCache contextCache, CancellationToken cancellationToken = default)
#pragma warning disable CS0618 // Type or member is obsolete
=> Task.FromResult(FromArtifact(value, contextCache)); // TODO: Remove default implementation in v15
#pragma warning restore CS0618 // Type or member is obsolete
Task<string> FromArtifactAsync(string value, IContextCache contextCache, CancellationToken cancellationToken = default);
}

View File

@@ -8,17 +8,6 @@ namespace Umbraco.Cms.Core.Deploy;
/// </summary>
public interface IServiceConnector : IDiscoverable
{
/// <summary>
/// Gets an artifact.
/// </summary>
/// <param name="udi">The entity identifier of the artifact.</param>
/// <param name="contextCache">The context cache.</param>
/// <returns>
/// The corresponding artifact or <c>null</c>.
/// </returns>
[Obsolete("Use GetArtifactAsync() instead. This method will be removed in a future version.")]
IArtifact? GetArtifact(Udi udi, IContextCache contextCache);
/// <summary>
/// Gets an artifact.
/// </summary>
@@ -28,21 +17,7 @@ public interface IServiceConnector : IDiscoverable
/// <returns>
/// A task that represents the asynchronous operation. The task result contains the corresponding artifact or <c>null</c>.
/// </returns>
Task<IArtifact?> GetArtifactAsync(Udi udi, IContextCache contextCache, CancellationToken cancellationToken = default)
#pragma warning disable CS0618 // Type or member is obsolete
=> Task.FromResult(GetArtifact(udi, contextCache)); // TODO: Remove default implementation in v15
#pragma warning restore CS0618 // Type or member is obsolete
/// <summary>
/// Gets an artifact.
/// </summary>
/// <param name="entity">The entity.</param>
/// <param name="contextCache">The context cache.</param>
/// <returns>
/// The corresponding artifact.
/// </returns>
[Obsolete("Use GetArtifactAsync() instead. This method will be removed in a future version.")]
IArtifact GetArtifact(object entity, IContextCache contextCache);
Task<IArtifact?> GetArtifactAsync(Udi udi, IContextCache contextCache, CancellationToken cancellationToken = default);
/// <summary>
/// Gets an artifact.
@@ -53,21 +28,7 @@ public interface IServiceConnector : IDiscoverable
/// <returns>
/// A task that represents the asynchronous operation. The task result contains the corresponding artifact.
/// </returns>
Task<IArtifact> GetArtifactAsync(object entity, IContextCache contextCache, CancellationToken cancellationToken = default)
#pragma warning disable CS0618 // Type or member is obsolete
=> Task.FromResult(GetArtifact(entity, contextCache)); // TODO: Remove default implementation in v15
#pragma warning restore CS0618 // Type or member is obsolete
/// <summary>
/// Initializes processing for an artifact.
/// </summary>
/// <param name="art">The artifact.</param>
/// <param name="context">The deploy context.</param>
/// <returns>
/// The state of an artifact being deployed.
/// </returns>
[Obsolete("Use ProcessInitAsync() instead. This method will be removed in a future version.")]
ArtifactDeployState ProcessInit(IArtifact art, IDeployContext context);
Task<IArtifact> GetArtifactAsync(object entity, IContextCache contextCache, CancellationToken cancellationToken = default);
/// <summary>
/// Initializes processing for an artifact.
@@ -78,19 +39,7 @@ public interface IServiceConnector : IDiscoverable
/// <returns>
/// A task that represents the asynchronous operation. The task result contains the state of an artifact being deployed.
/// </returns>
Task<ArtifactDeployState> ProcessInitAsync(IArtifact artifact, IDeployContext context, CancellationToken cancellationToken = default)
#pragma warning disable CS0618 // Type or member is obsolete
=> Task.FromResult(ProcessInit(artifact, context)); // TODO: Remove default implementation in v15
#pragma warning restore CS0618 // Type or member is obsolete
/// <summary>
/// Processes an artifact.
/// </summary>
/// <param name="dart">The state of the artifact being deployed.</param>
/// <param name="context">The deploy context.</param>
/// <param name="pass">The processing pass number.</param>
[Obsolete("Use ProcessAsync() instead. This method will be removed in a future version.")]
void Process(ArtifactDeployState dart, IDeployContext context, int pass);
Task<ArtifactDeployState> ProcessInitAsync(IArtifact artifact, IDeployContext context, CancellationToken cancellationToken = default);
/// <summary>
/// Processes an artifact.
@@ -102,23 +51,7 @@ public interface IServiceConnector : IDiscoverable
/// <returns>
/// A task that represents the asynchronous operation.
/// </returns>
Task ProcessAsync(ArtifactDeployState state, IDeployContext context, int pass, CancellationToken cancellationToken = default)
{
// TODO: Remove default implementation in v15
#pragma warning disable CS0618 // Type or member is obsolete
Process(state, context, pass);
#pragma warning restore CS0618 // Type or member is obsolete
return Task.CompletedTask;
}
/// <summary>
/// Explodes/expands an UDI range into UDIs.
/// </summary>
/// <param name="range">The UDI range.</param>
/// <param name="udis">The list of UDIs where to add the exploded/expanded UDIs.</param>
[Obsolete("Use ExpandRangeAsync() instead. This method will be removed in a future version.")]
void Explode(UdiRange range, List<Udi> udis);
Task ProcessAsync(ArtifactDeployState state, IDeployContext context, int pass, CancellationToken cancellationToken = default);
/// <summary>
/// Expands an UDI range into UDIs.
@@ -128,30 +61,7 @@ public interface IServiceConnector : IDiscoverable
/// <returns>
/// Returns an <see cref="IAsyncEnumerable{Udi}" /> which when enumerated will asynchronously expand the UDI range into UDIs.
/// </returns>
async IAsyncEnumerable<Udi> ExpandRangeAsync(UdiRange range, [EnumeratorCancellation] CancellationToken cancellationToken = default)
{
// TODO: Remove default implementation in v15
var udis = new List<Udi>();
#pragma warning disable CS0618 // Type or member is obsolete
Explode(range, udis);
#pragma warning restore CS0618 // Type or member is obsolete
foreach (Udi udi in udis)
{
yield return await ValueTask.FromResult(udi);
}
}
/// <summary>
/// Gets a named range for a specified UDI and selector.
/// </summary>
/// <param name="udi">The UDI.</param>
/// <param name="selector">The selector.</param>
/// <returns>
/// The named range for the specified UDI and selector.
/// </returns>
[Obsolete("Use GetRangeAsync() instead. This method will be removed in a future version.")]
NamedUdiRange GetRange(Udi udi, string selector);
IAsyncEnumerable<Udi> ExpandRangeAsync(UdiRange range, CancellationToken cancellationToken = default);
/// <summary>
/// Gets a named range for a specified UDI and selector.
@@ -162,31 +72,7 @@ public interface IServiceConnector : IDiscoverable
/// <returns>
/// A task that represents the asynchronous operation. The task result contains the named range for the specified UDI and selector.
/// </returns>
Task<NamedUdiRange> GetRangeAsync(Udi udi, string selector, CancellationToken cancellationToken = default)
#pragma warning disable CS0618 // Type or member is obsolete
=> Task.FromResult(GetRange(udi, selector)); // TODO: Remove default implementation in v15
#pragma warning restore CS0618 // Type or member is obsolete
/// <summary>
/// Gets a named range for specified entity type, identifier and selector.
/// </summary>
/// <param name="entityType">The entity type.</param>
/// <param name="sid">The identifier.</param>
/// <param name="selector">The selector.</param>
/// <returns>
/// The named range for the specified entity type, identifier and selector.
/// </returns>
/// <remarks>
/// <para>This is temporary. At least we thought it would be, in sept. 2016. What day is it now?</para>
/// <para>
/// At the moment our UI has a hard time returning proper UDIs, mainly because Core's tree do
/// not manage GUIDs but only integers... so we have to provide a way to support it. The string id here
/// can be either a real string (for string UDIs) or an "integer as a string", using the value "-1" to
/// indicate the "root" i.e. an open UDI.
/// </para>
/// </remarks>
[Obsolete("Use GetRangeAsync() instead. This method will be removed in a future version.")]
NamedUdiRange GetRange(string entityType, string sid, string selector);
Task<NamedUdiRange> GetRangeAsync(Udi udi, string selector, CancellationToken cancellationToken = default);
/// <summary>
/// Gets a named range for specified entity type, identifier and selector.
@@ -207,10 +93,7 @@ public interface IServiceConnector : IDiscoverable
/// indicate the "root" i.e. an open UDI.
/// </para>
/// </remarks>
Task<NamedUdiRange> GetRangeAsync(string entityType, string sid, string selector, CancellationToken cancellationToken = default)
#pragma warning disable CS0618 // Type or member is obsolete
=> Task.FromResult(GetRange(entityType, sid, selector)); // TODO: Remove default implementation in v15
#pragma warning restore CS0618 // Type or member is obsolete
Task<NamedUdiRange> GetRangeAsync(string entityType, string sid, string selector, CancellationToken cancellationToken = default);
/// <summary>
/// Compares two artifacts.

View File

@@ -20,19 +20,6 @@ public interface IValueConnector
/// </value>
IEnumerable<string> PropertyEditorAliases { get; }
/// <summary>
/// Gets the deploy property value corresponding to a content property value, and gather dependencies.
/// </summary>
/// <param name="value">The content property value.</param>
/// <param name="propertyType">The value property type</param>
/// <param name="dependencies">The content dependencies.</param>
/// <param name="contextCache">The context cache.</param>
/// <returns>
/// The deploy property value.
/// </returns>
[Obsolete("Use ToArtifactAsync() instead. This method will be removed in a future version.")]
string? ToArtifact(object? value, IPropertyType propertyType, ICollection<ArtifactDependency> dependencies, IContextCache contextCache);
/// <summary>
/// Gets the deploy property value corresponding to a content property value, and gather dependencies.
/// </summary>
@@ -44,23 +31,11 @@ public interface IValueConnector
/// <returns>
/// A task that represents the asynchronous operation. The task result contains the deploy property value.
/// </returns>
Task<string?> ToArtifactAsync(object? value, IPropertyType propertyType, ICollection<ArtifactDependency> dependencies, IContextCache contextCache, CancellationToken cancellationToken = default)
#pragma warning disable CS0618 // Type or member is obsolete
=> Task.FromResult(ToArtifact(value, propertyType, dependencies, contextCache)); // TODO: Remove default implementation in v15
#pragma warning restore CS0618 // Type or member is obsolete
/// <summary>
/// Gets the content property value corresponding to a deploy property value.
/// </summary>
/// <param name="value">The deploy property value.</param>
/// <param name="propertyType">The value property type</param>
/// <param name="currentValue">The current content property value.</param>
/// <param name="contextCache">The context cache.</param>
/// <returns>
/// The content property value.
/// </returns>
[Obsolete("Use FromArtifactAsync() instead. This method will be removed in a future version.")]
object? FromArtifact(string? value, IPropertyType propertyType, object? currentValue, IContextCache contextCache);
Task<string?> ToArtifactAsync(object? value,
IPropertyType propertyType,
ICollection<ArtifactDependency> dependencies,
IContextCache contextCache,
CancellationToken cancellationToken = default);
/// <summary>
/// Gets the content property value corresponding to a deploy property value.
@@ -73,8 +48,10 @@ public interface IValueConnector
/// <returns>
/// A task that represents the asynchronous operation. The task result contains the content property value.
/// </returns>
Task<object?> FromArtifactAsync(string? value, IPropertyType propertyType, object? currentValue, IContextCache contextCache, CancellationToken cancellationToken = default)
#pragma warning disable CS0618 // Type or member is obsolete
=> Task.FromResult(FromArtifact(value, propertyType, currentValue, contextCache)); // TODO: Remove default implementation in v15
#pragma warning restore CS0618 // Type or member is obsolete
Task<object?> FromArtifactAsync(
string? value,
IPropertyType propertyType,
object? currentValue,
IContextCache contextCache,
CancellationToken cancellationToken = default);
}

View File

@@ -25,7 +25,6 @@ public sealed class UserNotificationsHandler :
INotificationHandler<ContentMovedToRecycleBinNotification>,
INotificationHandler<ContentCopiedNotification>,
INotificationHandler<ContentRolledBackNotification>,
INotificationHandler<ContentSentToPublishNotification>,
INotificationHandler<ContentUnpublishedNotification>,
INotificationHandler<AssignedUserGroupPermissionsNotification>,
INotificationHandler<PublicAccessEntrySavedNotification>
@@ -107,10 +106,6 @@ public sealed class UserNotificationsHandler :
_notifier.Notify(_actions.GetAction<ActionUpdate>(), updatedEntities.ToArray());
}
[Obsolete("Scheduled for removal in v13")]
public void Handle(ContentSentToPublishNotification notification) =>
_notifier.Notify(_actions.GetAction<ActionToPublish>(), notification.Entity);
public void Handle(ContentSortedNotification notification)
{
var parentId = notification.SortedEntities.Select(x => x.ParentId).Distinct().ToList();

View File

@@ -23,6 +23,11 @@ public class DailyMotion : OEmbedProviderBase
{ "format", "xml" },
};
public override async Task<string?> GetMarkupAsync(string url, int? maxWidth, int? maxHeight, CancellationToken cancellationToken)
=> await GetXmlBasedMarkupAsync(url, maxWidth, maxHeight, cancellationToken);
[Obsolete("Use GetMarkupAsync instead. Planned for removal in v16")]
public override async Task<string?> GeOEmbedDataAsync(string url, int? maxWidth, int? maxHeight, CancellationToken cancellationToken)
{
var requestUrl = base.GetEmbedProviderUrl(url, maxWidth, maxHeight);
@@ -33,7 +38,5 @@ public class DailyMotion : OEmbedProviderBase
[Obsolete("Use GetMarkupAsync instead. This will be removed in Umbraco 15.")]
public override string? GetMarkup(string url, int maxWidth = 0, int maxHeight = 0)
{
return GeOEmbedDataAsync(url, maxWidth, maxHeight, CancellationToken.None).GetAwaiter().GetResult();
}
=> GetMarkupAsync(url, maxWidth, maxHeight, CancellationToken.None).GetAwaiter().GetResult();
}

View File

@@ -22,11 +22,9 @@ public class Flickr : OEmbedProviderBase
[Obsolete("Use GetMarkupAsync instead. This will be removed in Umbraco 15.")]
public override string? GetMarkup(string url, int maxWidth = 0, int maxHeight = 0)
{
return GeOEmbedDataAsync(url, maxWidth, maxHeight, CancellationToken.None).GetAwaiter().GetResult();
}
=> GetMarkupAsync(url, maxWidth, maxHeight, CancellationToken.None).GetAwaiter().GetResult();
public override async Task<string?> GeOEmbedDataAsync(string url, int? maxWidth, int? maxHeight, CancellationToken cancellationToken)
public override async Task<string?> GetMarkupAsync(string url, int? maxWidth, int? maxHeight, CancellationToken cancellationToken)
{
var requestUrl = base.GetEmbedProviderUrl(url, maxWidth, maxHeight);
XmlDocument xmlDocument = await base.GetXmlResponseAsync(requestUrl, cancellationToken);
@@ -38,4 +36,8 @@ public class Flickr : OEmbedProviderBase
return string.Format("<img src=\"{0}\" width=\"{1}\" height=\"{2}\" alt=\"{3}\" />", imageUrl, imageWidth, imageHeight, WebUtility.HtmlEncode(imageTitle));
}
[Obsolete("Use GetMarkupAsync instead. Planned for removal in v16")]
public override async Task<string?> GeOEmbedDataAsync(string url, int? maxWidth, int? maxHeight, CancellationToken cancellationToken)
=> await GetMarkupAsync(url, maxWidth, maxHeight, cancellationToken);
}

View File

@@ -22,10 +22,12 @@ public class GettyImages : OEmbedProviderBase
[Obsolete("Use GetMarkupAsync instead. This will be removed in Umbraco 15.")]
public override string? GetMarkup(string url, int maxWidth = 0, int maxHeight = 0)
{
return GeOEmbedDataAsync(url, maxWidth, maxHeight, CancellationToken.None).GetAwaiter().GetResult();
}
=> GetMarkupAsync(url, maxWidth, maxHeight, CancellationToken.None).GetAwaiter().GetResult();
public override async Task<string?> GetMarkupAsync(string url, int? maxWidth, int? maxHeight, CancellationToken cancellationToken)
=> await GetJsonBasedMarkupAsync(url, maxWidth, maxHeight, cancellationToken);
[Obsolete("Use GetMarkupAsync instead. Planned for removal in v16")]
public override async Task<string?> GeOEmbedDataAsync(string url, int? maxWidth, int? maxHeight, CancellationToken cancellationToken)
{
var requestUrl = base.GetEmbedProviderUrl(url, maxWidth, maxHeight);

View File

@@ -20,10 +20,12 @@ public class Giphy : OEmbedProviderBase
[Obsolete("Use GetMarkupAsync instead. This will be removed in Umbraco 15.")]
public override string? GetMarkup(string url, int maxWidth = 0, int maxHeight = 0)
{
return GeOEmbedDataAsync(url, maxWidth, maxHeight, CancellationToken.None).GetAwaiter().GetResult();
}
=> GetMarkupAsync(url, maxWidth, maxHeight, CancellationToken.None).GetAwaiter().GetResult();
public override async Task<string?> GetMarkupAsync(string url, int? maxWidth, int? maxHeight, CancellationToken cancellationToken)
=> await GetJsonBasedMarkupAsync(url, maxWidth, maxHeight, cancellationToken);
[Obsolete("Use GetMarkupAsync instead. Planned for removal in v16")]
public override async Task<string?> GeOEmbedDataAsync(string url, int? maxWidth, int? maxHeight, CancellationToken cancellationToken)
{
var requestUrl = base.GetEmbedProviderUrl(url, maxWidth, maxHeight);

View File

@@ -20,10 +20,12 @@ public class Hulu : OEmbedProviderBase
[Obsolete("Use GetMarkupAsync instead. This will be removed in Umbraco 15.")]
public override string? GetMarkup(string url, int maxWidth = 0, int maxHeight = 0)
{
return GeOEmbedDataAsync(url, maxWidth, maxHeight, CancellationToken.None).GetAwaiter().GetResult();
}
=> GetMarkupAsync(url, maxWidth, maxHeight, CancellationToken.None).GetAwaiter().GetResult();
public override async Task<string?> GetMarkupAsync(string url, int? maxWidth, int? maxHeight, CancellationToken cancellationToken)
=> await GetJsonBasedMarkupAsync(url, maxWidth, maxHeight, cancellationToken);
[Obsolete("Use GetMarkupAsync instead. Planned for removal in v16")]
public override async Task<string?> GeOEmbedDataAsync(string url, int? maxWidth, int? maxHeight, CancellationToken cancellationToken)
{
var requestUrl = base.GetEmbedProviderUrl(url, maxWidth, maxHeight);

View File

@@ -28,10 +28,12 @@ public class Issuu : OEmbedProviderBase
[Obsolete("Use GetMarkupAsync instead. This will be removed in Umbraco 15.")]
public override string? GetMarkup(string url, int maxWidth = 0, int maxHeight = 0)
{
return GeOEmbedDataAsync(url, maxWidth, maxHeight, CancellationToken.None).GetAwaiter().GetResult();
}
=> GetMarkupAsync(url, maxWidth, maxHeight, CancellationToken.None).GetAwaiter().GetResult();
public override async Task<string?> GetMarkupAsync(string url, int? maxWidth, int? maxHeight, CancellationToken cancellationToken)
=> await GetXmlBasedMarkupAsync(url, maxWidth, maxHeight, cancellationToken);
[Obsolete("Use GetMarkupAsync instead. Planned for removal in v16")]
public override async Task<string?> GeOEmbedDataAsync(string url, int? maxWidth, int? maxHeight, CancellationToken cancellationToken)
{
var requestUrl = base.GetEmbedProviderUrl(url, maxWidth, maxHeight);

View File

@@ -20,10 +20,12 @@ public class Kickstarter : OEmbedProviderBase
[Obsolete("Use GetMarkupAsync instead. This will be removed in Umbraco 15.")]
public override string? GetMarkup(string url, int maxWidth = 0, int maxHeight = 0)
{
return GeOEmbedDataAsync(url, maxWidth, maxHeight, CancellationToken.None).GetAwaiter().GetResult();
}
=> GetMarkupAsync(url, maxWidth, maxHeight, CancellationToken.None).GetAwaiter().GetResult();
public override async Task<string?> GetMarkupAsync(string url, int? maxWidth, int? maxHeight, CancellationToken cancellationToken)
=> await GetJsonBasedMarkupAsync(url, maxWidth, maxHeight, cancellationToken);
[Obsolete("Use GetMarkupAsync instead. Planned for removal in v16")]
public override async Task<string?> GeOEmbedDataAsync(string url, int? maxWidth, int? maxHeight, CancellationToken cancellationToken)
{
var requestUrl = base.GetEmbedProviderUrl(url, maxWidth, maxHeight);

View File

@@ -21,14 +21,12 @@ public class LottieFiles : OEmbedProviderBase
[Obsolete("Use GetMarkupAsync instead. This will be removed in Umbraco 15.")]
public override string? GetMarkup(string url, int maxWidth = 0, int maxHeight = 0)
{
return GeOEmbedDataAsync(url, maxWidth, maxHeight, CancellationToken.None).GetAwaiter().GetResult();
}
=> GetMarkupAsync(url, maxWidth, maxHeight, CancellationToken.None).GetAwaiter().GetResult();
public override async Task<string?> GeOEmbedDataAsync(string url, int? maxWidth, int? maxHeight, CancellationToken cancellationToken)
public override async Task<string?> GetMarkupAsync(string url, int? maxWidth, int? maxHeight, CancellationToken cancellationToken)
{
var requestUrl = this.GetEmbedProviderUrl(url, maxWidth, maxHeight);
OEmbedResponse? oembed = await this.GetJsonResponseAsync<OEmbedResponse>(requestUrl, cancellationToken);
var requestUrl = GetEmbedProviderUrl(url, maxWidth, maxHeight);
OEmbedResponse? oembed = await GetJsonResponseAsync<OEmbedResponse>(requestUrl, cancellationToken);
var html = oembed?.GetHtml();
// LottieFiles doesn't seem to support maxwidth and maxheight via oembed
@@ -53,4 +51,12 @@ public class LottieFiles : OEmbedProviderBase
return html;
}
[Obsolete("Use GetMarkupAsync instead. Planned for removal in v16")]
public override async Task<string?> GeOEmbedDataAsync(
string url,
int? maxWidth,
int? maxHeight,
CancellationToken cancellationToken)
=> await GetMarkupAsync(url, maxWidth, maxHeight, cancellationToken);
}

View File

@@ -21,9 +21,14 @@ public abstract class OEmbedProviderBase : IEmbedProvider
[Obsolete("Use GetMarkupAsync instead. This will be removed in Umbraco 15.")]
public abstract string? GetMarkup(string url, int maxWidth = 0, int maxHeight = 0);
public virtual Task<string?> GeOEmbedDataAsync(string url, int? maxWidth, int? maxHeight, CancellationToken cancellationToken) => Task.FromResult(GetMarkup(url, maxWidth ?? 0, maxHeight ?? 0));
public abstract Task<string?> GetMarkupAsync(string url, int? maxWidth, int? maxHeight, CancellationToken cancellationToken);
[Obsolete("Cleanup, only proxied to by GetMarkupAsync implementations. Planned for removal in v16")]
public virtual Task<string?> GeOEmbedDataAsync(string url, int? maxWidth, int? maxHeight, CancellationToken cancellationToken)
=> Task.FromResult(GetMarkup(url, maxWidth ?? 0, maxHeight ?? 0));
public virtual string GetEmbedProviderUrl(string url, int? maxWidth, int? maxHeight) => GetEmbedProviderUrl(url, maxWidth ?? 0, maxHeight ?? 0);
public virtual string GetEmbedProviderUrl(string url, int maxWidth, int maxHeight)
{
if (Uri.IsWellFormedUriString(url, UriKind.RelativeOrAbsolute) == false)
@@ -54,22 +59,6 @@ public abstract class OEmbedProviderBase : IEmbedProvider
return fullUrl.ToString();
}
[Obsolete("Use DownloadResponseAsync instead. This will be removed in Umbraco 15.")]
public virtual string DownloadResponse(string url)
{
if (_httpClient == null)
{
_httpClient = new HttpClient();
_httpClient.DefaultRequestHeaders.UserAgent.TryParseAdd(Constants.HttpClients.Headers.UserAgentProductName);
}
using (var request = new HttpRequestMessage(HttpMethod.Get, url))
{
using HttpResponseMessage response = _httpClient.SendAsync(request).GetAwaiter().GetResult();
return response.Content.ReadAsStringAsync().Result;
}
}
public virtual async Task<string> DownloadResponseAsync(string url, CancellationToken cancellationToken)
{
if (_httpClient == null)
@@ -85,14 +74,6 @@ public abstract class OEmbedProviderBase : IEmbedProvider
}
}
[Obsolete("Use GetJsonResponseAsync instead. This will be removed in Umbraco 15.")]
public virtual T? GetJsonResponse<T>(string url)
where T : class
{
var response = DownloadResponse(url);
return _jsonSerializer.Deserialize<T>(response);
}
public virtual async Task<T?> GetJsonResponseAsync<T>(string url, CancellationToken cancellationToken)
where T : class
{
@@ -109,19 +90,30 @@ public abstract class OEmbedProviderBase : IEmbedProvider
return doc;
}
[Obsolete("Use GetXmlResponseAsync instead. This will be removed in Umbraco 15.")]
public virtual XmlDocument GetXmlResponse(string url)
{
var response = DownloadResponse(url);
var doc = new XmlDocument();
doc.LoadXml(response);
return doc;
}
public virtual string GetXmlProperty(XmlDocument doc, string property)
{
XmlNode? selectSingleNode = doc.SelectSingleNode(property);
return selectSingleNode != null ? selectSingleNode.InnerText : string.Empty;
}
public virtual async Task<string?> GetJsonBasedMarkupAsync(string url, int? maxWidth, int? maxHeight, CancellationToken cancellationToken)
{
var requestUrl = GetEmbedProviderUrl(url, maxWidth, maxHeight);
OEmbedResponse? oembed = await GetJsonResponseAsync<OEmbedResponse>(requestUrl, cancellationToken);
return oembed?.GetHtml();
}
public virtual async Task<string?> GetXmlBasedMarkupAsync(
string url,
int? maxWidth,
int? maxHeight,
CancellationToken cancellationToken,
string property = "/oembed/html")
{
var requestUrl = GetEmbedProviderUrl(url, maxWidth, maxHeight);
XmlDocument xmlDocument = await GetXmlResponseAsync(requestUrl, cancellationToken);
return GetXmlProperty(xmlDocument, property);
}
}

View File

@@ -21,10 +21,12 @@ public class Slideshare : OEmbedProviderBase
[Obsolete("Use GetMarkupAsync instead. This will be removed in Umbraco 15.")]
public override string? GetMarkup(string url, int maxWidth = 0, int maxHeight = 0)
{
return GeOEmbedDataAsync(url, maxWidth, maxHeight, CancellationToken.None).GetAwaiter().GetResult();
}
=> GetMarkupAsync(url, maxWidth, maxHeight, CancellationToken.None).GetAwaiter().GetResult();
public override async Task<string?> GetMarkupAsync(string url, int? maxWidth, int? maxHeight, CancellationToken cancellationToken)
=> await GetXmlBasedMarkupAsync(url, maxWidth, maxHeight, cancellationToken);
[Obsolete("Use GetMarkupAsync instead. Planned for removal in v16")]
public override async Task<string?> GeOEmbedDataAsync(string url, int? maxWidth, int? maxHeight, CancellationToken cancellationToken)
{
var requestUrl = base.GetEmbedProviderUrl(url, maxWidth, maxHeight);

View File

@@ -22,10 +22,12 @@ public class Soundcloud : OEmbedProviderBase
[Obsolete("Use GetMarkupAsync instead. This will be removed in Umbraco 15.")]
public override string? GetMarkup(string url, int maxWidth = 0, int maxHeight = 0)
{
return GeOEmbedDataAsync(url, maxWidth, maxHeight, CancellationToken.None).GetAwaiter().GetResult();
}
=> GetMarkupAsync(url, maxWidth, maxHeight, CancellationToken.None).GetAwaiter().GetResult();
public override async Task<string?> GetMarkupAsync(string url, int? maxWidth, int? maxHeight, CancellationToken cancellationToken)
=> await GetXmlBasedMarkupAsync(url, maxWidth, maxHeight, cancellationToken);
[Obsolete("Use GetMarkupAsync instead. Planned for removal in v16")]
public override async Task<string?> GeOEmbedDataAsync(string url, int? maxWidth, int? maxHeight, CancellationToken cancellationToken)
{
var requestUrl = base.GetEmbedProviderUrl(url, maxWidth, maxHeight);

View File

@@ -21,10 +21,12 @@ public class Ted : OEmbedProviderBase
[Obsolete("Use GetMarkupAsync instead. This will be removed in Umbraco 15.")]
public override string? GetMarkup(string url, int maxWidth = 0, int maxHeight = 0)
{
return GeOEmbedDataAsync(url, maxWidth, maxHeight, CancellationToken.None).GetAwaiter().GetResult();
}
=> GetMarkupAsync(url, maxWidth, maxHeight, CancellationToken.None).GetAwaiter().GetResult();
public override async Task<string?> GetMarkupAsync(string url, int? maxWidth, int? maxHeight, CancellationToken cancellationToken)
=> await GetXmlBasedMarkupAsync(url, maxWidth, maxHeight, cancellationToken);
[Obsolete("Use GetMarkupAsync instead. Planned for removal in v16")]
public override async Task<string?> GeOEmbedDataAsync(string url, int? maxWidth, int? maxHeight, CancellationToken cancellationToken)
{
var requestUrl = base.GetEmbedProviderUrl(url, maxWidth, maxHeight);

View File

@@ -21,10 +21,12 @@ public class Twitter : OEmbedProviderBase
[Obsolete("Use GetMarkupAsync instead. This will be removed in Umbraco 15.")]
public override string? GetMarkup(string url, int maxWidth = 0, int maxHeight = 0)
{
return GeOEmbedDataAsync(url, maxWidth, maxHeight, CancellationToken.None).GetAwaiter().GetResult();
}
=> GetMarkupAsync(url, maxWidth, maxHeight, CancellationToken.None).GetAwaiter().GetResult();
public override async Task<string?> GetMarkupAsync(string url, int? maxWidth, int? maxHeight, CancellationToken cancellationToken)
=> await GetJsonBasedMarkupAsync(url, maxWidth, maxHeight, cancellationToken);
[Obsolete("Use GetMarkupAsync instead. Planned for removal in v16")]
public override async Task<string?> GeOEmbedDataAsync(string url, int? maxWidth, int? maxHeight, CancellationToken cancellationToken)
{
var requestUrl = base.GetEmbedProviderUrl(url, maxWidth, maxHeight);

View File

@@ -21,10 +21,12 @@ public class Vimeo : OEmbedProviderBase
[Obsolete("Use GetMarkupAsync instead. This will be removed in Umbraco 15.")]
public override string? GetMarkup(string url, int maxWidth = 0, int maxHeight = 0)
{
return GeOEmbedDataAsync(url, maxWidth, maxHeight, CancellationToken.None).GetAwaiter().GetResult();
}
=> GetMarkupAsync(url, maxWidth, maxHeight, CancellationToken.None).GetAwaiter().GetResult();
public override async Task<string?> GetMarkupAsync(string url, int? maxWidth, int? maxHeight, CancellationToken cancellationToken)
=> await GetXmlBasedMarkupAsync(url, maxWidth, maxHeight, cancellationToken);
[Obsolete("Use GetMarkupAsync instead. Planned for removal in v16")]
public override async Task<string?> GeOEmbedDataAsync(string url, int? maxWidth, int? maxHeight, CancellationToken cancellationToken)
{
var requestUrl = base.GetEmbedProviderUrl(url, maxWidth, maxHeight);

View File

@@ -18,11 +18,10 @@ public class X : OEmbedProviderBase
public override Dictionary<string, string> RequestParams => new();
[Obsolete("Use GetMarkupAsync instead. This will be removed in v16.")]
public override string? GetMarkup(string url, int maxWidth = 0, int maxHeight = 0)
{
var requestUrl = base.GetEmbedProviderUrl(url, maxWidth, maxHeight);
OEmbedResponse? oembed = base.GetJsonResponse<OEmbedResponse>(requestUrl);
=> GetMarkupAsync(url, maxWidth, maxHeight, CancellationToken.None).GetAwaiter().GetResult();
return oembed?.GetHtml();
}
public override async Task<string?> GetMarkupAsync(string url, int? maxWidth, int? maxHeight, CancellationToken cancellationToken)
=> await GetJsonBasedMarkupAsync(url, maxWidth, maxHeight, cancellationToken);
}

View File

@@ -24,10 +24,12 @@ public class YouTube : OEmbedProviderBase
[Obsolete("Use GetMarkupAsync instead. This will be removed in Umbraco 15.")]
public override string? GetMarkup(string url, int maxWidth = 0, int maxHeight = 0)
{
return GeOEmbedDataAsync(url, maxWidth, maxHeight, CancellationToken.None).GetAwaiter().GetResult();
}
=> GetMarkupAsync(url, maxWidth, maxHeight, CancellationToken.None).GetAwaiter().GetResult();
public override async Task<string?> GetMarkupAsync(string url, int? maxWidth, int? maxHeight, CancellationToken cancellationToken)
=> await GetJsonBasedMarkupAsync(url, maxWidth, maxHeight, cancellationToken);
[Obsolete("Use GetMarkupAsync instead. Planned for removal in v16")]
public override async Task<string?> GeOEmbedDataAsync(string url, int? maxWidth, int? maxHeight, CancellationToken cancellationToken)
{
var requestUrl = base.GetEmbedProviderUrl(url, maxWidth, maxHeight);

View File

@@ -20,5 +20,6 @@ public interface IEmbedProvider
[Obsolete("Use GetMarkupAsync instead. This will be removed in Umbraco 15.")]
string? GetMarkup(string url, int maxWidth = 0, int maxHeight = 0);
Task<string?> GetMarkupAsync(string url, int? maxWidth, int? maxHeight, CancellationToken cancellationToken) => Task.FromResult(GetMarkup(url, maxWidth ?? 0, maxHeight ?? 0));
}

View File

@@ -30,13 +30,13 @@ public static class UserGroupExtensions
}
public static bool IsSystemUserGroup(this IUserGroup group) =>
IsSystemUserGroup(group.Alias);
IsSystemUserGroup(group.Key);
public static bool IsSystemUserGroup(this IReadOnlyUserGroup group) =>
IsSystemUserGroup(group.Alias);
IsSystemUserGroup(group.Key);
private static bool IsSystemUserGroup(this string? groupAlias) =>
groupAlias == Constants.Security.AdminGroupAlias
|| groupAlias == Constants.Security.SensitiveDataGroupAlias
|| groupAlias == Constants.Security.TranslatorGroupAlias;
private static bool IsSystemUserGroup(this Guid? groupKey) =>
groupKey == Constants.Security.AdminGroupKey
|| groupKey == Constants.Security.SensitiveDataGroupKey
|| groupKey == Constants.Security.TranslatorGroupKey;
}

View File

@@ -53,7 +53,7 @@ public class ContentFinderByIdPath : ContentFinderByIdentifierPathBase, IContent
return Task.FromResult(false);
}
if (umbracoContext.InPreviewMode == false && (_webRoutingSettings.DisableFindContentByIdPath || _webRoutingSettings.DisableFindContentByIdentifierPath))
if (umbracoContext.InPreviewMode == false && _webRoutingSettings.DisableFindContentByIdentifierPath)
{
return Task.FromResult(false);
}

View File

@@ -292,15 +292,6 @@ namespace Umbraco.Cms.Core.Services.Implement
return dataType;
}
/// <summary>
/// Gets a <see cref="IDataType"/> by its unique guid Id
/// </summary>
/// <param name="id">Unique guid Id of the DataType</param>
/// <returns><see cref="IDataType"/></returns>
[Obsolete("Please use GetAsync. Will be removed in V15.")]
public IDataType? GetDataType(Guid id)
=> GetAsync(id).GetAwaiter().GetResult();
/// <inheritdoc />
public Task<IDataType?> GetAsync(Guid id)
{

View File

@@ -13,7 +13,7 @@ public static class DateTypeServiceExtensions
return false; // built in ones can never be ignoring start nodes
}
IDataType? dataType = dataTypeService.GetDataType(key);
IDataType? dataType = dataTypeService.GetAsync(key).GetAwaiter().GetResult();
if (dataType != null && dataType.ConfigurationObject is IIgnoreUserStartNodesConfig ignoreStartNodesConfig)
{

View File

@@ -76,16 +76,6 @@ public interface IDataTypeService : IService
[Obsolete("Please use GetAsync. Will be removed in V15.")]
IDataType? GetDataType(int id);
/// <summary>
/// Gets a <see cref="IDataType" /> by its unique guid Id
/// </summary>
/// <param name="id">Unique guid Id of the DataType</param>
/// <returns>
/// <see cref="IDataType" />
/// </returns>
[Obsolete("Please use GetAsync. Will be removed in V15.")]
IDataType? GetDataType(Guid id);
/// <summary>
/// Gets an <see cref="IDataType" /> by its Name
/// </summary>

View File

@@ -461,7 +461,7 @@ public class NotificationService : INotificationService
var protocol = _globalSettings.UseHttps ? "https" : "http";
var subjectVars = new NotificationEmailSubjectParams(
string.Concat(siteUri.Authority, _ioHelper.ResolveUrl(_globalSettings.UmbracoPath)),
string.Concat(siteUri.Authority, _ioHelper.ResolveUrl(Constants.System.DefaultUmbracoPath)),
actionName,
content.Name);
@@ -479,7 +479,7 @@ public class NotificationService : INotificationService
string.Concat(content.Id, ".aspx"),
protocol),
performingUser.Name,
string.Concat(siteUri.Authority, _ioHelper.ResolveUrl(_globalSettings.UmbracoPath)),
string.Concat(siteUri.Authority, _ioHelper.ResolveUrl(Constants.System.DefaultUmbracoPath)),
summary.ToString());
var fromMail = _contentSettings.Notifications.Email ?? _globalSettings.Smtp?.From;

View File

@@ -478,6 +478,7 @@ internal partial class UserService : RepositoryService, IUserService
/// This is just the default user group that the membership provider will use
/// </summary>
/// <returns></returns>
[Obsolete("No (backend) code path is using this anymore, so it can not be considered the default. Planned for removal in V16.")]
public string GetDefaultMemberType() => Constants.Security.WriterGroupAlias;
/// <summary>

View File

@@ -321,7 +321,6 @@ public static partial class UmbracoBuilderExtensions
.AddNotificationHandler<ContentMovedToRecycleBinNotification, UserNotificationsHandler>()
.AddNotificationHandler<ContentCopiedNotification, UserNotificationsHandler>()
.AddNotificationHandler<ContentRolledBackNotification, UserNotificationsHandler>()
.AddNotificationHandler<ContentSentToPublishNotification, UserNotificationsHandler>()
.AddNotificationHandler<ContentUnpublishedNotification, UserNotificationsHandler>()
.AddNotificationHandler<AssignedUserGroupPermissionsNotification, UserNotificationsHandler>()
.AddNotificationHandler<PublicAccessEntrySavedNotification, UserNotificationsHandler>();

View File

@@ -196,7 +196,6 @@ internal class DatabaseDataCreator
var userGroupKeyToPermissions = new Dictionary<Guid, IEnumerable<string>>()
{
[Constants.Security.AdminGroupKey] = new[] { ActionNew.ActionLetter, ActionUpdate.ActionLetter, ActionDelete.ActionLetter, ActionMove.ActionLetter, ActionCopy.ActionLetter, ActionSort.ActionLetter, ActionRollback.ActionLetter, ActionProtect.ActionLetter, ActionAssignDomain.ActionLetter, ActionPublish.ActionLetter, ActionRights.ActionLetter, ActionUnpublish.ActionLetter, ActionBrowse.ActionLetter, ActionCreateBlueprintFromContent.ActionLetter, ActionNotify.ActionLetter, ":", "5", "7", "T" },
[Constants.Security.WriterGroupKey] = new[] { ActionNew.ActionLetter, ActionUpdate.ActionLetter, ActionToPublish.ActionLetter, ActionBrowse.ActionLetter, ActionNotify.ActionLetter, ":" },
[Constants.Security.EditorGroupKey] = new[] { ActionNew.ActionLetter, ActionUpdate.ActionLetter, ActionDelete.ActionLetter, ActionMove.ActionLetter, ActionCopy.ActionLetter, ActionSort.ActionLetter, ActionRollback.ActionLetter, ActionProtect.ActionLetter, ActionPublish.ActionLetter, ActionUnpublish.ActionLetter, ActionBrowse.ActionLetter, ActionCreateBlueprintFromContent.ActionLetter, ActionNotify.ActionLetter, ":", "5", "T" },
[Constants.Security.TranslatorGroupKey] = new[] { ActionUpdate.ActionLetter, ActionBrowse.ActionLetter },
};

View File

@@ -1,31 +1,58 @@
using System.Text;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Options;
using Umbraco.Cms.Core.Configuration.Models;
using Umbraco.Cms.Core.Hosting;
using Umbraco.Cms.Core.DependencyInjection;
using Umbraco.Extensions;
using IHostingEnvironment = Umbraco.Cms.Core.Hosting.IHostingEnvironment;
namespace Umbraco.Cms.Infrastructure.ModelsBuilder.Building;
public class ModelsGenerator : IModelsGenerator
{
private readonly IHostingEnvironment _hostingEnvironment;
private readonly OutOfDateModelsStatus _outOfDateModels;
private readonly IHostEnvironment _hostEnvironment;
private readonly UmbracoServices _umbracoService;
private ModelsBuilderSettings _config;
[Obsolete("Use a not obsoleted constructor instead. Scheduled for removal in v16")]
public ModelsGenerator(UmbracoServices umbracoService, IOptionsMonitor<ModelsBuilderSettings> config,
OutOfDateModelsStatus outOfDateModels, IHostingEnvironment hostingEnvironment)
{
_umbracoService = umbracoService;
_config = config.CurrentValue;
_outOfDateModels = outOfDateModels;
_hostingEnvironment = hostingEnvironment;
config.OnChange(x => _config = x);
_hostEnvironment = StaticServiceProvider.Instance.GetRequiredService<IHostEnvironment>();
}
[Obsolete("Use a not obsoleted constructor instead. Scheduled for removal in v16")]
public ModelsGenerator(UmbracoServices umbracoService, IOptionsMonitor<ModelsBuilderSettings> config,
OutOfDateModelsStatus outOfDateModels, IHostingEnvironment hostingEnvironment, IHostEnvironment hostEnvironment)
{
_umbracoService = umbracoService;
_config = config.CurrentValue;
_outOfDateModels = outOfDateModels;
config.OnChange(x => _config = x);
_hostEnvironment = hostEnvironment;
}
public ModelsGenerator(UmbracoServices umbracoService, IOptionsMonitor<ModelsBuilderSettings> config,
OutOfDateModelsStatus outOfDateModels, IHostEnvironment hostEnvironment)
{
_umbracoService = umbracoService;
_config = config.CurrentValue;
_outOfDateModels = outOfDateModels;
_hostEnvironment = hostEnvironment;
config.OnChange(x => _config = x);
}
public void GenerateModels()
{
var modelsDirectory = _config.ModelsDirectoryAbsolute(_hostingEnvironment);
var modelsDirectory = _config.ModelsDirectoryAbsolute(_hostEnvironment);
if (!Directory.Exists(modelsDirectory))
{
Directory.CreateDirectory(modelsDirectory);

View File

@@ -1,23 +1,48 @@
using System.Text;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Options;
using Umbraco.Cms.Core.Configuration.Models;
using Umbraco.Cms.Core.Hosting;
using Umbraco.Cms.Core.DependencyInjection;
using Umbraco.Extensions;
using IHostingEnvironment = Umbraco.Cms.Core.Hosting.IHostingEnvironment;
namespace Umbraco.Cms.Infrastructure.ModelsBuilder;
public sealed class ModelsGenerationError
{
private readonly IHostingEnvironment _hostingEnvironment;
private readonly IHostEnvironment _hostEnvironment;
private ModelsBuilderSettings _config;
/// <summary>
/// Initializes a new instance of the <see cref="ModelsGenerationError" /> class.
/// </summary>
[Obsolete("Use a not obsoleted constructor instead. Scheduled for removal in v16")]
public ModelsGenerationError(IOptionsMonitor<ModelsBuilderSettings> config, IHostingEnvironment hostingEnvironment)
{
_config = config.CurrentValue;
_hostingEnvironment = hostingEnvironment;
config.OnChange(x => _config = x);
_hostEnvironment = StaticServiceProvider.Instance.GetRequiredService<IHostEnvironment>();
}
/// <summary>
/// Initializes a new instance of the <see cref="ModelsGenerationError" /> class.
/// </summary>
[Obsolete("Use a not obsoleted constructor instead. Scheduled for removal in v16")]
public ModelsGenerationError(
IOptionsMonitor<ModelsBuilderSettings> config,
IHostingEnvironment hostingEnvironment,
IHostEnvironment hostEnvironment)
{
_config = config.CurrentValue;
config.OnChange(x => _config = x);
_hostEnvironment = hostEnvironment;
}
public ModelsGenerationError(IOptionsMonitor<ModelsBuilderSettings> config, IHostEnvironment hostEnvironment)
{
_config = config.CurrentValue;
_hostEnvironment = hostEnvironment;
config.OnChange(x => _config = x);
}
@@ -73,7 +98,7 @@ public sealed class ModelsGenerationError
private string? GetErrFile()
{
var modelsDirectory = _config.ModelsDirectoryAbsolute(_hostingEnvironment);
var modelsDirectory = _config.ModelsDirectoryAbsolute(_hostEnvironment);
if (!Directory.Exists(modelsDirectory))
{
return null;

View File

@@ -1,9 +1,12 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Options;
using Umbraco.Cms.Core.Configuration.Models;
using Umbraco.Cms.Core.DependencyInjection;
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.Hosting;
using Umbraco.Cms.Core.Notifications;
using Umbraco.Extensions;
using IHostingEnvironment = Umbraco.Cms.Core.Hosting.IHostingEnvironment;
namespace Umbraco.Cms.Infrastructure.ModelsBuilder;
@@ -13,8 +16,8 @@ namespace Umbraco.Cms.Infrastructure.ModelsBuilder;
public sealed class OutOfDateModelsStatus : INotificationHandler<ContentTypeCacheRefresherNotification>,
INotificationHandler<DataTypeCacheRefresherNotification>
{
private readonly IHostingEnvironment _hostingEnvironment;
private ModelsBuilderSettings _config;
private readonly IHostEnvironment _hostEnvironment;
/// <summary>
/// Initializes a new instance of the <see cref="OutOfDateModelsStatus" /> class.
@@ -22,7 +25,24 @@ public sealed class OutOfDateModelsStatus : INotificationHandler<ContentTypeCach
public OutOfDateModelsStatus(IOptionsMonitor<ModelsBuilderSettings> config, IHostingEnvironment hostingEnvironment)
{
_config = config.CurrentValue;
_hostingEnvironment = hostingEnvironment;
_hostEnvironment = StaticServiceProvider.Instance.GetRequiredService<IHostEnvironment>();
config.OnChange(x => _config = x);
}
public OutOfDateModelsStatus(
IOptionsMonitor<ModelsBuilderSettings> config,
IHostingEnvironment hostingEnvironment,
IHostEnvironment hostEnvironment)
{
_config = config.CurrentValue;
_hostEnvironment = hostEnvironment;
config.OnChange(x => _config = x);
}
public OutOfDateModelsStatus(IOptionsMonitor<ModelsBuilderSettings> config, IHostEnvironment hostEnvironment)
{
_config = config.CurrentValue;
_hostEnvironment = hostEnvironment;
config.OnChange(x => _config = x);
}
@@ -70,7 +90,7 @@ public sealed class OutOfDateModelsStatus : INotificationHandler<ContentTypeCach
private string GetFlagPath()
{
var modelsDirectory = _config.ModelsDirectoryAbsolute(_hostingEnvironment);
var modelsDirectory = _config.ModelsDirectoryAbsolute(_hostEnvironment);
if (!Directory.Exists(modelsDirectory))
{
Directory.CreateDirectory(modelsDirectory);

View File

@@ -1093,7 +1093,7 @@ namespace Umbraco.Cms.Infrastructure.Packaging
var dataTypeDefinitionId =
new Guid(property.Element("Definition")!.Value); //Unique Id for a DataTypeDefinition
IDataType? dataTypeDefinition = _dataTypeService.GetDataType(dataTypeDefinitionId);
IDataType? dataTypeDefinition = _dataTypeService.GetAsync(dataTypeDefinitionId).GetAwaiter().GetResult();
//If no DataTypeDefinition with the guid from the xml wasn't found OR the ControlId on the DataTypeDefinition didn't match the DataType Id
//We look up a DataTypeDefinition that matches
@@ -1285,7 +1285,7 @@ namespace Umbraco.Cms.Infrastructure.Packaging
parentId = importedFolders[dataTypeDefinitionName];
}
IDataType? definition = _dataTypeService.GetDataType(dataTypeDefinitionId);
IDataType? definition = _dataTypeService.GetAsync(dataTypeDefinitionId).GetAwaiter().GetResult();
//If the datatype definition doesn't already exist we create a new according to the one in the package xml
if (definition == null)
{

View File

@@ -34,7 +34,7 @@ public class AspNetCoreBackOfficeInfo : IBackOfficeInfo
_getAbsoluteUrl = WebPath.Combine(
_hostingEnvironment.ApplicationMainUrl.ToString(),
_globalSettings.CurrentValue.UmbracoPath.TrimStart(CharArrays.TildeForwardSlash));
Core.Constants.System.DefaultUmbracoPath.TrimStart(CharArrays.TildeForwardSlash));
}
return _getAbsoluteUrl;

View File

@@ -5,11 +5,15 @@ using System.Runtime.Loader;
using System.Text;
using System.Text.RegularExpressions;
using Microsoft.AspNetCore.Mvc.Razor;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Configuration;
using Umbraco.Cms.Core.Configuration.Models;
using Umbraco.Cms.Core.DependencyInjection;
using Umbraco.Cms.Core.Extensions;
using Umbraco.Cms.Core.Hosting;
using Umbraco.Cms.Core.Logging;
using Umbraco.Cms.Core.Models.PublishedContent;
@@ -17,6 +21,7 @@ using Umbraco.Cms.Infrastructure.ModelsBuilder;
using Umbraco.Cms.Infrastructure.ModelsBuilder.Building;
using Umbraco.Extensions;
using File = System.IO.File;
using IHostingEnvironment = Umbraco.Cms.Core.Hosting.IHostingEnvironment;
namespace Umbraco.Cms.Web.Common.ModelsBuilder.InMemoryAuto
{
@@ -31,7 +36,7 @@ namespace Umbraco.Cms.Web.Common.ModelsBuilder.InMemoryAuto
private readonly ILogger<InMemoryModelFactory> _logger;
private readonly FileSystemWatcher? _watcher;
private readonly Lazy<UmbracoServices> _umbracoServices; // TODO: this is because of circular refs :(
private readonly IHostingEnvironment _hostingEnvironment;
private readonly IHostEnvironment _hostEnvironment;
private readonly IApplicationShutdownRegistry _hostingLifetime;
private readonly ModelsGenerationError _errors;
private readonly IPublishedValueFallback _publishedValueFallback;
@@ -48,6 +53,7 @@ namespace Umbraco.Cms.Web.Common.ModelsBuilder.InMemoryAuto
private ModelsBuilderSettings _config;
private bool _disposedValue;
[Obsolete("Use a not obsoleted constructor instead. Scheduled for removal in v16")]
public InMemoryModelFactory(
Lazy<UmbracoServices> umbracoServices,
IProfilingLogger profilingLogger,
@@ -63,12 +69,62 @@ namespace Umbraco.Cms.Web.Common.ModelsBuilder.InMemoryAuto
_profilingLogger = profilingLogger;
_logger = logger;
_config = config.CurrentValue;
_hostingEnvironment = hostingEnvironment;
_hostEnvironment = StaticServiceProvider.Instance.GetRequiredService<IHostEnvironment>();
_hostingLifetime = hostingLifetime;
_publishedValueFallback = publishedValueFallback;
_loadContextManager = loadContextManager;
_runtimeCompilationCacheBuster = runtimeCompilationCacheBuster;
_errors = new ModelsGenerationError(config, _hostingEnvironment);
_errors = new ModelsGenerationError(config, _hostEnvironment);
_ver = 1; // zero is for when we had no version
_skipver = -1; // nothing to skip
if (!hostingEnvironment.IsHosted)
{
return;
}
config.OnChange(x => _config = x);
_pureLiveDirectory = new Lazy<string>(PureLiveDirectoryAbsolute);
if (!Directory.Exists(_pureLiveDirectory.Value))
{
Directory.CreateDirectory(_pureLiveDirectory.Value);
}
// BEWARE! if the watcher is not properly released then for some reason the
// BuildManager will start confusing types - using a 'registered object' here
// though we should probably plug into Umbraco's MainDom - which is internal
_hostingLifetime.RegisterObject(this);
_watcher = new FileSystemWatcher(_pureLiveDirectory.Value);
_watcher.Changed += WatcherOnChanged;
_watcher.EnableRaisingEvents = true;
// get it here, this need to be fast
_debugLevel = _config.DebugLevel;
}
public InMemoryModelFactory(
Lazy<UmbracoServices> umbracoServices,
IProfilingLogger profilingLogger,
ILogger<InMemoryModelFactory> logger,
IOptionsMonitor<ModelsBuilderSettings> config,
IHostingEnvironment hostingEnvironment,
IHostEnvironment hostEnvironment,
IApplicationShutdownRegistry hostingLifetime,
IPublishedValueFallback publishedValueFallback,
InMemoryAssemblyLoadContextManager loadContextManager,
RuntimeCompilationCacheBuster runtimeCompilationCacheBuster)
{
_umbracoServices = umbracoServices;
_profilingLogger = profilingLogger;
_logger = logger;
_config = config.CurrentValue;
_hostEnvironment = hostEnvironment;
_hostingLifetime = hostingLifetime;
_publishedValueFallback = publishedValueFallback;
_loadContextManager = loadContextManager;
_runtimeCompilationCacheBuster = runtimeCompilationCacheBuster;
_errors = new ModelsGenerationError(config, _hostEnvironment);
_ver = 1; // zero is for when we had no version
_skipver = -1; // nothing to skip
@@ -359,7 +415,7 @@ namespace Umbraco.Cms.Web.Common.ModelsBuilder.InMemoryAuto
}
}
public string PureLiveDirectoryAbsolute() => _hostingEnvironment.MapPathContentRoot(Core.Constants.SystemDirectories.TempData + "/InMemoryAuto");
public string PureLiveDirectoryAbsolute() => _hostEnvironment.MapPathContentRoot(Core.Constants.SystemDirectories.TempData + "/InMemoryAuto");
// This is NOT thread safe but it is only called from within a lock
private Assembly ReloadAssembly(string pathToAssembly)

View File

@@ -32,7 +32,7 @@ public class UmbracoMvcConfigureOptions : IConfigureOptions<MvcOptions>
if (options.Conventions.Any(convention => convention is UmbracoBackofficeToken) is false)
{
// Replace the BackOfficeToken in routes.
var backofficePath = _globalSettings.UmbracoPath.TrimStart(Core.Constants.CharArrays.TildeForwardSlash);
var backofficePath = Core.Constants.System.DefaultUmbracoPath.TrimStart(Core.Constants.CharArrays.TildeForwardSlash);
options.Conventions.Add(new UmbracoBackofficeToken(Core.Constants.Web.AttributeRouting.BackOfficeToken, backofficePath));
}
}

View File

@@ -7,6 +7,7 @@ using Microsoft.AspNetCore.Mvc.ViewFeatures;
using Microsoft.AspNetCore.Razor.TagHelpers;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Configuration.Models;
using Umbraco.Cms.Core.Logging;
using Umbraco.Cms.Core.Models;
@@ -140,7 +141,7 @@ public abstract class UmbracoViewPage<TModel> : RazorPage<TModel>
markupToInject =
string.Format(
ContentSettings.PreviewBadge,
HostingEnvironment.ToAbsolute(GlobalSettings.UmbracoPath),
HostingEnvironment.ToAbsolute(Core.Constants.System.DefaultUmbracoPath),
Context.Request.GetEncodedUrl(),
UmbracoContext.PublishedRequest?.PublishedContent?.Key);
}

View File

@@ -1,6 +1,7 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Configuration.Models;
using Umbraco.Cms.Core.DependencyInjection;
using Umbraco.Cms.Core.Hosting;
@@ -49,7 +50,7 @@ public class RenderNoContentController : Controller
return Redirect("~/");
}
var model = new NoNodesViewModel { UmbracoPath = _hostingEnvironment.ToAbsolute(_globalSettings.UmbracoPath) };
var model = new NoNodesViewModel { UmbracoPath = _hostingEnvironment.ToAbsolute(Constants.System.DefaultUmbracoPath) };
return View(_globalSettings.NoNodesViewPath, model);
}

View File

@@ -10,6 +10,7 @@ using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.AspNetCore.Mvc.ViewFeatures;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.DependencyInjection;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Cache;
using Umbraco.Cms.Core.Configuration.Models;
using Umbraco.Cms.Core.Hosting;
@@ -85,7 +86,7 @@ public static class HtmlHelperRenderExtensions
var htmlBadge =
string.Format(
contentSettings.PreviewBadge,
hostingEnvironment.ToAbsolute(globalSettings.UmbracoPath),
hostingEnvironment.ToAbsolute(Constants.System.DefaultUmbracoPath),
WebUtility.UrlEncode(httpContextAccessor.GetRequiredHttpContext().Request.Path),
umbracoContext.PublishedRequest?.PublishedContent?.Key);
return new HtmlString(htmlBadge);

View File

@@ -197,12 +197,7 @@ public abstract class TestHelperBase
public TypeLoader GetMockedTypeLoader() =>
new(
Mock.Of<ITypeFinder>(),
new VaryingRuntimeHash(),
Mock.Of<IAppPolicyCache>(),
new DirectoryInfo(GetHostingEnvironment()
.MapPathContentRoot(Constants.SystemDirectories.TempData)),
Mock.Of<ILogger<TypeLoader>>(),
Mock.Of<IProfiler>());
Mock.Of<ILogger<TypeLoader>>());
/// <summary>
/// Some test files are copied to the /bin (/bin/debug) on build, this is a utility to return their physical path based

View File

@@ -10,6 +10,7 @@ using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Moq;
using NUnit.Framework;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Cache;
using Umbraco.Cms.Core.Composing;
using Umbraco.Cms.Core.Configuration.Models;
@@ -129,7 +130,7 @@ public static class UmbracoBuilderExtensions
uiProject.Create();
}
var mainLangFolder = new DirectoryInfo(Path.Combine(uiProject.FullName, globalSettings.Value.UmbracoPath.TrimStartExact("~/"), "config", "lang"));
var mainLangFolder = new DirectoryInfo(Path.Combine(uiProject.FullName, Constants.System.DefaultUmbracoPath.TrimStartExact("~/"), "config", "lang"));
return new LocalizedTextServiceFileSources(
loggerFactory.CreateLogger<LocalizedTextServiceFileSources>(),

View File

@@ -55,6 +55,8 @@ public class ContentServiceTests : UmbracoIntegrationTestWithContent
private IUserService UserService => GetRequiredService<IUserService>();
private IUserGroupService UserGroupService => GetRequiredService<IUserGroupService>();
private IRelationService RelationService => GetRequiredService<IRelationService>();
private ILocalizedTextService TextService => GetRequiredService<ILocalizedTextService>();
@@ -2055,11 +2057,11 @@ public class ContentServiceTests : UmbracoIntegrationTestWithContent
ContentService.Save(content2);
Assert.IsTrue(ContentService.Publish(content2, content2.AvailableCultures.ToArray(), userId: -1).Success);
var editorGroup = UserService.GetUserGroupByAlias(Constants.Security.EditorGroupAlias);
var editorGroup = await UserGroupService.GetAsync(Constants.Security.EditorGroupKey);
editorGroup.StartContentId = content1.Id;
UserService.Save(editorGroup);
var admin = UserService.GetUserById(Constants.Security.SuperUserId);
var admin = await UserService.GetAsync(Constants.Security.SuperUserKey);
admin.StartContentIds = new[] { content1.Id };
UserService.Save(admin);
@@ -2071,7 +2073,7 @@ public class ContentServiceTests : UmbracoIntegrationTestWithContent
new List<PublicAccessRule> { new() { RuleType = "test", RuleValue = "test" } }));
Assert.IsTrue(PublicAccessService.AddRule(content1, "test2", "test2").Success);
var user = UserService.GetUserById(Constants.Security.SuperUserId);
var user = await UserService.GetAsync(Constants.Security.SuperUserKey);
var userGroup = UserService.GetUserGroupByAlias(user.Groups.First().Alias);
Assert.IsNotNull(NotificationService.CreateNotification(user, content1, "X"));

View File

@@ -169,11 +169,9 @@ public class UserGroupServiceValidationTests : UmbracoIntegrationTest
Assert.AreEqual(updateName, updatedGroup.Name);
}
// these keys are not defined as "const" in Constants.Security but as "static readonly", so we have to hardcode
// them here ("static readonly" can't be used as testcase inputs as they are not constants)
[TestCase("E5E7F6C8-7F9C-4B5B-8D5D-9E1E5A4F7E4D", "admin")]
[TestCase("8C6AD70F-D307-4E4A-AF58-72C2E4E9439D", "sensitiveData")]
[TestCase("F2012E4C-D232-4BD1-8EAE-4384032D97D8", "translator")]
[TestCase(Constants.Security.AdminGroupKeyString, "admin")]
[TestCase(Constants.Security.SensitiveDataGroupKeyString, "sensitiveData")]
[TestCase(Constants.Security.TranslatorGroupString, "translator")]
public async Task Cannot_Delete_System_UserGroups(string userGroupKeyAsString, string expectedGroupAlias)
{
// since we can't use the constants as input, let's make sure we don't get false positives by double checking the group alias
@@ -188,10 +186,8 @@ public class UserGroupServiceValidationTests : UmbracoIntegrationTest
Assert.AreEqual(UserGroupOperationStatus.CanNotDeleteIsSystemUserGroup, result.Result);
}
// these keys are not defined as "const" in Constants.Security but as "static readonly", so we have to hardcode
// them here ("static readonly" can't be used as testcase inputs as they are not constants)
[TestCase("44DC260E-B4D4-4DD9-9081-EEC5598F1641", "editor")]
[TestCase("9FC2A16F-528C-46D6-A014-75BF4EC2480C", "writer")]
[TestCase( Constants.Security.EditorGroupKeyString, "editor")]
[TestCase(Constants.Security.WriterGroupKeyString, "writer")]
public async Task Can_Delete_Non_System_UserGroups(string userGroupKeyAsString, string expectedGroupAlias)
{
// since we can't use the constants as input, let's make sure we don't get false positives by double checking the group alias
@@ -203,6 +199,6 @@ public class UserGroupServiceValidationTests : UmbracoIntegrationTest
var result = await UserGroupService.DeleteAsync(key);
Assert.IsTrue(result.Success);
Assert.AreEqual(UserGroupOperationStatus.Success, result.Result);
Assert.AreEqual(result.Result,UserGroupOperationStatus.Success);
}
}

View File

@@ -16,7 +16,7 @@ public partial class UserServiceCrudTests
public async Task Cannot_Request_Disabled_If_Hidden(UserState includeState)
{
var userService = CreateUserService(new SecuritySettings {HideDisabledUsersInBackOffice = true});
var editorGroup = await UserGroupService.GetAsync(Constants.Security.EditorGroupAlias);
var editorGroup = await UserGroupService.GetAsync(Constants.Security.EditorGroupKey);
var createModel = new UserCreateModel
{
@@ -44,8 +44,8 @@ public partial class UserServiceCrudTests
public async Task Only_Super_User_Can_Filter_Super_user()
{
var userService = CreateUserService();
var editorGroup = await UserGroupService.GetAsync(Constants.Security.EditorGroupAlias);
var adminGroup = await UserGroupService.GetAsync(Constants.Security.AdminGroupAlias);
var editorGroup = await UserGroupService.GetAsync(Constants.Security.EditorGroupKey);
var adminGroup = await UserGroupService.GetAsync(Constants.Security.AdminGroupKey);
var nonSuperCreateModel = new UserCreateModel
{
@@ -78,7 +78,7 @@ public partial class UserServiceCrudTests
public async Task Super_User_Can_Filter_Super_User()
{
var userService = CreateUserService();
var editorGroup = await UserGroupService.GetAsync(Constants.Security.EditorGroupAlias);
var editorGroup = await UserGroupService.GetAsync(Constants.Security.EditorGroupKey);
var nonSuperCreateModel = new UserCreateModel
{
@@ -107,8 +107,8 @@ public partial class UserServiceCrudTests
public async Task Non_Admins_Cannot_Filter_Admins()
{
var userService = CreateUserService();
var adminGroup = await UserGroupService.GetAsync(Constants.Security.AdminGroupAlias);
var editorGroup = await UserGroupService.GetAsync(Constants.Security.EditorGroupAlias);
var adminGroup = await UserGroupService.GetAsync(Constants.Security.AdminGroupKey);
var editorGroup = await UserGroupService.GetAsync(Constants.Security.EditorGroupKey);
var editorCreateModel = new UserCreateModel
{
@@ -146,8 +146,8 @@ public partial class UserServiceCrudTests
public async Task Admins_Can_Filter_Admins()
{
var userService = CreateUserService();
var adminGroup = await UserGroupService.GetAsync(Constants.Security.AdminGroupAlias);
var editorGroup = await UserGroupService.GetAsync(Constants.Security.EditorGroupAlias);
var adminGroup = await UserGroupService.GetAsync(Constants.Security.AdminGroupKey);
var editorGroup = await UserGroupService.GetAsync(Constants.Security.EditorGroupKey);
var editorCreateModel = new UserCreateModel
{
@@ -185,10 +185,10 @@ public partial class UserServiceCrudTests
private async Task CreateTestUsers(IUserService userService)
{
var editorGroup = await UserGroupService.GetAsync(Constants.Security.EditorGroupAlias);
var adminGroup = await UserGroupService.GetAsync(Constants.Security.AdminGroupAlias);
var writerGroup = await UserGroupService.GetAsync(Constants.Security.WriterGroupAlias);
var translatorGroup = await UserGroupService.GetAsync(Constants.Security.TranslatorGroupAlias);
var editorGroup = await UserGroupService.GetAsync(Constants.Security.EditorGroupKey);
var adminGroup = await UserGroupService.GetAsync(Constants.Security.AdminGroupKey);
var writerGroup = await UserGroupService.GetAsync(Constants.Security.WriterGroupKey);
var translatorGroup = await UserGroupService.GetAsync(Constants.Security.TranslatorGroupKey);
var createModels = new List<UserCreateModel>
{
@@ -262,7 +262,7 @@ public partial class UserServiceCrudTests
var userService = CreateUserService();
await CreateTestUsers(userService);
var editorGroup = await UserGroupService.GetAsync(Constants.Security.EditorGroupAlias);
var editorGroup = await UserGroupService.GetAsync(Constants.Security.EditorGroupKey);
var filter = new UserFilter
{
ExcludeUserGroups = new HashSet<Guid> { editorGroup!.Key }

View File

@@ -13,8 +13,8 @@ public partial class UserServiceCrudTests
public async Task Only_Super_User_Can_Get_Super_user()
{
var userService = CreateUserService();
var editorGroup = await UserGroupService.GetAsync(Constants.Security.EditorGroupAlias);
var adminGroup = await UserGroupService.GetAsync(Constants.Security.AdminGroupAlias);
var editorGroup = await UserGroupService.GetAsync(Constants.Security.EditorGroupKey);
var adminGroup = await UserGroupService.GetAsync(Constants.Security.AdminGroupKey);
var nonSuperCreateModel = new UserCreateModel
{
@@ -43,7 +43,7 @@ public partial class UserServiceCrudTests
public async Task Super_User_Can_See_Super_User()
{
var userService = CreateUserService();
var editorGroup = await UserGroupService.GetAsync(Constants.Security.EditorGroupAlias);
var editorGroup = await UserGroupService.GetAsync(Constants.Security.EditorGroupKey);
var nonSuperCreateModel = new UserCreateModel
{
@@ -71,8 +71,8 @@ public partial class UserServiceCrudTests
public async Task Non_Admins_Cannot_Get_admins()
{
var userService = CreateUserService();
var adminGroup = await UserGroupService.GetAsync(Constants.Security.AdminGroupAlias);
var editorGroup = await UserGroupService.GetAsync(Constants.Security.EditorGroupAlias);
var adminGroup = await UserGroupService.GetAsync(Constants.Security.AdminGroupKey);
var editorGroup = await UserGroupService.GetAsync(Constants.Security.EditorGroupKey);
var editorCreateModel = new UserCreateModel
{
@@ -107,8 +107,8 @@ public partial class UserServiceCrudTests
public async Task Admins_Can_See_Admins()
{
var userService = CreateUserService();
var adminGroup = await UserGroupService.GetAsync(Constants.Security.AdminGroupAlias);
var editorGroup = await UserGroupService.GetAsync(Constants.Security.EditorGroupAlias);
var adminGroup = await UserGroupService.GetAsync(Constants.Security.AdminGroupKey);
var editorGroup = await UserGroupService.GetAsync(Constants.Security.EditorGroupKey);
var editorCreateModel = new UserCreateModel
{
@@ -144,7 +144,7 @@ public partial class UserServiceCrudTests
public async Task Cannot_See_Disabled_When_HideDisabled_Is_True()
{
var userService = CreateUserService(securitySettings: new SecuritySettings { HideDisabledUsersInBackOffice = true });
var editorGroup = await UserGroupService.GetAsync(Constants.Security.EditorGroupAlias);
var editorGroup = await UserGroupService.GetAsync(Constants.Security.EditorGroupKey);
var firstEditorCreateModel = new UserCreateModel
{

View File

@@ -11,7 +11,7 @@ public partial class UserServiceCrudTests
[Test]
public async Task Can_Enable_User()
{
var editorUserGroup = await UserGroupService.GetAsync(Constants.Security.EditorGroupAlias);
var editorUserGroup = await UserGroupService.GetAsync(Constants.Security.EditorGroupKey);
var userCreateModel = new UserCreateModel
{
@@ -39,7 +39,7 @@ public partial class UserServiceCrudTests
[Test]
public async Task Can_Disable_User()
{
var editorUserGroup = await UserGroupService.GetAsync(Constants.Security.EditorGroupAlias);
var editorUserGroup = await UserGroupService.GetAsync(Constants.Security.EditorGroupKey);
var userCreateModel = new UserCreateModel
{
@@ -63,7 +63,7 @@ public partial class UserServiceCrudTests
[Test]
public async Task User_Cannot_Disable_Self()
{
var adminUserGroup = await UserGroupService.GetAsync(Constants.Security.AdminGroupAlias);
var adminUserGroup = await UserGroupService.GetAsync(Constants.Security.AdminGroupKey);
var userCreateModel = new UserCreateModel
{
@@ -85,7 +85,7 @@ public partial class UserServiceCrudTests
[Test]
public async Task Cannot_Disable_Invited_User()
{
var editorUserGroup = await UserGroupService.GetAsync(Constants.Security.EditorGroupAlias);
var editorUserGroup = await UserGroupService.GetAsync(Constants.Security.EditorGroupKey);
var userInviteModel = new UserInviteModel
{
@@ -108,7 +108,7 @@ public partial class UserServiceCrudTests
[Test]
public async Task Enable_Missing_User_Fails_With_Not_Found()
{
var editorUserGroup = await UserGroupService.GetAsync(Constants.Security.EditorGroupAlias);
var editorUserGroup = await UserGroupService.GetAsync(Constants.Security.EditorGroupKey);
var userCreateModel = new UserCreateModel
{
@@ -132,7 +132,7 @@ public partial class UserServiceCrudTests
[Test]
public async Task Disable_Missing_User_Fails_With_Not_Found()
{
var editorUserGroup = await UserGroupService.GetAsync(Constants.Security.EditorGroupAlias);
var editorUserGroup = await UserGroupService.GetAsync(Constants.Security.EditorGroupKey);
var userCreateModel = new UserCreateModel
{

View File

@@ -68,34 +68,3 @@ public class CustomDbContextCustomSqliteProviderTests : UmbracoIntegrationTest
}
}
[Obsolete]
[TestFixture]
[UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest, Logger = UmbracoTestOptions.Logger.Console)]
public class CustomDbContextLegacyExtensionProviderTests : UmbracoIntegrationTest
{
[Test]
public void Can_Register_Custom_DbContext_And_Resolve()
{
var dbContext = Services.GetRequiredService<CustomDbContext>();
Assert.IsNotNull(dbContext);
Assert.IsNotEmpty(dbContext.Database.GetConnectionString());
}
protected override void CustomTestSetup(IUmbracoBuilder builder)
{
builder.Services.AddUmbracoEFCoreContext<CustomDbContext>("Data Source=:memory:;Version=3;New=True;", "Microsoft.Data.Sqlite", (options, connectionString, providerName) =>
{
options.UseSqlite(connectionString);
});
}
internal class CustomDbContext : Microsoft.EntityFrameworkCore.DbContext
{
public CustomDbContext(DbContextOptions<CustomDbContext> options)
: base(options)
{
}
}
}

View File

@@ -108,11 +108,7 @@ public class ComponentTests
private static TypeLoader MockTypeLoader() => new(
Mock.Of<ITypeFinder>(),
new VaryingRuntimeHash(),
Mock.Of<IAppPolicyCache>(),
new DirectoryInfo(TestHelper.GetHostingEnvironment().MapPathContentRoot(Constants.SystemDirectories.TempData)),
Mock.Of<ILogger<TypeLoader>>(),
Mock.Of<IProfiler>());
Mock.Of<ILogger<TypeLoader>>());
[Test]
public async Task Boot1A()
@@ -140,16 +136,6 @@ public class ComponentTests
return new Composer1();
}
if (type == typeof(Composer5))
{
return new Composer5();
}
if (type == typeof(Component5))
{
return new Component5(new SomeResource());
}
if (type == typeof(IProfilingLogger))
{
return new ProfilingLogger(Mock.Of<ILogger<ProfilingLogger>>(), Mock.Of<IProfiler>());
@@ -297,26 +283,6 @@ public class ComponentTests
return new Composer1();
}
if (type == typeof(Composer5))
{
return new Composer5();
}
if (type == typeof(Composer5a))
{
return new Composer5a();
}
if (type == typeof(Component5))
{
return new Component5(new SomeResource());
}
if (type == typeof(Component5a))
{
return new Component5a();
}
if (type == typeof(IProfilingLogger))
{
return new ProfilingLogger(Mock.Of<ILogger<ProfilingLogger>>(), Mock.Of<IProfiler>());
@@ -337,24 +303,15 @@ public class ComponentTests
});
var composition = new UmbracoBuilder(register, Mock.Of<IConfiguration>(), TestHelper.GetMockedTypeLoader());
Type[] types = { typeof(Composer1), typeof(Composer5), typeof(Composer5a) };
Type[] types = { typeof(Composer1) };
var composers = new ComposerGraph(composition, types, Enumerable.Empty<Attribute>(), Mock.Of<ILogger<ComposerGraph>>());
Assert.IsEmpty(Composed);
composers.Compose();
AssertTypeArray(TypeArray<Composer1, Composer5, Composer5a>(), Composed);
var builder = composition.WithCollectionBuilder<ComponentCollectionBuilder>();
builder.RegisterWith(register);
var components = builder.CreateCollection(factory);
Assert.IsEmpty(Initialized);
await components.InitializeAsync(false, default);
AssertTypeArray(TypeArray<Component5, Component5a>(), Initialized);
Assert.IsEmpty(Terminated);
await components.TerminateAsync(false, default);
AssertTypeArray(TypeArray<Component5a, Component5>(), Terminated);
}
[Test]
@@ -491,11 +448,7 @@ public class ComponentTests
var typeFinder = TestHelper.GetTypeFinder();
var typeLoader = new TypeLoader(
typeFinder,
new VaryingRuntimeHash(),
AppCaches.Disabled.RuntimeCache,
new DirectoryInfo(TestHelper.GetHostingEnvironment().MapPathContentRoot(Constants.SystemDirectories.TempData)),
Mock.Of<ILogger<TypeLoader>>(),
Mock.Of<IProfiler>());
Mock.Of<ILogger<TypeLoader>>());
var register = MockRegister();
var builder = new UmbracoBuilder(register, Mock.Of<IConfiguration>(), TestHelper.GetMockedTypeLoader());
@@ -537,43 +490,6 @@ public class ComponentTests
{
}
public class Composer5 : TestComposerBase
{
public override void Compose(IUmbracoBuilder builder)
{
base.Compose(builder);
builder.Components().Append<Component5>();
}
}
[ComposeAfter(typeof(Composer5))]
public class Composer5a : TestComposerBase
{
public override void Compose(IUmbracoBuilder builder)
{
base.Compose(builder);
builder.Components().Append<Component5a>();
}
}
public class TestComponentBase : IComponent
{
public virtual void Initialize() => Initialized.Add(GetType());
public virtual void Terminate() => Terminated.Add(GetType());
}
public class Component5 : TestComponentBase
{
private readonly ISomeResource _resource;
public Component5(ISomeResource resource) => _resource = resource;
}
public class Component5a : TestComponentBase
{
}
[Disable]
public class Composer6 : TestComposerBase
{

View File

@@ -31,12 +31,7 @@ public abstract class ComposingTestBase
var typeFinder = TestHelper.GetTypeFinder();
TypeLoader = new TypeLoader(
typeFinder,
new VaryingRuntimeHash(),
NoAppCache.Instance,
new DirectoryInfo(TestHelper.GetHostingEnvironment().MapPathContentRoot(Constants.SystemDirectories.TempData)),
Mock.Of<ILogger<TypeLoader>>(),
Mock.Of<IProfiler>(),
false,
AssembliesToScan);
}
}

View File

@@ -43,13 +43,7 @@ public class TypeLoaderTests
};
_typeLoader = new TypeLoader(
typeFinder,
new VaryingRuntimeHash(),
NoAppCache.Instance,
new DirectoryInfo(TestHelper.GetHostingEnvironment()
.MapPathContentRoot(Constants.SystemDirectories.TempData)),
Mock.Of<ILogger<TypeLoader>>(),
Mock.Of<IProfiler>(),
false,
assemblies);
}

View File

@@ -28,7 +28,7 @@ public class GlobalSettingsTests
{
hostingSettings.CurrentValue.ApplicationVirtualPath = rootPath;
var globalSettings = new GlobalSettings { UmbracoPath = path };
var globalSettings = new GlobalSettings();
Assert.AreEqual(outcome, globalSettings.GetUmbracoMvcAreaNoCache(hostingEnvironment));
}

View File

@@ -313,24 +313,22 @@ public class UdiTests
[UdiDefinition("foo", UdiType.GuidUdi)]
public class FooConnector : IServiceConnector
{
public IArtifact GetArtifact(Udi udi, IContextCache contextCache) => throw new NotImplementedException();
public Task<IArtifact?> GetArtifactAsync(Udi udi, IContextCache contextCache, CancellationToken cancellationToken = default) => throw new NotImplementedException();
public IArtifact GetArtifact(object entity, IContextCache contextCache) => throw new NotImplementedException();
public Task<IArtifact> GetArtifactAsync(object entity, IContextCache contextCache, CancellationToken cancellationToken = default) => throw new NotImplementedException();
public ArtifactDeployState ProcessInit(IArtifact art, IDeployContext context) =>
public Task<ArtifactDeployState> ProcessInitAsync(IArtifact artifact, IDeployContext context, CancellationToken cancellationToken = default) => throw new NotImplementedException();
public Task ProcessAsync(ArtifactDeployState state, IDeployContext context, int pass,
CancellationToken cancellationToken = default) =>
throw new NotImplementedException();
public void Process(ArtifactDeployState dart, IDeployContext context, int pass) =>
throw new NotImplementedException();
public IAsyncEnumerable<Udi> ExpandRangeAsync(UdiRange range, CancellationToken cancellationToken = default) => throw new NotImplementedException();
public void Explode(UdiRange range, List<Udi> udis) => throw new NotImplementedException();
public Task<NamedUdiRange> GetRangeAsync(Udi udi, string selector, CancellationToken cancellationToken = default) => throw new NotImplementedException();
public NamedUdiRange GetRange(Udi udi, string selector) => throw new NotImplementedException();
public Task<NamedUdiRange> GetRangeAsync(string entityType, string sid, string selector, CancellationToken cancellationToken = default) => throw new NotImplementedException();
public NamedUdiRange GetRange(string entityType, string sid, string selector) =>
throw new NotImplementedException();
public bool Compare(IArtifact art1, IArtifact art2, ICollection<Difference> differences = null) =>
throw new NotImplementedException();
public bool Compare(IArtifact? art1, IArtifact? art2, ICollection<Difference>? differences = null) => throw new NotImplementedException();
}
}

View File

@@ -90,21 +90,27 @@ public class UserGroupServiceTests
});
}
[TestCase(false,UserGroupOperationStatus.Success)]
[TestCase(true,UserGroupOperationStatus.CanNotUpdateAliasIsSystemUserGroup)]
public async Task Can_Not_Update_SystemGroup_Alias(bool isSystemGroup, UserGroupOperationStatus status)
// Obsoletion will be resolved when they are converted to internal consts.
[TestCase(null, null, UserGroupOperationStatus.Success)]
[TestCase(Constants.Security.AdminGroupKeyString, Constants.Security.AdminGroupAlias, UserGroupOperationStatus.CanNotUpdateAliasIsSystemUserGroup)]
[TestCase(Constants.Security.SensitiveDataGroupKeyString, Constants.Security.SensitiveDataGroupAlias, UserGroupOperationStatus.CanNotUpdateAliasIsSystemUserGroup)]
[TestCase(Constants.Security.TranslatorGroupString, Constants.Security.TranslatorGroupAlias, UserGroupOperationStatus.CanNotUpdateAliasIsSystemUserGroup)]
public async Task Can_Not_Update_SystemGroup_Alias(string? systemGroupKey, string? systemGroupAlias, UserGroupOperationStatus status)
{
// prep
var userGroupAlias = systemGroupAlias ?? "someNonSystemAlias";
Guid userGroupKey = systemGroupKey is not null ? new Guid(systemGroupKey) : Guid.NewGuid();
// Arrange
var actingUserKey = Guid.NewGuid();
var mockUser = SetupUserWithGroupAccess(actingUserKey, [Constants.Security.AdminGroupAlias]);
var userService = SetupUserServiceWithGetUserByKey(actingUserKey, mockUser);
var userGroupRepository = new Mock<IUserGroupRepository>();
var userGroupKey = Guid.NewGuid();
var persistedUserGroup =
new UserGroup(
Mock.Of<IShortStringHelper>(),
0,
isSystemGroup ? Constants.Security.AdminGroupAlias : "someNonSystemAlias",
userGroupAlias,
"Administrators",
null)
{