@@ -214,7 +214,7 @@ public function getJobsIterator($job, ?int $limit, int $offset): iterable {
214214 * Get the next job in the list
215215 * @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.
216216 */
217- public function getNext (bool $ onlyTimeSensitive = false ): ?IJob {
217+ public function getNext (bool $ onlyTimeSensitive = false , string $ jobClass = null ): ?IJob {
218218 $ query = $ this ->connection ->getQueryBuilder ();
219219 $ query ->select ('* ' )
220220 ->from ('jobs ' )
@@ -227,6 +227,10 @@ public function getNext(bool $onlyTimeSensitive = false): ?IJob {
227227 $ query ->andWhere ($ query ->expr ()->eq ('time_sensitive ' , $ query ->createNamedParameter (IJob::TIME_SENSITIVE , IQueryBuilder::PARAM_INT )));
228228 }
229229
230+ if ($ jobClass ) {
231+ $ query ->andWhere ($ query ->expr ()->eq ('class ' , $ query ->createNamedParameter ($ jobClass )));
232+ }
233+
230234 $ result = $ query ->executeQuery ();
231235 $ row = $ result ->fetch ();
232236 $ result ->closeCursor ();
@@ -261,7 +265,7 @@ public function getNext(bool $onlyTimeSensitive = false): ?IJob {
261265
262266 if ($ count === 0 ) {
263267 // Background job already executed elsewhere, try again.
264- return $ this ->getNext ($ onlyTimeSensitive );
268+ return $ this ->getNext ($ onlyTimeSensitive, $ jobClass );
265269 }
266270
267271 if ($ job === null ) {
@@ -274,7 +278,7 @@ public function getNext(bool $onlyTimeSensitive = false): ?IJob {
274278 $ reset ->executeStatement ();
275279
276280 // Background job from disabled app, try again.
277- return $ this ->getNext ($ onlyTimeSensitive );
281+ return $ this ->getNext ($ onlyTimeSensitive, $ jobClass );
278282 }
279283
280284 return $ job ;
0 commit comments