jackwh/laravel-new-relic

Callback scheduled task causes fatal error

Opened this issue · 0 comments

It's possible to set scheduled task as callable class inside \App\Console\Kernel, like this:

    /**
     * Define the application's command schedule.
     *
     * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
     * @return void
     */
    protected function schedule(Schedule $schedule)
    {
        $schedule->call(new NotificationTask())->everyMinute();
    }

in this case calling artisan schedule:run fails with the error

  2023-07-06 10:43:26 Running [Callback] .......................................... 0ms FAIL

   TypeError 

  JackWH\LaravelNewRelic\NewRelicTransactionHandler::parseTaskCommand(): Argument #1 ($taskCommand) must be of type string, null given, called in /application/vendor/jackwh/laravel-new-relic/src/NewRelicTransactionHandler.php on line 205

  at vendor/jackwh/laravel-new-relic/src/NewRelicTransactionHandler.php:269
    265▕ 
    266▕     /**
    267▕      * Parse a command string for a scheduled task, returning it in a simplified format.
    268▕      */
  ➜ 269▕     protected function parseTaskCommand(string $taskCommand): string
    270▕     {
    271▕         $formattedCommand = Str::of($taskCommand)
    272▕             ->afterLast("'artisan' ")
    273▕             ->afterLast("artisan ")

      +20 vendor frames 

  21  artisan:35
      Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))