X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fjobqueue%2FJob.php;h=703e48564bde225a03ffc85397dab88b8ddb7d99;hp=f814ceeb1b8b7440d1ae6437a10a96fb0da37eab;hb=12601ff7d2796752404bfb331fccc41083d31f9f;hpb=acf2e7603c4de9ebe42563292f9587b5f8808cf1 diff --git a/includes/jobqueue/Job.php b/includes/jobqueue/Job.php index f814ceeb1b..703e48564b 100644 --- a/includes/jobqueue/Job.php +++ b/includes/jobqueue/Job.php @@ -69,12 +69,22 @@ abstract class Job implements IJobSpecification { global $wgJobClasses; if ( isset( $wgJobClasses[$command] ) ) { - $class = $wgJobClasses[$command]; - - $job = new $class( $title, $params ); - $job->command = $command; + $handler = $wgJobClasses[$command]; + + if ( is_callable( $handler ) ) { + $job = call_user_func( $handler, $title, $params ); + } elseif ( class_exists( $handler ) ) { + $job = new $handler( $title, $params ); + } else { + $job = null; + } - return $job; + if ( $job instanceof Job ) { + $job->command = $command; + return $job; + } else { + throw new InvalidArgumentException( "Cannot instantiate job '$command': bad spec!" ); + } } throw new InvalidArgumentException( "Invalid job command '{$command}'" );