@@ -214,7 +214,7 @@ public function getJobsIterator($job, ?int $limit, int $offset): iterable {
214
214
* Get the next job in the list
215
215
* @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.
216
216
*/
217
- public function getNext (bool $ onlyTimeSensitive = false ): ?IJob {
217
+ public function getNext (bool $ onlyTimeSensitive = false , string $ jobClass = null ): ?IJob {
218
218
$ query = $ this ->connection ->getQueryBuilder ();
219
219
$ query ->select ('* ' )
220
220
->from ('jobs ' )
@@ -227,6 +227,10 @@ public function getNext(bool $onlyTimeSensitive = false): ?IJob {
227
227
$ query ->andWhere ($ query ->expr ()->eq ('time_sensitive ' , $ query ->createNamedParameter (IJob::TIME_SENSITIVE , IQueryBuilder::PARAM_INT )));
228
228
}
229
229
230
+ if ($ jobClass ) {
231
+ $ query ->andWhere ($ query ->expr ()->eq ('class ' , $ query ->createNamedParameter ($ jobClass )));
232
+ }
233
+
230
234
$ result = $ query ->executeQuery ();
231
235
$ row = $ result ->fetch ();
232
236
$ result ->closeCursor ();
@@ -261,7 +265,7 @@ public function getNext(bool $onlyTimeSensitive = false): ?IJob {
261
265
262
266
if ($ count === 0 ) {
263
267
// Background job already executed elsewhere, try again.
264
- return $ this ->getNext ($ onlyTimeSensitive );
268
+ return $ this ->getNext ($ onlyTimeSensitive, $ jobClass );
265
269
}
266
270
267
271
if ($ job === null ) {
@@ -274,7 +278,7 @@ public function getNext(bool $onlyTimeSensitive = false): ?IJob {
274
278
$ reset ->executeStatement ();
275
279
276
280
// Background job from disabled app, try again.
277
- return $ this ->getNext ($ onlyTimeSensitive );
281
+ return $ this ->getNext ($ onlyTimeSensitive, $ jobClass );
278
282
}
279
283
280
284
return $ job ;
0 commit comments