Fix Sqlite database locking issue (#13246)
* Add locking for creating scope * Lock the repository instead * Add scope in action instead of locking in service * Fix up post-merge Co-authored-by: Zeegaan <nge@umbraco.dk>
This commit is contained in:
@@ -15,6 +15,7 @@ using Umbraco.Cms.Core.Mapping;
|
||||
using Umbraco.Cms.Core.Models;
|
||||
using Umbraco.Cms.Core.Models.ContentEditing;
|
||||
using Umbraco.Cms.Core.PropertyEditors;
|
||||
using Umbraco.Cms.Core.Scoping;
|
||||
using Umbraco.Cms.Core.Security;
|
||||
using Umbraco.Cms.Core.Services;
|
||||
using Umbraco.Cms.Core.Strings;
|
||||
@@ -46,6 +47,7 @@ public class ContentTypeController : ContentTypeControllerBase<IContentType>
|
||||
private readonly ILogger<ContentTypeController> _logger;
|
||||
private readonly PackageDataInstallation _packageDataInstallation;
|
||||
private readonly BlockGridSampleHelper _blockGridSampleHelper;
|
||||
private readonly ICoreScopeProvider _coreScopeProvider;
|
||||
|
||||
private readonly PropertyEditorCollection _propertyEditors;
|
||||
// TODO: Split this controller apart so that authz is consistent, currently we need to authz each action individually.
|
||||
@@ -99,7 +101,7 @@ public class ContentTypeController : ContentTypeControllerBase<IContentType>
|
||||
{
|
||||
}
|
||||
|
||||
[ActivatorUtilitiesConstructor]
|
||||
[Obsolete("Please use constructor that takes an ICoreScopeProvider")]
|
||||
public ContentTypeController(
|
||||
ICultureDictionary cultureDictionary,
|
||||
IContentTypeService contentTypeService,
|
||||
@@ -120,6 +122,52 @@ public class ContentTypeController : ContentTypeControllerBase<IContentType>
|
||||
EditorValidatorCollection editorValidatorCollection,
|
||||
PackageDataInstallation packageDataInstallation,
|
||||
BlockGridSampleHelper blockGridSampleHelper)
|
||||
: this(
|
||||
cultureDictionary,
|
||||
contentTypeService,
|
||||
mediaTypeService,
|
||||
memberTypeService,
|
||||
umbracoMapper,
|
||||
localizedTextService,
|
||||
serializer,
|
||||
propertyEditors,
|
||||
backofficeSecurityAccessor,
|
||||
dataTypeService,
|
||||
shortStringHelper,
|
||||
fileService,
|
||||
logger,
|
||||
contentService,
|
||||
contentTypeBaseServiceProvider,
|
||||
hostingEnvironment,
|
||||
editorValidatorCollection,
|
||||
packageDataInstallation,
|
||||
blockGridSampleHelper,
|
||||
StaticServiceProvider.Instance.GetRequiredService<ICoreScopeProvider>())
|
||||
{
|
||||
}
|
||||
|
||||
[ActivatorUtilitiesConstructor]
|
||||
public ContentTypeController(
|
||||
ICultureDictionary cultureDictionary,
|
||||
IContentTypeService contentTypeService,
|
||||
IMediaTypeService mediaTypeService,
|
||||
IMemberTypeService memberTypeService,
|
||||
IUmbracoMapper umbracoMapper,
|
||||
ILocalizedTextService localizedTextService,
|
||||
IEntityXmlSerializer serializer,
|
||||
PropertyEditorCollection propertyEditors,
|
||||
IBackOfficeSecurityAccessor backofficeSecurityAccessor,
|
||||
IDataTypeService dataTypeService,
|
||||
IShortStringHelper shortStringHelper,
|
||||
IFileService fileService,
|
||||
ILogger<ContentTypeController> logger,
|
||||
IContentService contentService,
|
||||
IContentTypeBaseServiceProvider contentTypeBaseServiceProvider,
|
||||
IHostingEnvironment hostingEnvironment,
|
||||
EditorValidatorCollection editorValidatorCollection,
|
||||
PackageDataInstallation packageDataInstallation,
|
||||
BlockGridSampleHelper blockGridSampleHelper,
|
||||
ICoreScopeProvider coreScopeProvider)
|
||||
: base(
|
||||
cultureDictionary,
|
||||
editorValidatorCollection,
|
||||
@@ -144,6 +192,7 @@ public class ContentTypeController : ContentTypeControllerBase<IContentType>
|
||||
_hostingEnvironment = hostingEnvironment;
|
||||
_packageDataInstallation = packageDataInstallation;
|
||||
_blockGridSampleHelper = blockGridSampleHelper;
|
||||
_coreScopeProvider = coreScopeProvider;
|
||||
}
|
||||
|
||||
[Authorize(Policy = AuthorizationPolicies.TreeAccessDocumentTypes)]
|
||||
@@ -444,6 +493,7 @@ public class ContentTypeController : ContentTypeControllerBase<IContentType>
|
||||
|
||||
private ITemplate? CreateTemplateForContentType(string contentTypeAlias, string? contentTypeName)
|
||||
{
|
||||
using ICoreScope scope = _coreScopeProvider.CreateCoreScope();
|
||||
ITemplate? template = _fileService.GetTemplate(contentTypeAlias);
|
||||
if (template == null)
|
||||
{
|
||||
@@ -460,6 +510,8 @@ public class ContentTypeController : ContentTypeControllerBase<IContentType>
|
||||
template = tryCreateTemplate.Result?.Entity;
|
||||
}
|
||||
|
||||
scope.Complete();
|
||||
|
||||
return template;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user