From 36f79e7faa55f687c131f07b51100ae725669deb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arthur=20Parient=C3=A9?= <41431456+arthurpar06@users.noreply.github.com> Date: Fri, 24 May 2024 16:49:55 +0200 Subject: [PATCH] Create a console kernel instance before running webcron (#1810) --- app/Http/Controllers/Api/MaintenanceController.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/Http/Controllers/Api/MaintenanceController.php b/app/Http/Controllers/Api/MaintenanceController.php index c70f1dcab..a6f6eb0ec 100644 --- a/app/Http/Controllers/Api/MaintenanceController.php +++ b/app/Http/Controllers/Api/MaintenanceController.php @@ -3,6 +3,7 @@ namespace App\Http\Controllers\Api; use App\Console\Cron; +use App\Console\Kernel; use App\Contracts\Controller; use App\Exceptions\CronInvalid; use Illuminate\Http\JsonResponse; @@ -25,6 +26,15 @@ public function cron(Request $request, string $id): JsonResponse throw new CronInvalid(); } + // Create a console kernel instance + $consoleKernel = app()->make(Kernel::class); + + // Run a null artisan thing just so Laravel internals can be setup properly + $status = $consoleKernel->handle( + new \Symfony\Component\Console\Input\ArgvInput(), + new \Symfony\Component\Console\Output\NullOutput() + ); + $cron = app(Cron::class); $run = $cron->run();