* Use getCanonicalURL() to avoid links with the wrong host (e.g.
when it is virtual) and to avoid getting redirects.
* Also disable this setting when post-send execution is already
available, by default.
* Bump the socket timeout slightly.
Bug: T107290
Bug: T68485
Change-Id: I56c43193fa6583cc0c8209ff59cf20c986a799a3
* When $wgJobRunRate > 0, try to run jobs asynchronously, spawning a new process
* to handle the job execution, instead of blocking the request until the job
* execution finishes.
* When $wgJobRunRate > 0, try to run jobs asynchronously, spawning a new process
* to handle the job execution, instead of blocking the request until the job
* execution finishes.
+$wgRunJobsAsync = (
+ !function_exists( 'register_postsend_function' ) &&
+ !function_exists( 'fastcgi_finish_request' )
+);
/**
* Number of rows to update per job
/**
* Number of rows to update per job
*/
public function triggerJobs() {
$jobRunRate = $this->config->get( 'JobRunRate' );
*/
public function triggerJobs() {
$jobRunRate = $this->config->get( 'JobRunRate' );
- if ( $jobRunRate <= 0 || wfReadOnly() ) {
- return;
- } elseif ( $this->getTitle()->isSpecial( 'RunJobs' ) ) {
+ if ( $this->getTitle()->isSpecial( 'RunJobs' ) ) {
return; // recursion guard
return; // recursion guard
+ } elseif ( $jobRunRate <= 0 || wfReadOnly() ) {
+ return;
}
if ( $jobRunRate < 1 ) {
}
if ( $jobRunRate < 1 ) {
$query, $this->config->get( 'SecretKey' ) );
$errno = $errstr = null;
$query, $this->config->get( 'SecretKey' ) );
$errno = $errstr = null;
- $info = wfParseUrl( $this->config->get( 'Server' ) );
+ $info = wfParseUrl( $this->config->get( 'CanonicalServer' ) );
MediaWiki\suppressWarnings();
$host = $info['host'];
$port = 80;
MediaWiki\suppressWarnings();
$host = $info['host'];
$port = 80;
- $url = wfAppendQuery( wfScript( 'index' ), $query );
+ $special = SpecialPageFactory::getPage( 'RunJobs' );
+ $url = $special->getPageTitle()->getCanonicalURL( $query );
$req = (
"POST $url HTTP/1.1\r\n" .
"Host: {$info['host']}\r\n" .
$req = (
"POST $url HTTP/1.1\r\n" .
"Host: {$info['host']}\r\n" .
$runJobsLogger->info( "Running $n job(s) via '$url'" );
// Send a cron API request to be performed in the background.
// Give up if this takes too long to send (which should be rare).
$runJobsLogger->info( "Running $n job(s) via '$url'" );
// Send a cron API request to be performed in the background.
// Give up if this takes too long to send (which should be rare).
- stream_set_timeout( $sock, 1 );
+ stream_set_timeout( $sock, 2 );
$bytes = fwrite( $sock, $req );
if ( $bytes !== strlen( $req ) ) {
$runJobsLogger->error( "Failed to start cron API (socket write error)" );
$bytes = fwrite( $sock, $req );
if ( $bytes !== strlen( $req ) ) {
$runJobsLogger->error( "Failed to start cron API (socket write error)" );
public function execute( $par = '' ) {
$this->getOutput()->disable();
public function execute( $par = '' ) {
$this->getOutput()->disable();
if ( wfReadOnly() ) {
// HTTP 423 Locked
HttpStatus::header( 423 );
if ( wfReadOnly() ) {
// HTTP 423 Locked
HttpStatus::header( 423 );