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