From 7eb2b9484daf26706074c89844144c0dce11dbec Mon Sep 17 00:00:00 2001 From: mortexa Date: Sat, 25 Mar 2023 18:29:41 +0330 Subject: [PATCH 1/2] Give new app instance to cache manager --- .../ProvidesDefaultConfigurationOptions.php | 1 + ...veNewApplicationInstanceToCacheManager.php | 23 +++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 src/Listeners/GiveNewApplicationInstanceToCacheManager.php diff --git a/src/Concerns/ProvidesDefaultConfigurationOptions.php b/src/Concerns/ProvidesDefaultConfigurationOptions.php index 0eb049196..f7d6bec7b 100644 --- a/src/Concerns/ProvidesDefaultConfigurationOptions.php +++ b/src/Concerns/ProvidesDefaultConfigurationOptions.php @@ -41,6 +41,7 @@ public static function prepareApplicationForNextOperation(): array \Laravel\Octane\Listeners\GiveNewApplicationInstanceToMailManager::class, \Laravel\Octane\Listeners\GiveNewApplicationInstanceToNotificationChannelManager::class, \Laravel\Octane\Listeners\GiveNewApplicationInstanceToPipelineHub::class, + \Laravel\Octane\Listeners\GiveNewApplicationInstanceToCacheManager::class, \Laravel\Octane\Listeners\GiveNewApplicationInstanceToQueueManager::class, \Laravel\Octane\Listeners\GiveNewApplicationInstanceToRouter::class, \Laravel\Octane\Listeners\GiveNewApplicationInstanceToValidationFactory::class, diff --git a/src/Listeners/GiveNewApplicationInstanceToCacheManager.php b/src/Listeners/GiveNewApplicationInstanceToCacheManager.php new file mode 100644 index 000000000..f2ba076b6 --- /dev/null +++ b/src/Listeners/GiveNewApplicationInstanceToCacheManager.php @@ -0,0 +1,23 @@ +sandbox->resolved('cache')) { + return; + } + + with($event->sandbox->make('cache'), function ($manager) use ($event) { + $manager->setApplication($event->sandbox); + }); + } +} From 7f13e5e6faa590905cdfdc387fbbaaf5d1ab692c Mon Sep 17 00:00:00 2001 From: mortexa Date: Sun, 26 Mar 2023 14:31:18 +0330 Subject: [PATCH 2/2] ensure `setApplication` method exists --- src/Listeners/GiveNewApplicationInstanceToCacheManager.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Listeners/GiveNewApplicationInstanceToCacheManager.php b/src/Listeners/GiveNewApplicationInstanceToCacheManager.php index f2ba076b6..cb6b3a7dd 100644 --- a/src/Listeners/GiveNewApplicationInstanceToCacheManager.php +++ b/src/Listeners/GiveNewApplicationInstanceToCacheManager.php @@ -17,7 +17,9 @@ public function handle($event): void } with($event->sandbox->make('cache'), function ($manager) use ($event) { - $manager->setApplication($event->sandbox); + if (method_exists($manager, 'setApplication')) { + $manager->setApplication($event->sandbox); + } }); } }