From 1c952023e1cd8cf119db296c850d626a525e2134 Mon Sep 17 00:00:00 2001 From: Marius Date: Sun, 5 Nov 2023 11:41:13 +0200 Subject: [PATCH] Execute the bootstrappers in reverse order when reverting to central context Bootstrappers order may be relevant in specific cases. For example, when a custom bootstrapper queries the tenant database, it will be placed after the Database bootstrapper and must be reverted before the database connection is reverted back to central. --- src/Listeners/RevertToCentralContext.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Listeners/RevertToCentralContext.php b/src/Listeners/RevertToCentralContext.php index 788e38760..cac48c571 100644 --- a/src/Listeners/RevertToCentralContext.php +++ b/src/Listeners/RevertToCentralContext.php @@ -14,7 +14,7 @@ public function handle(TenancyEnded $event) { event(new RevertingToCentralContext($event->tenancy)); - foreach ($event->tenancy->getBootstrappers() as $bootstrapper) { + foreach (array_reverse($event->tenancy->getBootstrappers()) as $bootstrapper) { $bootstrapper->revert(); }