Restored order of operations on scope dispose to that used in Umbraco 11 before refactor into Scope inheriting CoreScope. (#14573)

This commit is contained in:
Andy Butland
2023-07-18 12:57:09 +02:00
committed by GitHub
parent dad49b846f
commit d1aac3964c
2 changed files with 17 additions and 10 deletions

View File

@@ -231,7 +231,7 @@ public class CoreScope : ICoreScope
}
}
private void HandleScopedFileSystems()
protected void HandleScopedFileSystems()
{
if (_shouldScopeFileSystems == true)
{
@@ -250,7 +250,7 @@ public class CoreScope : ICoreScope
_parentScope = coreScope;
}
private void HandleScopedNotifications() => _notificationPublisher?.ScopeExit(Completed.HasValue && Completed.Value);
protected void HandleScopedNotifications() => _notificationPublisher?.ScopeExit(Completed.HasValue && Completed.Value);
private void EnsureNotDisposed()
{

View File

@@ -357,7 +357,7 @@ namespace Umbraco.Cms.Infrastructure.Scoping
}
}
public void Dispose()
public override void Dispose()
{
EnsureNotDisposed();
@@ -402,16 +402,21 @@ namespace Umbraco.Cms.Infrastructure.Scoping
Completed = true;
}
if (ParentScope != null)
{
ParentScope.ChildCompleted(Completed);
}
else
// CoreScope.Dispose will handle file systems and notifications, as well as notifying any parent scope of the child scope's completion.
// In this overridden class, we re-use that functionality and also handle scope context (including enlisted actions) and detached scopes.
// We retain order of events behaviour from Umbraco 11:
// - handle file systems (in CoreScope)
// - handle scoped notifications (in CoreScope)
// - handle scope context (in Scope)
// - handle detatched scopes (in Scope)
if (ParentScope is null)
{
DisposeLastScope();
}
base.Dispose();
else
{
ParentScope.ChildCompleted(Completed);
}
_disposed = true;
}
@@ -559,6 +564,8 @@ namespace Umbraco.Cms.Infrastructure.Scoping
}
TryFinally(
HandleScopedFileSystems,
HandleScopedNotifications,
HandleScopeContext,
HandleDetachedScopes);
}