Support for PHP callables as worker callbacks

Created on 7 March 2024, 9 months ago
Updated 29 August 2024, 3 months ago

Problem/Motivation

Currently job scheduler specifies and requires the worker callback to be a function name.

PHP supports many other ways of specifying something that should be executed in addition to function names. As I see it the only thing that blocks using these other options is [the call to function_exists() when executing the worker callback](https://git.drupalcode.org/project/job_scheduler/-/blob/4.0.x/src/JobSch...).

PHP call_user_func() will accept any type of callable.

Steps to reproduce

Set up a job work a worker callback as a static function on a class e.g. "worker callback" => [MyClass::class, 'callback']

Proposed resolution

1. Change the call to function_exists() to is_callable()
2. Update the documentation

Remaining tasks

- If acceptable update the documentation accordingly.

User interface changes

None.

API changes

The worker callback property will now accept any type of callable.

Data model changes

None.

✨ Feature request
Status

Needs review

Version

4.0

Component

Code

Created by

πŸ‡©πŸ‡°Denmark kasperg

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024