@@ -206,7 +206,7 @@ public function getJobsIterator($job, ?int $limit, int $offset): iterable {
206
206
* Get the next job in the list
207
207
* @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.
208
208
*/
209
- public function getNext (bool $ onlyTimeSensitive = false ): ?IJob {
209
+ public function getNext (bool $ onlyTimeSensitive = false , string $ jobClass = null ): ?IJob {
210
210
$ query = $ this ->connection ->getQueryBuilder ();
211
211
$ query ->select ('* ' )
212
212
->from ('jobs ' )
@@ -219,6 +219,10 @@ public function getNext(bool $onlyTimeSensitive = false): ?IJob {
219
219
$ query ->andWhere ($ query ->expr ()->eq ('time_sensitive ' , $ query ->createNamedParameter (IJob::TIME_SENSITIVE , IQueryBuilder::PARAM_INT )));
220
220
}
221
221
222
+ if ($ jobClass ) {
223
+ $ query ->andWhere ($ query ->expr ()->eq ('class ' , $ query ->createNamedParameter ($ jobClass )));
224
+ }
225
+
222
226
$ result = $ query ->executeQuery ();
223
227
$ row = $ result ->fetch ();
224
228
$ result ->closeCursor ();
@@ -253,7 +257,7 @@ public function getNext(bool $onlyTimeSensitive = false): ?IJob {
253
257
254
258
if ($ count === 0 ) {
255
259
// Background job already executed elsewhere, try again.
256
- return $ this ->getNext ($ onlyTimeSensitive );
260
+ return $ this ->getNext ($ onlyTimeSensitive, $ jobClass );
257
261
}
258
262
259
263
if ($ job === null ) {
@@ -266,7 +270,7 @@ public function getNext(bool $onlyTimeSensitive = false): ?IJob {
266
270
$ reset ->executeStatement ();
267
271
268
272
// Background job from disabled app, try again.
269
- return $ this ->getNext ($ onlyTimeSensitive );
273
+ return $ this ->getNext ($ onlyTimeSensitive, $ jobClass );
270
274
}
271
275
272
276
return $ job ;
0 commit comments