X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fjobqueue%2FJob.php;h=703e48564bde225a03ffc85397dab88b8ddb7d99;hb=1ab510cfcabc2d431b3c0a28fdc896aff85487d4;hp=f814ceeb1b8b7440d1ae6437a10a96fb0da37eab;hpb=75d8b6c6cd2b70d98242e1246678c12e973a5dfa;p=lhc%2Fweb%2Fwiklou.git 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}'" );