mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
fix: Make DummyJobList.getJobsIterator return an interable instance
iterator_to_array on PHP 8.1 does not accept an array and fails hard with a type error Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
This commit is contained in:
parent
8b1ac839d7
commit
af38184b6f
1 changed files with 7 additions and 3 deletions
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
namespace Test\BackgroundJob;
|
||||
|
||||
use ArrayIterator;
|
||||
use OC\BackgroundJob\JobList;
|
||||
use OCP\BackgroundJob\IJob;
|
||||
use OCP\BackgroundJob\Job;
|
||||
|
|
@ -98,20 +99,23 @@ class DummyJobList extends JobList {
|
|||
return $this->jobs;
|
||||
}
|
||||
|
||||
public function getJobsIterator($job, ?int $limit, int $offset): array {
|
||||
public function getJobsIterator($job, ?int $limit, int $offset): iterable {
|
||||
if ($job instanceof IJob) {
|
||||
$jobClass = get_class($job);
|
||||
} else {
|
||||
$jobClass = $job;
|
||||
}
|
||||
return array_slice(
|
||||
|
||||
$jobs = array_slice(
|
||||
array_filter(
|
||||
$this->jobs,
|
||||
fn ($job) => ($jobClass === null) || (get_class($job) == $jobClass)
|
||||
fn ($job) => ($jobClass === null) || (get_class($job) === $jobClass)
|
||||
),
|
||||
$offset,
|
||||
$limit
|
||||
);
|
||||
|
||||
return new ArrayIterator($jobs);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue