Go to the documentation of this file.
33 parent::__construct(
'RunJobs' );
44 wfHttpError( 423,
'Locked',
'Wiki is in read-only mode.' );
50 wfHttpError( 400,
'Bad Request',
'Request must be POSTed.' );
55 $optional = [
'maxjobs' => 0,
'maxtime' => 30,
'type' =>
false,
56 'async' =>
true,
'stats' => false ];
57 $required = array_flip( [
'title',
'tasks',
'signature',
'sigexpiry' ] );
58 $params = array_intersect_key( $this->
getRequest()->getValues(), $required + $optional );
59 $missing = array_diff_key( $required, $params );
60 if ( count( $missing ) ) {
62 'Missing parameters: ' . implode(
', ', array_keys( $missing ) )
69 unset( $squery[
'signature'] );
71 $providedSignature = $params[
'signature'];
72 $verified = is_string( $providedSignature )
73 && hash_equals( $correctSignature, $providedSignature );
74 if ( !$verified || $params[
'sigexpiry'] < time() ) {
75 wfHttpError( 400,
'Bad Request',
'Invalid or stale signature provided.' );
82 if ( $params[
'async'] ) {
91 function () use ( $params ) {
92 $this->
doRun( $params );
99 $stats = $this->
doRun( $params );
101 if ( $params[
'stats'] ) {
102 $this->
getRequest()->response()->header(
'Content-Type: application/json' );
110 protected function doRun( array $params ) {
111 $runner =
new JobRunner( LoggerFactory::getInstance(
'runJobs' ) );
112 return $runner->run( [
113 'type' => $params[
'type'],
114 'maxJobs' => $params[
'maxjobs'] ?: 1,
115 'maxTime' => $params[
'maxtime'] ?: 30
126 return hash_hmac(
'sha1',
wfArrayToCgi( $query ), $secretKey );
getOutput()
Get the OutputPage being used for this instance.
Shortcut to construct a special page which is unlisted by default.
static addUpdate(DeferrableUpdate $update, $stage=self::POSTSEND)
Add an update to the deferred list to be run later by execute()
static getQuerySignature(array $query, $secretKey)
wfReadOnly()
Check whether the wiki is in read-only mode.
getConfig()
Shortcut to get main config object.
getRequest()
Get the WebRequest being used for this instance.
doesWrites()
Indicates whether this special page may perform database writes.
wfHttpError( $code, $label, $desc)
Provide a simple HTTP error.
static header( $code)
Output an HTTP status code header.
Deferrable update that must run outside of any explicit LBFactory transaction round.
Special page designed for running background tasks (internal use only)
execute( $par='')
Default execute method Checks user permissions.
Job queue runner utility methods.
wfArrayToCgi( $array1, $array2=null, $prefix='')
This function takes one or two arrays as input, and returns a CGI-style string, e....