48 parent::__construct(
'RunJobs' );
49 $this->jobRunner = $jobRunner;
50 $this->readOnlyMode = $readOnlyMode;
60 if ( $this->readOnlyMode->isReadOnly() ) {
61 wfHttpError( 423,
'Locked',
'Wiki is in read-only mode.' );
67 wfHttpError( 400,
'Bad Request',
'Request must be POSTed.' );
72 $optional = [
'maxjobs' => 0,
'maxtime' => 30,
'type' =>
false,
73 'async' =>
true,
'stats' => false ];
74 $required = array_fill_keys( [
'title',
'tasks',
'signature',
'sigexpiry' ],
true );
75 $params = array_intersect_key( $this->
getRequest()->getValues(), $required + $optional );
76 $missing = array_diff_key( $required,
$params );
77 if ( count( $missing ) ) {
79 'Missing parameters: ' . implode(
', ', array_keys( $missing ) )
86 unset( $squery[
'signature'] );
89 $providedSignature =
$params[
'signature'];
90 $verified = is_string( $providedSignature )
91 && hash_equals( $correctSignature, $providedSignature );
92 if ( !$verified ||
$params[
'sigexpiry'] < time() ) {
93 wfHttpError( 400,
'Bad Request',
'Invalid or stale signature provided.' );
102 HttpStatus::header( 202 );
107 DeferredUpdates::addUpdate(
114 DeferredUpdates::POSTSEND
120 $this->
getRequest()->response()->header(
'Content-Type: application/json' );
121 print FormatJson::encode( $stats );
129 return $this->jobRunner->run( [
131 'maxJobs' =>
$params[
'maxjobs'] ?: 1,
132 'maxTime' =>
$params[
'maxtime'] ?: 30
143 return hash_hmac(
'sha1',
wfArrayToCgi( $query ), $secretKey );
151class_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.