From d74044f6341e93861d820f21b6d37a2f98e1ef60 Mon Sep 17 00:00:00 2001 From: Côme Chilliet Date: Thu, 12 Jan 2023 17:18:59 +0100 Subject: Fix API breakage by using a new method instead MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- lib/private/BackgroundJob/JobList.php | 11 ++++++++++- lib/public/BackgroundJob/IJobList.php | 14 ++++++++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/private/BackgroundJob/JobList.php b/lib/private/BackgroundJob/JobList.php index 494735ad873..67b736b8dd9 100644 --- a/lib/private/BackgroundJob/JobList.php +++ b/lib/private/BackgroundJob/JobList.php @@ -157,11 +157,20 @@ class JobList implements IJobList { return (bool) $row; } + public function getJobs($job, ?int $limit, int $offset): array { + $iterable = $this->getJobsIterator($job, $limit, $offset); + if (is_array($iterable)) { + return $iterable; + } else { + return iterator_to_array($iterable); + } + } + /** * @param IJob|class-string|null $job * @return iterable Avoid to store these objects as they may share a Singleton instance. You should instead use these IJobs instances while looping on the iterable. */ - public function getJobs($job, ?int $limit, int $offset): iterable { + public function getJobsIterator($job, ?int $limit, int $offset): iterable { $query = $this->connection->getQueryBuilder(); $query->select('*') ->from('jobs') diff --git a/lib/public/BackgroundJob/IJobList.php b/lib/public/BackgroundJob/IJobList.php index 0b32607feb6..e8d0380e604 100644 --- a/lib/public/BackgroundJob/IJobList.php +++ b/lib/public/BackgroundJob/IJobList.php @@ -79,10 +79,20 @@ interface IJobList { * Get jobs matching the search * * @param IJob|class-string|null $job - * @return iterable + * @return array * @since 25.0.0 + * @deprecated 26.0.0 Use getJobsIterator instead to avoid duplicated job objects + */ + public function getJobs($job, ?int $limit, int $offset): array; + + /** + * Get jobs matching the search + * + * @param IJob|class-string|null $job + * @return iterable + * @since 26.0.0 */ - public function getJobs($job, ?int $limit, int $offset): iterable; + public function getJobsIterator($job, ?int $limit, int $offset): iterable; /** * get the next job in the list -- cgit v1.2.3