@@ -206,7 +206,7 @@ public function getJobsIterator($job, ?int $limit, int $offset): iterable {
206206 * Get the next job in the list
207207 * @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.
208208 */
209- public function getNext (bool $ onlyTimeSensitive = false ): ?IJob {
209+ public function getNext (bool $ onlyTimeSensitive = false , string $ jobClass = null ): ?IJob {
210210 $ query = $ this ->connection ->getQueryBuilder ();
211211 $ query ->select ('* ' )
212212 ->from ('jobs ' )
@@ -219,6 +219,10 @@ public function getNext(bool $onlyTimeSensitive = false): ?IJob {
219219 $ query ->andWhere ($ query ->expr ()->eq ('time_sensitive ' , $ query ->createNamedParameter (IJob::TIME_SENSITIVE , IQueryBuilder::PARAM_INT )));
220220 }
221221
222+ if ($ jobClass ) {
223+ $ query ->andWhere ($ query ->expr ()->eq ('class ' , $ query ->createNamedParameter ($ jobClass )));
224+ }
225+
222226 $ result = $ query ->executeQuery ();
223227 $ row = $ result ->fetch ();
224228 $ result ->closeCursor ();
@@ -253,7 +257,7 @@ public function getNext(bool $onlyTimeSensitive = false): ?IJob {
253257
254258 if ($ count === 0 ) {
255259 // Background job already executed elsewhere, try again.
256- return $ this ->getNext ($ onlyTimeSensitive );
260+ return $ this ->getNext ($ onlyTimeSensitive, $ jobClass );
257261 }
258262
259263 if ($ job === null ) {
@@ -266,7 +270,7 @@ public function getNext(bool $onlyTimeSensitive = false): ?IJob {
266270 $ reset ->executeStatement ();
267271
268272 // Background job from disabled app, try again.
269- return $ this ->getNext ($ onlyTimeSensitive );
273+ return $ this ->getNext ($ onlyTimeSensitive, $ jobClass );
270274 }
271275
272276 return $ job ;
0 commit comments