@@ -213,7 +213,7 @@ public function getJobsIterator($job, ?int $limit, int $offset): iterable {
213213 * Get the next job in the list
214214 * @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.
215215 */
216- public function getNext (bool $ onlyTimeSensitive = false ): ?IJob {
216+ public function getNext (bool $ onlyTimeSensitive = false , string $ jobClass = null ): ?IJob {
217217 $ query = $ this ->connection ->getQueryBuilder ();
218218 $ query ->select ('* ' )
219219 ->from ('jobs ' )
@@ -226,6 +226,10 @@ public function getNext(bool $onlyTimeSensitive = false): ?IJob {
226226 $ query ->andWhere ($ query ->expr ()->eq ('time_sensitive ' , $ query ->createNamedParameter (IJob::TIME_SENSITIVE , IQueryBuilder::PARAM_INT )));
227227 }
228228
229+ if ($ jobClass ) {
230+ $ query ->andWhere ($ query ->expr ()->eq ('class ' , $ query ->createNamedParameter ($ jobClass )));
231+ }
232+
229233 $ result = $ query ->executeQuery ();
230234 $ row = $ result ->fetch ();
231235 $ result ->closeCursor ();
@@ -260,7 +264,7 @@ public function getNext(bool $onlyTimeSensitive = false): ?IJob {
260264
261265 if ($ count === 0 ) {
262266 // Background job already executed elsewhere, try again.
263- return $ this ->getNext ($ onlyTimeSensitive );
267+ return $ this ->getNext ($ onlyTimeSensitive, $ jobClass );
264268 }
265269
266270 if ($ job === null ) {
@@ -273,7 +277,7 @@ public function getNext(bool $onlyTimeSensitive = false): ?IJob {
273277 $ reset ->executeStatement ();
274278
275279 // Background job from disabled app, try again.
276- return $ this ->getNext ($ onlyTimeSensitive );
280+ return $ this ->getNext ($ onlyTimeSensitive, $ jobClass );
277281 }
278282
279283 return $ job ;
0 commit comments