From 47d3af9bb3772cbd09aaa49f8a6205d6c2d3f9a4 Mon Sep 17 00:00:00 2001 From: Shannon Date: Mon, 16 Sep 2019 16:59:57 +1000 Subject: [PATCH] removes the test suspendable model factory code --- .../Packaging/PackageDataInstallation.cs | 5 +- .../PublishedModelFactoryExtensions.cs | 94 +------------------ .../Cache/ContentTypeCacheRefresher.cs | 1 - .../Cache/DataTypeCacheRefresher.cs | 1 - .../Editors/ContentTypeController.cs | 6 +- .../NuCache/PublishedSnapshotService.cs | 2 - 6 files changed, 6 insertions(+), 103 deletions(-) diff --git a/src/Umbraco.Core/Packaging/PackageDataInstallation.cs b/src/Umbraco.Core/Packaging/PackageDataInstallation.cs index d488f438ff..b6dd49bd18 100644 --- a/src/Umbraco.Core/Packaging/PackageDataInstallation.cs +++ b/src/Umbraco.Core/Packaging/PackageDataInstallation.cs @@ -28,15 +28,13 @@ namespace Umbraco.Core.Packaging private readonly IDataTypeService _dataTypeService; private readonly PropertyEditorCollection _propertyEditors; private readonly IScopeProvider _scopeProvider; - private readonly IPublishedModelFactory _publishedModelFactory; private readonly IEntityService _entityService; private readonly IContentTypeService _contentTypeService; private readonly IContentService _contentService; public PackageDataInstallation(ILogger logger, IFileService fileService, IMacroService macroService, ILocalizationService localizationService, IDataTypeService dataTypeService, IEntityService entityService, IContentTypeService contentTypeService, - IContentService contentService, PropertyEditorCollection propertyEditors, IScopeProvider scopeProvider, - IPublishedModelFactory publishedModelFactory) + IContentService contentService, PropertyEditorCollection propertyEditors, IScopeProvider scopeProvider) { _logger = logger; _fileService = fileService; @@ -45,7 +43,6 @@ namespace Umbraco.Core.Packaging _dataTypeService = dataTypeService; _propertyEditors = propertyEditors; _scopeProvider = scopeProvider; - _publishedModelFactory = publishedModelFactory; _entityService = entityService; _contentTypeService = contentTypeService; _contentService = contentService; diff --git a/src/Umbraco.Core/PublishedModelFactoryExtensions.cs b/src/Umbraco.Core/PublishedModelFactoryExtensions.cs index e314746ffd..0e3aa48c53 100644 --- a/src/Umbraco.Core/PublishedModelFactoryExtensions.cs +++ b/src/Umbraco.Core/PublishedModelFactoryExtensions.cs @@ -28,17 +28,9 @@ namespace Umbraco.Core { lock (liveFactory.SyncRoot) { - //if (_suspend != null) - //{ - // //if we are currently suspended, queue the action - // _suspend.Queue(action); - //} - //else - //{ - //Call refresh on the live factory to re-compile the models - liveFactory.Refresh(); - action(); - //} + //Call refresh on the live factory to re-compile the models + liveFactory.Refresh(); + action(); } } else @@ -103,85 +95,5 @@ namespace Umbraco.Core private static volatile bool _refresh = false; - //public static IDisposable SuspendSafeLiveFactory(this IPublishedModelFactory factory) - //{ - // if (factory is ILivePublishedModelFactory liveFactory) - // { - // lock (liveFactory.SyncRoot) - // { - // if (_suspend == null) - // { - // _suspend = new SuspendSafeLiveFactory( - // factory, - // () => _suspend = null); //reset when it's done - // } - // return _suspend; - // } - // } - // else - // { - // return new SuspendSafeLiveFactory(factory); //returns a noop version of IDisposable, this won't actually do anything - // } - //} - - //private static SuspendSafeLiveFactory _suspend; - } - - internal class SuspendSafeLiveFactory : IDisposable - { - private readonly IPublishedModelFactory _factory; - private readonly Action _reset; - private readonly List _actions = new List(); - - public SuspendSafeLiveFactory(IPublishedModelFactory factory, Action reset = null) - { - _factory = factory; - _reset = reset; - } - - /// - /// Queue an action to execute on disposal after rebuild - /// - /// - public void Queue(Action action) - { - _actions.Add(action); - } - - #region IDisposable Support - private bool disposedValue = false; // To detect redundant calls - - protected virtual void Dispose(bool disposing) - { - if (!disposedValue) - { - if (disposing) - { - if (_factory is ILivePublishedModelFactory liveFactory) - { - lock (liveFactory.SyncRoot) - { - //Call refresh on the live factory to re-compile the models - liveFactory.Refresh(); - - //then we need to call all queued actions - foreach(var action in _actions) - action(); - } - } - _reset?.Invoke(); - } - disposedValue = true; - } - } - - // This code added to correctly implement the disposable pattern. - public void Dispose() - { - // Do not change this code. Put cleanup code in Dispose(bool disposing) above. - Dispose(true); - } - #endregion - } } diff --git a/src/Umbraco.Web/Cache/ContentTypeCacheRefresher.cs b/src/Umbraco.Web/Cache/ContentTypeCacheRefresher.cs index 4d339ff336..df81dd85e8 100644 --- a/src/Umbraco.Web/Cache/ContentTypeCacheRefresher.cs +++ b/src/Umbraco.Web/Cache/ContentTypeCacheRefresher.cs @@ -90,7 +90,6 @@ namespace Umbraco.Web.Cache // service of changes, else factories may try to rebuild models while // we are using the database to load content into caches - //_publishedModelFactory.WithSafeLiveFactory(() => _publishedModelFactory.WithSafeLiveFactoryRefreshSet(() => _publishedSnapshotService.Notify(payloads)); diff --git a/src/Umbraco.Web/Cache/DataTypeCacheRefresher.cs b/src/Umbraco.Web/Cache/DataTypeCacheRefresher.cs index b80542af44..f86073abdd 100644 --- a/src/Umbraco.Web/Cache/DataTypeCacheRefresher.cs +++ b/src/Umbraco.Web/Cache/DataTypeCacheRefresher.cs @@ -66,7 +66,6 @@ namespace Umbraco.Web.Cache // service of changes, else factories may try to rebuild models while // we are using the database to load content into caches - //_publishedModelFactory.WithSafeLiveFactory(() => _publishedModelFactory.WithSafeLiveFactoryRefreshSet(() => _publishedSnapshotService.Notify(payloads)); diff --git a/src/Umbraco.Web/Editors/ContentTypeController.cs b/src/Umbraco.Web/Editors/ContentTypeController.cs index 82cf3a5813..7c63061159 100644 --- a/src/Umbraco.Web/Editors/ContentTypeController.cs +++ b/src/Umbraco.Web/Editors/ContentTypeController.cs @@ -49,7 +49,6 @@ namespace Umbraco.Web.Editors private readonly IEntityXmlSerializer _serializer; private readonly PropertyEditorCollection _propertyEditors; private readonly IScopeProvider _scopeProvider; - private readonly IPublishedModelFactory _publishedModelFactory; public ContentTypeController(IEntityXmlSerializer serializer, ICultureDictionaryFactory cultureDictionaryFactory, @@ -58,13 +57,12 @@ namespace Umbraco.Web.Editors ISqlContext sqlContext, PropertyEditorCollection propertyEditors, ServiceContext services, AppCaches appCaches, IProfilingLogger logger, IRuntimeState runtimeState, UmbracoHelper umbracoHelper, - IScopeProvider scopeProvider, IPublishedModelFactory publishedModelFactory) + IScopeProvider scopeProvider) : base(cultureDictionaryFactory, globalSettings, umbracoContextAccessor, sqlContext, services, appCaches, logger, runtimeState, umbracoHelper) { _serializer = serializer; _propertyEditors = propertyEditors; _scopeProvider = scopeProvider; - _publishedModelFactory = publishedModelFactory; } public int GetCount() @@ -527,7 +525,7 @@ namespace Umbraco.Web.Editors } var dataInstaller = new PackageDataInstallation(Logger, Services.FileService, Services.MacroService, Services.LocalizationService, - Services.DataTypeService, Services.EntityService, Services.ContentTypeService, Services.ContentService, _propertyEditors, _scopeProvider, _publishedModelFactory); + Services.DataTypeService, Services.EntityService, Services.ContentTypeService, Services.ContentService, _propertyEditors, _scopeProvider); var xd = new XmlDocument {XmlResolver = null}; xd.Load(filePath); diff --git a/src/Umbraco.Web/PublishedCache/NuCache/PublishedSnapshotService.cs b/src/Umbraco.Web/PublishedCache/NuCache/PublishedSnapshotService.cs index 66cc5aaed0..15e6574b40 100755 --- a/src/Umbraco.Web/PublishedCache/NuCache/PublishedSnapshotService.cs +++ b/src/Umbraco.Web/PublishedCache/NuCache/PublishedSnapshotService.cs @@ -790,8 +790,6 @@ namespace Umbraco.Web.PublishedCache.NuCache Notify(_contentStore, payloads, RefreshContentTypesLocked); Notify(_mediaStore, payloads, RefreshMediaTypesLocked); - //TODO: I don't think this is necessary with the changes to nucache now that calls to `CreateModel` are lazy? - // but I may be dreaming here, if i remove this call and save a content type, then the cache doesn't render a lot of the content. hrm. if (_publishedModelFactory.IsLiveFactory()) { //In the case of Pure Live - we actually need to refresh all of the content and the media