From: Aaron Schulz Date: Wed, 3 Jun 2015 20:04:42 +0000 (-0700) Subject: Implemented getAllAcquiredJobs in JobQueueDB X-Git-Tag: 1.31.0-rc.0~11187^2 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/%7B%7B%20url_for%28%27admin_users%27%29%20%7D%7D?a=commitdiff_plain;h=dc4950a33b5ae1a2f7ca46e3b667ab9f50b9d850;p=lhc%2Fweb%2Fwiklou.git Implemented getAllAcquiredJobs in JobQueueDB Change-Id: Ie9f0b9357b365f8bddd1f2fdcac11dec29aec876 --- diff --git a/includes/jobqueue/JobQueueDB.php b/includes/jobqueue/JobQueueDB.php index 74edef3805..3dc36bd58b 100644 --- a/includes/jobqueue/JobQueueDB.php +++ b/includes/jobqueue/JobQueueDB.php @@ -558,19 +558,35 @@ class JobQueueDB extends JobQueue { * @return Iterator */ public function getAllQueuedJobs() { + return $this->getJobIterator( array( 'job_cmd' => $this->getType(), 'job_token' => '' ) ); + } + + /** + * @see JobQueue::getAllAcquiredJobs() + * @return Iterator + */ + public function getAllAcquiredJobs() { + return $this->getJobIterator( array( 'job_cmd' => $this->getType(), "job_token > ''" ) ); + } + + /** + * @param array $conds Query conditions + * @return Iterator + */ + protected function getJobIterator( array $conds ) { $dbr = $this->getSlaveDB(); try { return new MappedIterator( - $dbr->select( 'job', self::selectFields(), - array( 'job_cmd' => $this->getType(), 'job_token' => '' ) ), - function ( $row ) use ( $dbr ) { + $dbr->select( 'job', self::selectFields(), $conds ), + function ( $row ) { $job = Job::factory( $row->job_cmd, Title::makeTitle( $row->job_namespace, $row->job_title ), - strlen( $row->job_params ) ? unserialize( $row->job_params ) : false + strlen( $row->job_params ) ? unserialize( $row->job_params ) : array() ); $job->metadata['id'] = $row->job_id; $job->metadata['timestamp'] = $row->job_timestamp; + return $job; } );