Siebrand has uploaded a new change for review.
https://gerrit.wikimedia.org/r/97509
Change subject: Update formatting of job related files
......................................................................
Update formatting of job related files
Change-Id: I634c26061f0ac1231647a9062b6cea01b77136bd
---
M includes/job/Job.php
M includes/job/JobQueue.php
M includes/job/JobQueueDB.php
M includes/job/JobQueueFederated.php
M includes/job/JobQueueGroup.php
M includes/job/JobQueueRedis.php
M includes/job/aggregator/JobQueueAggregator.php
M includes/job/aggregator/JobQueueAggregatorMemc.php
M includes/job/aggregator/JobQueueAggregatorRedis.php
M includes/job/jobs/AssembleUploadChunksJob.php
M includes/job/jobs/DoubleRedirectJob.php
M includes/job/jobs/DuplicateJob.php
M includes/job/jobs/EmaillingJob.php
M includes/job/jobs/EnotifNotifyJob.php
M includes/job/jobs/HTMLCacheUpdateJob.php
M includes/job/jobs/NullJob.php
M includes/job/jobs/PublishStashedFileJob.php
M includes/job/jobs/RefreshLinksJob.php
M includes/job/jobs/UploadFromUrlJob.php
19 files changed, 175 insertions(+), 47 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/09/97509/1
diff --git a/includes/job/Job.php b/includes/job/Job.php
index ab7df5d..0359540 100644
--- a/includes/job/Job.php
+++ b/includes/job/Job.php
@@ -70,6 +70,7 @@
global $wgJobClasses;
if ( isset( $wgJobClasses[$command] ) ) {
$class = $wgJobClasses[$command];
+
return new $class( $title, $params, $id );
}
throw new MWException( "Invalid job command `{$command}`" );
@@ -225,6 +226,7 @@
// Likewise for jobs with different delay times
unset( $info['params']['jobReleaseTimestamp'] );
}
+
return $info;
}
@@ -305,6 +307,7 @@
if ( $paramString !== '' ) {
$s .= ' ' . $paramString;
}
+
return $s;
} else {
return "{$this->command} $paramString";
diff --git a/includes/job/JobQueue.php b/includes/job/JobQueue.php
index 6556ee8..b8a612c 100644
--- a/includes/job/JobQueue.php
+++ b/includes/job/JobQueue.php
@@ -106,6 +106,7 @@
if ( !( $obj instanceof self ) ) {
throw new MWException( "Class '$class' is not a " .
__CLASS__ . " class." );
}
+
return $obj;
}
@@ -177,6 +178,7 @@
wfProfileIn( __METHOD__ );
$res = $this->doIsEmpty();
wfProfileOut( __METHOD__ );
+
return $res;
}
@@ -199,6 +201,7 @@
wfProfileIn( __METHOD__ );
$res = $this->doGetSize();
wfProfileOut( __METHOD__ );
+
return $res;
}
@@ -221,6 +224,7 @@
wfProfileIn( __METHOD__ );
$res = $this->doGetAcquiredCount();
wfProfileOut( __METHOD__ );
+
return $res;
}
@@ -244,6 +248,7 @@
wfProfileIn( __METHOD__ );
$res = $this->doGetDelayedCount();
wfProfileOut( __METHOD__ );
+
return $res;
}
@@ -268,6 +273,7 @@
wfProfileIn( __METHOD__ );
$res = $this->doGetAbandonedCount();
wfProfileOut( __METHOD__ );
+
return $res;
}
@@ -321,6 +327,7 @@
wfProfileIn( __METHOD__ );
$ok = $this->doBatchPush( $jobs, $flags );
wfProfileOut( __METHOD__ );
+
return $ok;
}
@@ -358,7 +365,9 @@
JobQueue::incrStats( 'job-pop-duplicate',
$this->type );
$job = DuplicateJob::newFromJob( $job ); //
convert to a no-op
}
- } catch ( MWException $e ) {} // don't lose jobs over this
+ } catch ( MWException $e ) {
+ // don't lose jobs over this
+ }
return $job;
}
@@ -386,6 +395,7 @@
wfProfileIn( __METHOD__ );
$ok = $this->doAck( $job );
wfProfileOut( __METHOD__ );
+
return $ok;
}
@@ -433,6 +443,7 @@
wfProfileIn( __METHOD__ );
$ok = $this->doDeduplicateRootJob( $job );
wfProfileOut( __METHOD__ );
+
return $ok;
}
@@ -476,6 +487,7 @@
wfProfileIn( __METHOD__ );
$isDuplicate = $this->doIsRootJobOldDuplicate( $job );
wfProfileOut( __METHOD__ );
+
return $isDuplicate;
}
@@ -504,6 +516,7 @@
*/
protected function getRootJobCacheKey( $signature ) {
list( $db, $prefix ) = wfSplitWikiID( $this->wiki );
+
return wfForeignMemcKey( $db, $prefix, 'jobqueue', $this->type,
'rootjob', $signature );
}
@@ -518,6 +531,7 @@
wfProfileIn( __METHOD__ );
$res = $this->doDelete();
wfProfileOut( __METHOD__ );
+
return $res;
}
@@ -547,7 +561,8 @@
* @see JobQueue::waitForBackups()
* @return void
*/
- protected function doWaitForBackups() {}
+ protected function doWaitForBackups() {
+ }
/**
* Return a map of task names to task definition maps.
@@ -566,6 +581,7 @@
foreach ( $tasks as $name => &$def ) {
$def['name'] = $name;
}
+
return $tasks;
}
@@ -592,7 +608,8 @@
* @see JobQueue::flushCaches()
* @return void
*/
- protected function doFlushCaches() {}
+ protected function doFlushCaches() {
+ }
/**
* Get an iterator to traverse over all available jobs in this queue.
@@ -637,6 +654,7 @@
*/
final public function getSiblingQueuesWithJobs( array $types ) {
$section = new ProfileSection( __METHOD__ );
+
return $this->doGetSiblingQueuesWithJobs( $types );
}
@@ -661,6 +679,7 @@
*/
final public function getSiblingQueueSizes( array $types ) {
$section = new ProfileSection( __METHOD__ );
+
return $this->doGetSiblingQueueSizes( $types );
}
@@ -702,5 +721,8 @@
* @ingroup JobQueue
* @since 1.22
*/
-class JobQueueError extends MWException {}
-class JobQueueConnectionError extends JobQueueError {}
+class JobQueueError extends MWException {
+}
+
+class JobQueueConnectionError extends JobQueueError {
+}
diff --git a/includes/job/JobQueueDB.php b/includes/job/JobQueueDB.php
index c39083d..59d3de1 100644
--- a/includes/job/JobQueueDB.php
+++ b/includes/job/JobQueueDB.php
@@ -198,7 +198,7 @@
$that = $this;
$method = __METHOD__;
$dbw->onTransactionIdle(
- function() use ( $dbw, $that, $jobs, $flags, $method ) {
+ function () use ( $dbw, $that, $jobs, $flags, $method )
{
$that->doBatchPushInternal( $dbw, $jobs,
$flags, $method );
}
);
@@ -289,7 +289,7 @@
$dbw->commit( __METHOD__, 'flush' ); // flush existing
transaction
$autoTrx = $dbw->getFlag( DBO_TRX ); // get current
setting
$dbw->clearFlag( DBO_TRX ); // make each query its own
transaction
- $scopedReset = new ScopedCallback( function() use (
$dbw, $autoTrx ) {
+ $scopedReset = new ScopedCallback( function () use (
$dbw, $autoTrx ) {
$dbw->setFlag( $autoTrx ? DBO_TRX : 0 ); //
restore old setting
} );
@@ -485,7 +485,7 @@
$dbw->commit( __METHOD__, 'flush' ); // flush existing
transaction
$autoTrx = $dbw->getFlag( DBO_TRX ); // get current
setting
$dbw->clearFlag( DBO_TRX ); // make each query its own
transaction
- $scopedReset = new ScopedCallback( function() use (
$dbw, $autoTrx ) {
+ $scopedReset = new ScopedCallback( function () use (
$dbw, $autoTrx ) {
$dbw->setFlag( $autoTrx ? DBO_TRX : 0 ); //
restore old setting
} );
@@ -520,7 +520,7 @@
// jobs to become no-ops without any actual jobs that made them
redundant.
$dbw = $this->getMasterDB();
$cache = $this->dupCache;
- $dbw->onTransactionIdle( function() use ( $cache, $params,
$key, $dbw ) {
+ $dbw->onTransactionIdle( function () use ( $cache, $params,
$key, $dbw ) {
$timestamp = $cache->get( $key ); // current last
timestamp of this job
if ( $timestamp && $timestamp >=
$params['rootJobTimestamp'] ) {
return true; // a newer version of this root
job was enqueued
@@ -544,6 +544,7 @@
} catch ( DBError $e ) {
$this->throwDBException( $e );
}
+
return true;
}
@@ -586,7 +587,7 @@
return new MappedIterator(
$dbr->select( 'job', '*',
array( 'job_cmd' => $this->getType(),
'job_token' => '' ) ),
- function( $row ) use ( $dbr ) {
+ function ( $row ) use ( $dbr ) {
$job = Job::factory(
$row->job_cmd,
Title::makeTitle(
$row->job_namespace, $row->job_title ),
@@ -618,6 +619,7 @@
foreach ( $res as $row ) {
$types[] = $row->job_cmd;
}
+
return $types;
}
@@ -630,6 +632,7 @@
foreach ( $res as $row ) {
$sizes[$row->job_cmd] = (int)$row->count;
}
+
return $sizes;
}
@@ -663,7 +666,7 @@
__METHOD__
);
$ids = array_map(
- function( $o ) {
+ function ( $o ) {
return $o->job_id;
}, iterator_to_array( $res )
);
@@ -699,7 +702,7 @@
// the IDs first means that the UPDATE can be done by
primary key (less deadlocks).
$res = $dbw->select( 'job', 'job_id', $conds,
__METHOD__ );
$ids = array_map(
- function( $o ) {
+ function ( $o ) {
return $o->job_id;
}, iterator_to_array( $res )
);
@@ -723,20 +726,21 @@
*/
protected function insertFields( Job $job ) {
$dbw = $this->getMasterDB();
+
return array(
// Fields that describe the nature of the job
- 'job_cmd' => $job->getType(),
+ 'job_cmd' => $job->getType(),
'job_namespace' => $job->getTitle()->getNamespace(),
- 'job_title' => $job->getTitle()->getDBkey(),
- 'job_params' => self::makeBlob( $job->getParams() ),
+ 'job_title' => $job->getTitle()->getDBkey(),
+ 'job_params' => self::makeBlob( $job->getParams() ),
// Additional job metadata
- 'job_id' => $dbw->nextSequenceValue(
'job_job_id_seq' ),
+ 'job_id' => $dbw->nextSequenceValue( 'job_job_id_seq' ),
'job_timestamp' => $dbw->timestamp(),
- 'job_sha1' => wfBaseConvert(
+ 'job_sha1' => wfBaseConvert(
sha1( serialize( $job->getDeduplicationInfo() )
),
16, 36, 31
),
- 'job_random' => mt_rand( 0, self::MAX_JOB_RANDOM )
+ 'job_random' => mt_rand( 0, self::MAX_JOB_RANDOM )
);
}
@@ -770,6 +774,7 @@
$lb = ( $this->cluster !== false )
? wfGetLBFactory()->getExternalLB( $this->cluster,
$this->wiki )
: wfGetLB( $this->wiki );
+
return $lb->getConnectionRef( $index, array(), $this->wiki );
}
@@ -779,6 +784,7 @@
private function getCacheKey( $property ) {
list( $db, $prefix ) = wfSplitWikiID( $this->wiki );
$cluster = is_string( $this->cluster ) ? $this->cluster :
'main';
+
return wfForeignMemcKey( $db, $prefix, 'jobqueue', $cluster,
$this->type, $property );
}
diff --git a/includes/job/JobQueueFederated.php
b/includes/job/JobQueueFederated.php
index 36f4959..f598d29 100644
--- a/includes/job/JobQueueFederated.php
+++ b/includes/job/JobQueueFederated.php
@@ -49,14 +49,17 @@
class JobQueueFederated extends JobQueue {
/** @var Array (partition name => weight) reverse sorted by weight */
protected $partitionMap = array();
+
/** @var Array (partition name => JobQueue) reverse sorted by weight */
protected $partitionQueues = array();
+
/** @var HashRing */
protected $partitionPushRing;
+
/** @var BagOStuff */
protected $cache;
- protected $maxPartitionsTry; // integer; maximum number of partitions
to try
+ protected $maxPartitionsTry; // integer; maximum number of partitions
to try
const CACHE_TTL_SHORT = 30; // integer; seconds to cache info without
re-validating
const CACHE_TTL_LONG = 300; // integer; seconds to cache info that is
kept up to date
@@ -104,8 +107,8 @@
// Get the config to pass to merge into each partition queue
config
$baseConfig = $params;
foreach ( array( 'class', 'sectionsByWiki', 'maxPartitionsTry',
- 'partitionsBySection', 'configByPartition',
'partitionsNoPush' ) as $o )
- {
+ 'partitionsBySection', 'configByPartition',
'partitionsNoPush' ) as $o
+ ) {
unset( $baseConfig[$o] ); // partition queue doesn't
care about this
}
// Get the partition queue objects
@@ -149,6 +152,7 @@
try {
if ( !$queue->doIsEmpty() ) {
$this->cache->add( $key, 'false',
self::CACHE_TTL_LONG );
+
return false;
}
} catch ( JobQueueError $e ) {
@@ -157,6 +161,7 @@
}
$this->cache->add( $key, 'true', self::CACHE_TTL_LONG );
+
return true;
}
@@ -199,6 +204,7 @@
}
$this->cache->set( $key, $count, self::CACHE_TTL_SHORT );
+
return $count;
}
@@ -215,6 +221,7 @@
throw new JobQueueError(
"Could not insert job(s),
{$this->maxPartitionsTry} partitions tried." );
}
+
return true;
}
@@ -318,6 +325,7 @@
}
if ( $job ) {
$job->metadata['QueuePartition'] = $partition;
+
return $job;
} else {
unset( $partitionsTry[$partition] ); //
blacklist partition
@@ -325,6 +333,7 @@
}
$this->cache->set( $key, 'true', JobQueueDB::CACHE_TTL_LONG );
+
return false;
}
@@ -332,6 +341,7 @@
if ( !isset( $job->metadata['QueuePartition'] ) ) {
throw new MWException( "The given job has no defined
partition name." );
}
+
return
$this->partitionQueues[$job->metadata['QueuePartition']]->ack( $job );
}
@@ -345,6 +355,7 @@
return
$this->partitionQueues[$partitions[1]]->doIsRootJobOldDuplicate( $job );
}
}
+
return false;
}
@@ -358,6 +369,7 @@
return
$this->partitionQueues[$partitions[1]]->doDeduplicateRootJob( $job );
}
}
+
return false;
}
@@ -388,6 +400,7 @@
$tasks["{$partition}:{$task}"] = $def;
}
}
+
return $tasks;
}
@@ -412,6 +425,7 @@
foreach ( $this->partitionQueues as $queue ) {
$iterator->append( $queue->getAllQueuedJobs() );
}
+
return $iterator;
}
@@ -420,6 +434,7 @@
foreach ( $this->partitionQueues as $queue ) {
$iterator->append( $queue->getAllDelayedJobs() );
}
+
return $iterator;
}
@@ -445,6 +460,7 @@
MWExceptionHandler::logException( $e );
}
}
+
return array_values( $result );
}
@@ -464,6 +480,7 @@
MWExceptionHandler::logException( $e );
}
}
+
return $result;
}
@@ -478,6 +495,7 @@
*/
private function getCacheKey( $property ) {
list( $db, $prefix ) = wfSplitWikiID( $this->wiki );
+
return wfForeignMemcKey( $db, $prefix, 'jobqueue', $this->type,
$property );
}
}
diff --git a/includes/job/JobQueueGroup.php b/includes/job/JobQueueGroup.php
index fa7fee5..70820d5 100644
--- a/includes/job/JobQueueGroup.php
+++ b/includes/job/JobQueueGroup.php
@@ -66,6 +66,7 @@
if ( !isset( self::$instances[$wiki] ) ) {
self::$instances[$wiki] = new self( $wiki );
}
+
return self::$instances[$wiki];
}
@@ -157,6 +158,7 @@
if ( !$job ) {
JobQueueAggregator::singleton()->notifyQueueEmpty( $this->wiki, $qtype );
}
+
return $job;
} else { // any job in the "default" jobs types
if ( $flags & self::USE_CACHE ) {
@@ -269,6 +271,7 @@
}
}
}
+
return $types;
}
@@ -289,6 +292,7 @@
}
}
}
+
return $sizeMap;
}
@@ -339,8 +343,10 @@
// later jobs have not been done yet. This helps
throttle queue spam.
$deprioritized = !$this->get( 'refreshLinks'
)->isEmpty();
$this->cache->set( 'isDeprioritized', $type,
$deprioritized );
+
return $deprioritized;
}
+
return false;
}
@@ -368,8 +374,8 @@
if ( $definition['period'] <= 0 ) {
continue; // disabled
} elseif ( !isset( $lastRuns[$type][$task] )
- || $lastRuns[$type][$task] < ( time() -
$definition['period'] ) )
- {
+ || $lastRuns[$type][$task] < ( time() -
$definition['period'] )
+ ) {
try {
if ( call_user_func(
$definition['callback'] ) !== null ) {
$tasksRun[$type][$task]
= time();
@@ -382,13 +388,13 @@
}
}
- $wgMemc->merge( $key, function( $cache, $key, $lastRuns ) use (
$tasksRun ) {
+ $wgMemc->merge( $key, function ( $cache, $key, $lastRuns ) use
( $tasksRun ) {
if ( is_array( $lastRuns ) ) {
foreach ( $tasksRun as $type => $tasks ) {
foreach ( $tasks as $task => $timestamp
) {
if ( !isset(
$lastRuns[$type][$task] )
- || $timestamp >
$lastRuns[$type][$task] )
- {
+ || $timestamp >
$lastRuns[$type][$task]
+ ) {
$lastRuns[$type][$task]
= $timestamp;
}
}
@@ -396,6 +402,7 @@
} else {
$lastRuns = $tasksRun;
}
+
return $lastRuns;
} );
@@ -420,6 +427,7 @@
} else {
$value = $wgConf->getConfig( $this->wiki, $name
);
$wgMemc->set( $key, array( 'v' => $value ),
86400 + mt_rand( 0, 86400 ) );
+
return $value;
}
}
diff --git a/includes/job/JobQueueRedis.php b/includes/job/JobQueueRedis.php
index 67bb5a4..3bed28e 100644
--- a/includes/job/JobQueueRedis.php
+++ b/includes/job/JobQueueRedis.php
@@ -134,6 +134,7 @@
$conn->multi( Redis::PIPELINE );
$conn->zSize( $this->getQueueKey( 'z-claimed' ) );
$conn->zSize( $this->getQueueKey( 'z-abandoned' ) );
+
return array_sum( $conn->exec() );
} catch ( RedisException $e ) {
$this->throwRedisException( $this->server, $conn, $e );
@@ -217,6 +218,7 @@
}
if ( $failed > 0 ) {
wfDebugLog( 'JobQueueRedis', "Could not insert
{$failed} {$this->type} job(s)." );
+
return false;
}
JobQueue::incrStats( 'job-insert', $this->type, count(
$items ) );
@@ -428,12 +430,14 @@
if ( !$res ) {
wfDebugLog( 'JobQueueRedis', "Could not
acknowledge {$this->type} job." );
+
return false;
}
} catch ( RedisException $e ) {
$this->throwRedisException( $this->server,
$conn, $e );
}
}
+
return true;
}
@@ -457,6 +461,7 @@
if ( $timestamp && $timestamp >=
$params['rootJobTimestamp'] ) {
return true; // a newer version of this root
job was enqueued
}
+
// Update the timestamp of the last root job started at
the location...
return $conn->set( $key, $params['rootJobTimestamp'],
self::ROOTJOB_TTL ); // 2 weeks
} catch ( RedisException $e ) {
@@ -501,6 +506,7 @@
foreach ( $props as $prop ) {
$keys[] = $this->getQueueKey( $prop );
}
+
return ( $conn->delete( $keys ) !== false );
} catch ( RedisException $e ) {
$this->throwRedisException( $this->server, $conn, $e );
@@ -515,12 +521,15 @@
$conn = $this->getConnection();
try {
$that = $this;
+
return new MappedIterator(
$conn->lRange( $this->getQueueKey(
'l-unclaimed' ), 0, -1 ),
- function( $uid ) use ( $that, $conn ) {
+ function ( $uid ) use ( $that, $conn ) {
return $that->getJobFromUidInternal(
$uid, $conn );
},
- array( 'accept' => function ( $job ) { return
is_object( $job ); } )
+ array( 'accept' => function ( $job ) {
+ return is_object( $job );
+ } )
);
} catch ( RedisException $e ) {
$this->throwRedisException( $this->server, $conn, $e );
@@ -535,12 +544,15 @@
$conn = $this->getConnection();
try {
$that = $this;
+
return new MappedIterator( // delayed jobs
$conn->zRange( $this->getQueueKey( 'z-delayed'
), 0, -1 ),
- function( $uid ) use ( $that, $conn ) {
+ function ( $uid ) use ( $that, $conn ) {
return $that->getJobFromUidInternal(
$uid, $conn );
},
- array( 'accept' => function ( $job ) { return
is_object( $job ); } )
+ array( 'accept' => function ( $job ) {
+ return is_object( $job );
+ } )
);
} catch ( RedisException $e ) {
$this->throwRedisException( $this->server, $conn, $e );
@@ -573,6 +585,7 @@
} catch ( RedisException $e ) {
$this->throwRedisException( $this->server, $conn, $e );
}
+
return $sizes;
}
@@ -597,6 +610,7 @@
$title = Title::makeTitle( $item['namespace'],
$item['title'] );
$job = Job::factory( $item['type'], $title,
$item['params'] );
$job->metadata['uuid'] = $item['uuid'];
+
return $job;
} catch ( RedisException $e ) {
$this->throwRedisException( $this->server, $conn, $e );
@@ -734,6 +748,7 @@
'period' => 300 // 5 minutes
);
}
+
return $tasks;
}
@@ -744,18 +759,18 @@
protected function getNewJobFields( Job $job ) {
return array(
// Fields that describe the nature of the job
- 'type' => $job->getType(),
- 'namespace' => $job->getTitle()->getNamespace(),
- 'title' => $job->getTitle()->getDBkey(),
- 'params' => $job->getParams(),
+ 'type' => $job->getType(),
+ 'namespace' => $job->getTitle()->getNamespace(),
+ 'title' => $job->getTitle()->getDBkey(),
+ 'params' => $job->getParams(),
// Some jobs cannot run until a "release timestamp"
- 'rtimestamp' => $job->getReleaseTimestamp() ?: 0,
+ 'rtimestamp' => $job->getReleaseTimestamp() ? : 0,
// Additional job metadata
- 'uuid' => UIDGenerator::newRawUUIDv4(
UIDGenerator::QUICK_RAND ),
- 'sha1' => $job->ignoreDuplicates()
- ? wfBaseConvert( sha1( serialize(
$job->getDeduplicationInfo() ) ), 16, 36, 31 )
- : '',
- 'timestamp' => time() // UNIX timestamp
+ 'uuid' => UIDGenerator::newRawUUIDv4(
UIDGenerator::QUICK_RAND ),
+ 'sha1' => $job->ignoreDuplicates()
+ ? wfBaseConvert( sha1( serialize(
$job->getDeduplicationInfo() ) ), 16, 36, 31 )
+ : '',
+ 'timestamp' => time() // UNIX timestamp
);
}
@@ -768,8 +783,10 @@
if ( $title ) {
$job = Job::factory( $fields['type'], $title,
$fields['params'] );
$job->metadata['uuid'] = $fields['uuid'];
+
return $job;
}
+
return false;
}
@@ -780,10 +797,12 @@
protected function serialize( array $fields ) {
$blob = serialize( $fields );
if ( $this->compression === 'gzip'
- && strlen( $blob ) >= 1024 && function_exists(
'gzdeflate' ) )
- {
+ && strlen( $blob ) >= 1024
+ && function_exists( 'gzdeflate' )
+ ) {
$object = (object)array( 'blob' => gzdeflate( $blob ),
'enc' => 'gzip' );
$blobz = serialize( $object );
+
return ( strlen( $blobz ) < strlen( $blob ) ) ? $blobz
: $blob;
} else {
return $blob;
@@ -803,6 +822,7 @@
$fields = false;
}
}
+
return is_array( $fields ) ? $fields : false;
}
@@ -817,6 +837,7 @@
if ( !$conn ) {
throw new JobQueueConnectionError( "Unable to connect
to redis server." );
}
+
return $conn;
}
diff --git a/includes/job/aggregator/JobQueueAggregator.php
b/includes/job/aggregator/JobQueueAggregator.php
index a8186ab..142b162 100644
--- a/includes/job/aggregator/JobQueueAggregator.php
+++ b/includes/job/aggregator/JobQueueAggregator.php
@@ -34,7 +34,8 @@
/**
* @param array $params
*/
- protected function __construct( array $params ) {}
+ protected function __construct( array $params ) {
+ }
/**
* @return JobQueueAggregator
@@ -74,6 +75,7 @@
wfProfileIn( __METHOD__ );
$ok = $this->doNotifyQueueEmpty( $wiki, $type );
wfProfileOut( __METHOD__ );
+
return $ok;
}
@@ -93,6 +95,7 @@
wfProfileIn( __METHOD__ );
$ok = $this->doNotifyQueueNonEmpty( $wiki, $type );
wfProfileOut( __METHOD__ );
+
return $ok;
}
@@ -110,6 +113,7 @@
wfProfileIn( __METHOD__ );
$res = $this->doGetAllReadyWikiQueues();
wfProfileOut( __METHOD__ );
+
return $res;
}
@@ -127,6 +131,7 @@
wfProfileIn( __METHOD__ );
$res = $this->doPurge();
wfProfileOut( __METHOD__ );
+
return $res;
}
diff --git a/includes/job/aggregator/JobQueueAggregatorMemc.php
b/includes/job/aggregator/JobQueueAggregatorMemc.php
index 9434da0..d733a42 100644
--- a/includes/job/aggregator/JobQueueAggregatorMemc.php
+++ b/includes/job/aggregator/JobQueueAggregatorMemc.php
@@ -65,6 +65,7 @@
}
$this->cache->delete( "$key:lock" ); // unlock
}
+
return true;
}
@@ -103,6 +104,7 @@
$this->cache->delete( "$key:rebuild" ); //
unlock
}
}
+
return is_array( $pendingDbInfo )
? $pendingDbInfo['pendingDBs']
: array(); // cache is both empty and locked
diff --git a/includes/job/aggregator/JobQueueAggregatorRedis.php
b/includes/job/aggregator/JobQueueAggregatorRedis.php
index f1922a3..ca8975a 100644
--- a/includes/job/aggregator/JobQueueAggregatorRedis.php
+++ b/includes/job/aggregator/JobQueueAggregatorRedis.php
@@ -60,9 +60,11 @@
}
try {
$conn->hDel( $this->getReadyQueueKey(),
$this->encQueueName( $type, $wiki ) );
+
return true;
} catch ( RedisException $e ) {
$this->handleException( $conn, $e );
+
return false;
}
}
@@ -74,9 +76,11 @@
}
try {
$conn->hSet( $this->getReadyQueueKey(),
$this->encQueueName( $type, $wiki ), time() );
+
return true;
} catch ( RedisException $e ) {
$this->handleException( $conn, $e );
+
return false;
}
}
@@ -124,6 +128,7 @@
return $pendingDBs;
} catch ( RedisException $e ) {
$this->handleException( $conn, $e );
+
return array();
}
}
@@ -137,8 +142,10 @@
$conn->delete( $this->getReadyQueueKey() );
} catch ( RedisException $e ) {
$this->handleException( $conn, $e );
+
return false;
}
+
return true;
}
@@ -156,6 +163,7 @@
break;
}
}
+
return $conn;
}
@@ -190,6 +198,7 @@
*/
private function dencQueueName( $name ) {
list( $type, $wiki ) = explode( '/', $name, 2 );
+
return array( rawurldecode( $type ), rawurldecode( $wiki ) );
}
}
diff --git a/includes/job/jobs/AssembleUploadChunksJob.php
b/includes/job/jobs/AssembleUploadChunksJob.php
index 6237e56..fb5fb58 100644
--- a/includes/job/jobs/AssembleUploadChunksJob.php
+++ b/includes/job/jobs/AssembleUploadChunksJob.php
@@ -39,6 +39,7 @@
$user = $context->getUser();
if ( !$user->isLoggedIn() ) {
$this->setLastError( "Could not load the author
user from session." );
+
return false;
}
@@ -48,6 +49,7 @@
// the user does not necessarily mean the
session was loaded.
// Most likely cause by suhosin.session.encrypt
= On.
$this->setLastError( "Error associating with
user session. Try setting suhosin.session.encrypt = Off" );
+
return false;
}
@@ -71,6 +73,7 @@
array( 'result' => 'Failure', 'stage'
=> 'assembling', 'status' => $status )
);
$this->setLastError( $status->getWikiText() );
+
return false;
}
@@ -108,8 +111,10 @@
)
);
$this->setLastError( get_class( $e ) . ": " .
$e->getText() );
+
return false;
}
+
return true;
}
@@ -118,6 +123,7 @@
if ( is_array( $info['params'] ) ) {
$info['params'] = array( 'filekey' =>
$info['params']['filekey'] );
}
+
return $info;
}
diff --git a/includes/job/jobs/DoubleRedirectJob.php
b/includes/job/jobs/DoubleRedirectJob.php
index 33e749b..991b2eb 100644
--- a/includes/job/jobs/DoubleRedirectJob.php
+++ b/includes/job/jobs/DoubleRedirectJob.php
@@ -85,18 +85,21 @@
function run() {
if ( !$this->redirTitle ) {
$this->setLastError( 'Invalid title' );
+
return false;
}
$targetRev = Revision::newFromTitle( $this->title, false,
Revision::READ_LATEST );
if ( !$targetRev ) {
wfDebug( __METHOD__ . ": target redirect already
deleted, ignoring\n" );
+
return true;
}
$content = $targetRev->getContent();
$currentDest = $content ? $content->getRedirectTarget() : null;
if ( !$currentDest || !$currentDest->equals( $this->redirTitle
) ) {
wfDebug( __METHOD__ . ": Redirect has changed since the
job was queued\n" );
+
return true;
}
@@ -104,6 +107,7 @@
$mw = MagicWord::get( 'staticredirect' );
if ( $content->matchMagicWord( $mw ) ) {
wfDebug( __METHOD__ . ": skipping: suppressed with
__STATICREDIRECT__\n" );
+
return true;
}
@@ -111,6 +115,7 @@
$newTitle = self::getFinalDestination( $this->redirTitle );
if ( !$newTitle ) {
wfDebug( __METHOD__ . ": skipping: single redirect,
circular redirect or invalid redirect destination\n" );
+
return true;
}
if ( $newTitle->equals( $this->redirTitle ) ) {
@@ -128,12 +133,14 @@
if ( $newContent->equals( $content ) ) {
$this->setLastError( 'Content unchanged???' );
+
return false;
}
$user = $this->getUser();
if ( !$user ) {
$this->setLastError( 'Invalid user' );
+
return false;
}
@@ -171,6 +178,7 @@
$titleText = $title->getPrefixedDBkey();
if ( isset( $seenTitles[$titleText] ) ) {
wfDebug( __METHOD__, "Circular redirect
detected, aborting\n" );
+
return false;
}
$seenTitles[$titleText] = true;
@@ -198,6 +206,7 @@
$dest = $title = Title::makeTitle(
$row->rd_namespace, $row->rd_title, '', $row->rd_interwiki );
}
}
+
return $dest;
}
@@ -216,6 +225,7 @@
self::$user->addToDatabase();
}
}
+
return self::$user;
}
}
diff --git a/includes/job/jobs/DuplicateJob.php
b/includes/job/jobs/DuplicateJob.php
index be1bfe5..b3f3371 100644
--- a/includes/job/jobs/DuplicateJob.php
+++ b/includes/job/jobs/DuplicateJob.php
@@ -50,6 +50,7 @@
$djob->params = is_array( $djob->params ) ? $djob->params :
array();
$djob->params = array( 'isDuplicate' => true ) + $djob->params;
$djob->metadata = $job->metadata;
+
return $djob;
}
diff --git a/includes/job/jobs/EmaillingJob.php
b/includes/job/jobs/EmaillingJob.php
index 9fbf312..f24cebb 100644
--- a/includes/job/jobs/EmaillingJob.php
+++ b/includes/job/jobs/EmaillingJob.php
@@ -43,5 +43,4 @@
return $status->isOK();
}
-
}
diff --git a/includes/job/jobs/EnotifNotifyJob.php
b/includes/job/jobs/EnotifNotifyJob.php
index bbe988d..816b531 100644
--- a/includes/job/jobs/EnotifNotifyJob.php
+++ b/includes/job/jobs/EnotifNotifyJob.php
@@ -27,7 +27,6 @@
* @ingroup JobQueue
*/
class EnotifNotifyJob extends Job {
-
function __construct( $title, $params, $id = 0 ) {
parent::__construct( 'enotifNotify', $title, $params, $id );
}
@@ -52,7 +51,7 @@
$this->params['watchers'],
$this->params['pageStatus']
);
+
return true;
}
-
}
diff --git a/includes/job/jobs/HTMLCacheUpdateJob.php
b/includes/job/jobs/HTMLCacheUpdateJob.php
index be12937..1dd77ed 100644
--- a/includes/job/jobs/HTMLCacheUpdateJob.php
+++ b/includes/job/jobs/HTMLCacheUpdateJob.php
@@ -86,6 +86,7 @@
$numRows = $this->blCache->getNumLinks( $this->params['table'],
$max );
if ( $wgMaxBacklinksInvalidate !== false && $numRows >
$wgMaxBacklinksInvalidate ) {
wfDebug( "Skipped HTML cache invalidation of
{$this->title->getPrefixedText()}." );
+
return true;
}
@@ -123,6 +124,7 @@
# period of time, say by updating a heavily-used
template.
$this->insertJobsFromTitles( $titleArray );
}
+
return true;
}
diff --git a/includes/job/jobs/NullJob.php b/includes/job/jobs/NullJob.php
index b6164a5..77f6572 100644
--- a/includes/job/jobs/NullJob.php
+++ b/includes/job/jobs/NullJob.php
@@ -71,6 +71,7 @@
$job = new self( $this->title, $params );
JobQueueGroup::singleton()->push( $job );
}
+
return true;
}
}
diff --git a/includes/job/jobs/PublishStashedFileJob.php
b/includes/job/jobs/PublishStashedFileJob.php
index 1276e3c..ba47cb9 100644
--- a/includes/job/jobs/PublishStashedFileJob.php
+++ b/includes/job/jobs/PublishStashedFileJob.php
@@ -39,6 +39,7 @@
$user = $context->getUser();
if ( !$user->isLoggedIn() ) {
$this->setLastError( "Could not load the author
user from session." );
+
return false;
}
@@ -48,6 +49,7 @@
// the user does not necessarily mean the
session was loaded.
// Most likely cause by suhosin.session.encrypt
= On.
$this->setLastError( "Error associating with
user session. Try setting suhosin.session.encrypt = Off" );
+
return false;
}
@@ -73,6 +75,7 @@
array( 'result' => 'Failure', 'stage'
=> 'publish', 'status' => $status )
);
$this->setLastError( "Could not verify upload."
);
+
return false;
}
@@ -89,6 +92,7 @@
array( 'result' => 'Failure', 'stage'
=> 'publish', 'status' => $status )
);
$this->setLastError( $status->getWikiText() );
+
return false;
}
@@ -120,8 +124,10 @@
)
);
$this->setLastError( get_class( $e ) . ": " .
$e->getText() );
+
return false;
}
+
return true;
}
@@ -130,6 +136,7 @@
if ( is_array( $info['params'] ) ) {
$info['params'] = array( 'filekey' =>
$info['params']['filekey'] );
}
+
return $info;
}
diff --git a/includes/job/jobs/RefreshLinksJob.php
b/includes/job/jobs/RefreshLinksJob.php
index 4fc8bac..377fea5 100644
--- a/includes/job/jobs/RefreshLinksJob.php
+++ b/includes/job/jobs/RefreshLinksJob.php
@@ -42,6 +42,7 @@
if ( is_null( $this->title ) ) {
$this->error = "refreshLinks: Invalid title";
+
return false;
}
@@ -56,6 +57,7 @@
if ( !$revision ) {
$this->error = 'refreshLinks: Article not found "' .
$this->title->getPrefixedDBkey() . '"';
+
return false; // XXX: what if it was just deleted?
}
@@ -73,6 +75,7 @@
if ( is_array( $info['params'] ) ) {
unset( $info['params']['masterPos'] );
}
+
return $info;
}
@@ -128,6 +131,7 @@
if ( is_null( $this->title ) ) {
$this->error = "refreshLinks2: Invalid title";
+
return false;
}
@@ -205,6 +209,7 @@
array( 'masterPos' => $masterPos ) +
$this->getRootJobParams()
); // carry over information for de-duplication
}
+
return $jobs;
}
@@ -217,6 +222,7 @@
if ( is_array( $info['params'] ) ) {
unset( $info['params']['masterPos'] );
}
+
return $info;
}
}
diff --git a/includes/job/jobs/UploadFromUrlJob.php
b/includes/job/jobs/UploadFromUrlJob.php
index c993cfb..1354169 100644
--- a/includes/job/jobs/UploadFromUrlJob.php
+++ b/includes/job/jobs/UploadFromUrlJob.php
@@ -66,6 +66,7 @@
$status = $this->upload->fetchFile( $opts );
if ( !$status->isOk() ) {
$this->leaveMessage( $status );
+
return true;
}
@@ -74,6 +75,7 @@
if ( $result['status'] != UploadBase::OK ) {
$status = $this->upload->convertVerifyErrorToStatus(
$result );
$this->leaveMessage( $status );
+
return true;
}
@@ -111,8 +113,8 @@
$this->user
);
$this->leaveMessage( $status );
- return true;
+ return true;
}
/**
@@ -179,6 +181,7 @@
if ( !isset( $_SESSION[self::SESSION_KEYNAME][$key] ) ) {
$_SESSION[self::SESSION_KEYNAME][$key] = array();
}
+
return $_SESSION[self::SESSION_KEYNAME][$key];
}
}
--
To view, visit https://gerrit.wikimedia.org/r/97509
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I634c26061f0ac1231647a9062b6cea01b77136bd
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Siebrand <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits