diff --git a/src/Umbraco.Core/ObjectResolution/LazyManyObjectsResolverbase.cs b/src/Umbraco.Core/ObjectResolution/LazyManyObjectsResolverbase.cs index 016a9c8f11..f2223d338e 100644 --- a/src/Umbraco.Core/ObjectResolution/LazyManyObjectsResolverbase.cs +++ b/src/Umbraco.Core/ObjectResolution/LazyManyObjectsResolverbase.cs @@ -49,6 +49,7 @@ namespace Umbraco.Core.ObjectResolution /// Initializes a new instance of the class with an initial list /// If is per HttpRequest then there must be a current HttpContext. /// is per HttpRequest but the current HttpContext is null. + /// protected LazyManyObjectsResolverBase(IEnumerable> lazyTypeList, ObjectLifetimeScope scope = ObjectLifetimeScope.Application) : this(scope) { @@ -108,7 +109,7 @@ namespace Umbraco.Core.ObjectResolution /// Gets a value indicating whether the resolver has resolved types to create instances from. /// /// To be used in unit tests. - internal bool HasResolvedTypes + public bool HasResolvedTypes { get { diff --git a/src/Umbraco.Core/PluginManager.cs b/src/Umbraco.Core/PluginManager.cs index 2f0f7fcec6..d03edc0fc6 100644 --- a/src/Umbraco.Core/PluginManager.cs +++ b/src/Umbraco.Core/PluginManager.cs @@ -44,9 +44,9 @@ namespace Umbraco.Core /// file is cached temporarily until app startup completes. /// /// - /// - internal PluginManager(ApplicationContext appContext, bool detectBinChanges = true) - : this(detectBinChanges) + /// + internal PluginManager(ApplicationContext appContext, bool detectChanges = true) + : this(detectChanges) { if (appContext == null) throw new ArgumentNullException("appContext"); _appContext = appContext; @@ -55,11 +55,11 @@ namespace Umbraco.Core /// /// Creates a new PluginManager /// - /// - /// If true will detect changes in the /bin folder and therefor load plugins from the + /// + /// If true will detect changes in the /bin folder, app_code, etc... and therefor load plugins from the /// cached plugins file if one is found. If false will never use the cache file for plugins /// - internal PluginManager(bool detectCodeChanges = true) + internal PluginManager(bool detectChanges = true) { _tempFolder = IOHelper.MapPath("~/App_Data/TEMP/PluginCache"); //create the folder if it doesn't exist @@ -68,29 +68,41 @@ namespace Umbraco.Core Directory.CreateDirectory(_tempFolder); } + var pluginListFile = GetPluginListFilePath(); + //this is a check for legacy changes, before we didn't store the TypeResolutionKind in the file which was a mistake, //so we need to detect if the old file is there without this attribute, if it is then we delete it if (DetectLegacyPluginListFile()) { - var filePath = GetPluginListFilePath(); - File.Delete(filePath); + File.Delete(pluginListFile); } - if (detectCodeChanges) + if (detectChanges) { //first check if the cached hash is 0, if it is then we ne //do the check if they've changed - HaveAssembliesChanged = (CachedAssembliesHash != CurrentAssembliesHash) || CachedAssembliesHash == 0; + RequiresRescanning = (CachedAssembliesHash != CurrentAssembliesHash) || CachedAssembliesHash == 0; //if they have changed, we need to write the new file - if (HaveAssembliesChanged) + if (RequiresRescanning) { + //if the hash has changed, clear out the persisted list no matter what, this will force + // rescanning of all plugin types including lazy ones. + // http://issues.umbraco.org/issue/U4-4789 + File.Delete(pluginListFile); + WriteCachePluginsHash(); } } else { + + //if the hash has changed, clear out the persisted list no matter what, this will force + // rescanning of all plugin types including lazy ones. + // http://issues.umbraco.org/issue/U4-4789 + File.Delete(pluginListFile); + //always set to true if we're not detecting (generally only for testing) - HaveAssembliesChanged = true; + RequiresRescanning = true; } } @@ -130,9 +142,9 @@ namespace Umbraco.Core /// - /// Returns a bool if the assemblies in the /bin have changed since they were last hashed. + /// Returns a bool if the assemblies in the /bin, app_code, global.asax, etc... have changed since they were last hashed. /// - internal bool HaveAssembliesChanged { get; private set; } + internal bool RequiresRescanning { get; private set; } /// /// Returns the currently cached hash value of the scanned assemblies in the /bin folder. Returns 0 @@ -328,7 +340,7 @@ namespace Umbraco.Core /// /// Generally only used for resetting cache, for example during the install process /// - internal void ClearPluginCache() + public void ClearPluginCache() { var path = GetPluginListFilePath(); if (File.Exists(path)) @@ -670,7 +682,7 @@ namespace Umbraco.Core //we first need to look into our cache file (this has nothing to do with the 'cacheResult' parameter which caches in memory). //if assemblies have not changed and the cache file actually exists, then proceed to try to lookup by the cache file. - if (HaveAssembliesChanged == false && File.Exists(GetPluginListFilePath())) + if (RequiresRescanning == false && File.Exists(GetPluginListFilePath())) { var fileCacheResult = TryGetCachedPluginsFromFile(resolutionType);