@@ -192,7 +192,7 @@ public function getJobsIterator($job, ?int $limit, int $offset): iterable {
192192 * Get the next job in the list
193193 * @return ?IJob the next job to run. Beware that this object may be a singleton and may be modified by the next call to buildJob.
194194 */
195- public function getNext (bool $ onlyTimeSensitive = false ): ?IJob {
195+ public function getNext (bool $ onlyTimeSensitive = false , string $ jobClass = null ): ?IJob {
196196 $ query = $ this ->connection ->getQueryBuilder ();
197197 $ query ->select ('* ' )
198198 ->from ('jobs ' )
@@ -205,6 +205,10 @@ public function getNext(bool $onlyTimeSensitive = false): ?IJob {
205205 $ query ->andWhere ($ query ->expr ()->eq ('time_sensitive ' , $ query ->createNamedParameter (IJob::TIME_SENSITIVE , IQueryBuilder::PARAM_INT )));
206206 }
207207
208+ if ($ jobClass ) {
209+ $ query ->andWhere ($ query ->expr ()->eq ('class ' , $ query ->createNamedParameter ($ jobClass )));
210+ }
211+
208212 $ result = $ query ->executeQuery ();
209213 $ row = $ result ->fetch ();
210214 $ result ->closeCursor ();
@@ -239,7 +243,7 @@ public function getNext(bool $onlyTimeSensitive = false): ?IJob {
239243
240244 if ($ count === 0 ) {
241245 // Background job already executed elsewhere, try again.
242- return $ this ->getNext ($ onlyTimeSensitive );
246+ return $ this ->getNext ($ onlyTimeSensitive, $ jobClass );
243247 }
244248
245249 if ($ job === null ) {
@@ -252,7 +256,7 @@ public function getNext(bool $onlyTimeSensitive = false): ?IJob {
252256 $ reset ->executeStatement ();
253257
254258 // Background job from disabled app, try again.
255- return $ this ->getNext ($ onlyTimeSensitive );
259+ return $ this ->getNext ($ onlyTimeSensitive, $ jobClass );
256260 }
257261
258262 return $ job ;
0 commit comments