From: Aaron Schulz Date: Thu, 26 Mar 2015 19:17:10 +0000 (-0700) Subject: Made showJobs.php include abandoned jobs in --list X-Git-Tag: 1.31.0-rc.0~11980^2 X-Git-Url: https://git.cyclocoop.org/%28%28?a=commitdiff_plain;h=9720c6c41079ff49804e1171eaa09121ddeaecc5;p=lhc%2Fweb%2Fwiklou.git Made showJobs.php include abandoned jobs in --list Change-Id: I7ae8dd2470d5e15fd66c6c06f3feb6d70527daa3 --- diff --git a/includes/jobqueue/JobQueue.php b/includes/jobqueue/JobQueue.php index f4fe9133e9..91fe86cff1 100644 --- a/includes/jobqueue/JobQueue.php +++ b/includes/jobqueue/JobQueue.php @@ -615,6 +615,17 @@ abstract class JobQueue { return new ArrayIterator( array() ); // not implemented } + /** + * Get an iterator to traverse over all abandoned jobs in this queue + * + * @return Iterator + * @throws JobQueueError + * @since 1.25 + */ + public function getAllAbandonedJobs() { + return new ArrayIterator( array() ); // not implemented + } + /** * Do not use this function outside of JobQueue/JobQueueGroup * diff --git a/includes/jobqueue/JobQueueFederated.php b/includes/jobqueue/JobQueueFederated.php index 1d84dc4c5a..d985d4495f 100644 --- a/includes/jobqueue/JobQueueFederated.php +++ b/includes/jobqueue/JobQueueFederated.php @@ -422,6 +422,17 @@ class JobQueueFederated extends JobQueue { return $iterator; } + public function getAllAbandonedJobs() { + $iterator = new AppendIterator(); + + /** @var JobQueue $queue */ + foreach ( $this->partitionQueues as $queue ) { + $iterator->append( $queue->getAllAbandonedJobs() ); + } + + return $iterator; + } + public function getCoalesceLocationInternal() { return "JobQueueFederated:wiki:{$this->wiki}" . sha1( serialize( array_keys( $this->partitionQueues ) ) ); diff --git a/includes/jobqueue/JobQueueRedis.php b/includes/jobqueue/JobQueueRedis.php index d9fe30b110..6c823fb9f8 100644 --- a/includes/jobqueue/JobQueueRedis.php +++ b/includes/jobqueue/JobQueueRedis.php @@ -516,6 +516,29 @@ LUA; } } + /** + * @see JobQueue::getAllAbandonedJobs() + * @return Iterator + */ + public function getAllAbandonedJobs() { + $conn = $this->getConnection(); + try { + $that = $this; + + return new MappedIterator( // delayed jobs + $conn->zRange( $this->getQueueKey( 'z-abandoned' ), 0, -1 ), + function ( $uid ) use ( $that, $conn ) { + return $that->getJobFromUidInternal( $uid, $conn ); + }, + array( 'accept' => function ( $job ) { + return is_object( $job ); + } ) + ); + } catch ( RedisException $e ) { + $this->throwRedisException( $conn, $e ); + } + } + public function getCoalesceLocationInternal() { return "RedisServer:" . $this->server; } diff --git a/maintenance/showJobs.php b/maintenance/showJobs.php index a9f7d8b419..9e9ad327e0 100644 --- a/maintenance/showJobs.php +++ b/maintenance/showJobs.php @@ -58,6 +58,9 @@ class ShowJobs extends Maintenance { foreach ( $queue->getAllDelayedJobs() as $job ) { $this->output( $job->toString() . " status=delayed\n" ); } + foreach ( $queue->getAllAbandonedJobs() as $job ) { + $this->output( $job->toString() . " status=abandoned\n" ); + } } } elseif ( $this->hasOption( 'group' ) ) { foreach ( $group->getQueueTypes() as $type ) {