@@ -192,7 +192,7 @@ public function getJobsIterator($job, ?int $limit, int $offset): iterable {
192
192
* Get the next job in the list
193
193
* @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.
194
194
*/
195
- public function getNext (bool $ onlyTimeSensitive = false ): ?IJob {
195
+ public function getNext (bool $ onlyTimeSensitive = false , string $ jobClass = null ): ?IJob {
196
196
$ query = $ this ->connection ->getQueryBuilder ();
197
197
$ query ->select ('* ' )
198
198
->from ('jobs ' )
@@ -205,6 +205,10 @@ public function getNext(bool $onlyTimeSensitive = false): ?IJob {
205
205
$ query ->andWhere ($ query ->expr ()->eq ('time_sensitive ' , $ query ->createNamedParameter (IJob::TIME_SENSITIVE , IQueryBuilder::PARAM_INT )));
206
206
}
207
207
208
+ if ($ jobClass ) {
209
+ $ query ->andWhere ($ query ->expr ()->eq ('class ' , $ query ->createNamedParameter ($ jobClass )));
210
+ }
211
+
208
212
$ result = $ query ->executeQuery ();
209
213
$ row = $ result ->fetch ();
210
214
$ result ->closeCursor ();
@@ -239,7 +243,7 @@ public function getNext(bool $onlyTimeSensitive = false): ?IJob {
239
243
240
244
if ($ count === 0 ) {
241
245
// Background job already executed elsewhere, try again.
242
- return $ this ->getNext ($ onlyTimeSensitive );
246
+ return $ this ->getNext ($ onlyTimeSensitive, $ jobClass );
243
247
}
244
248
245
249
if ($ job === null ) {
@@ -252,7 +256,7 @@ public function getNext(bool $onlyTimeSensitive = false): ?IJob {
252
256
$ reset ->executeStatement ();
253
257
254
258
// Background job from disabled app, try again.
255
- return $ this ->getNext ($ onlyTimeSensitive );
259
+ return $ this ->getNext ($ onlyTimeSensitive, $ jobClass );
256
260
}
257
261
258
262
return $ job ;
0 commit comments