From af38184b6fadacaf9ef3faf4e62ab2f0f8447959 Mon Sep 17 00:00:00 2001 From: Daniel Kesselberg Date: Wed, 2 Jul 2025 18:34:13 +0200 Subject: [PATCH] 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 --- tests/lib/BackgroundJob/DummyJobList.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/lib/BackgroundJob/DummyJobList.php b/tests/lib/BackgroundJob/DummyJobList.php index 717db52715f..8cb9523b0dd 100644 --- a/tests/lib/BackgroundJob/DummyJobList.php +++ b/tests/lib/BackgroundJob/DummyJobList.php @@ -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); } /**