52 parent::__construct(
'RunJobs' );
53 $this->jobRunner = $jobRunner;
54 $this->readOnlyMode = $readOnlyMode;
64 if ( $this->readOnlyMode->isReadOnly() ) {
65 wfHttpError( 423,
'Locked',
'Wiki is in read-only mode.' );
71 wfHttpError( 400,
'Bad Request',
'Request must be POSTed.' );
76 $optional = [
'maxjobs' => 0,
'maxtime' => 30,
'type' =>
false,
77 'async' =>
true,
'stats' => false ];
78 $required = array_fill_keys( [
'title',
'tasks',
'signature',
'sigexpiry' ],
true );
79 $params = array_intersect_key( $this->
getRequest()->getValues(), $required + $optional );
80 $missing = array_diff_key( $required,
$params );
81 if ( count( $missing ) ) {
83 'Missing parameters: ' . implode(
', ', array_keys( $missing ) )
90 unset( $squery[
'signature'] );
93 $providedSignature =
$params[
'signature'];
94 $verified = is_string( $providedSignature )
95 && hash_equals( $correctSignature, $providedSignature );
96 if ( !$verified ||
$params[
'sigexpiry'] < time() ) {
97 wfHttpError( 400,
'Bad Request',
'Invalid or stale signature provided.' );
106 HttpStatus::header( 202 );
111 DeferredUpdates::addUpdate(
118 DeferredUpdates::POSTSEND
124 $this->
getRequest()->response()->header(
'Content-Type: application/json' );
125 print FormatJson::encode( $stats );
133 return $this->jobRunner->run( [
135 'maxJobs' =>
$params[
'maxjobs'] ?: 1,
136 'maxTime' =>
$params[
'maxtime'] ?: 30
147 return hash_hmac(
'sha1',
wfArrayToCgi( $query ), $secretKey );
155class_alias( SpecialRunJobs::class,
'SpecialRunJobs' );
wfHttpError( $code, $label, $desc)
Provide a simple HTTP error.
wfArrayToCgi( $array1, $array2=null, $prefix='')
This function takes one or two arrays as input, and returns a CGI-style string, e....
array $params
The job parameters.
Job queue runner utility methods.
A class containing constants representing the names of configuration variables.
const SecretKey
Name constant for the SecretKey setting, for use with Config::get()
getConfig()
Shortcut to get main config object.
getRequest()
Get the WebRequest being used for this instance.
getOutput()
Get the OutputPage being used for this instance.
Shortcut to construct a special page which is unlisted by default.