Skip to content

Commit

Permalink
Update detection of closure-based scheduled tasks
Browse files Browse the repository at this point in the history
Use Str to check for empty commands, which will account for the command being null or an empty string.

Also add check for the closure summaryForDisplay output being one of either `Closure` or `Callback`, which was added to support PHP 8

@see laravel/framework#34999
  • Loading branch information
michaeldyrynda committed Nov 17, 2020
1 parent 0e3ba48 commit df85258
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/TaskIdentifier.php
Expand Up @@ -19,11 +19,11 @@ class TaskIdentifier
public function __invoke($task)
{
if ($task instanceof CallbackEvent) {
if (is_null($task->command) && $task->description && class_exists($task->description)) {
if (Str::of($task->command)->isEmpty() && $task->description && class_exists($task->description)) {
return static::TYPE_JOB;
}

if (is_null($task->command) && Str::is($task->description, $task->getSummaryForDisplay())) {
if (Str::of($task->command)->isEmpty() && Str::is($task->description, $task->getSummaryForDisplay())) {
return static::TYPE_CLOSURE;
}

Expand All @@ -41,7 +41,7 @@ public function __invoke($task)
}
}

private function sanitisedCommand(string $command): string
private function sanitisedCommand(?string $command): string
{
return trim(str_replace([
"'",
Expand Down

0 comments on commit df85258

Please sign in to comment.