aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorCôme Chilliet <come.chilliet@nextcloud.com>2023-01-12 17:18:59 +0100
committerCôme Chilliet <come.chilliet@nextcloud.com>2023-01-12 17:18:59 +0100
commitd74044f6341e93861d820f21b6d37a2f98e1ef60 (patch)
tree2e25ede4dd29913b5e526cce3b790d627a230205 /lib
parente74f4646622a6f667228d52be1dde091bb0b2757 (diff)
downloadnextcloud-server-d74044f6341e93861d820f21b6d37a2f98e1ef60.tar.gz
nextcloud-server-d74044f6341e93861d820f21b6d37a2f98e1ef60.zip
Fix API breakage by using a new method instead
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/private/BackgroundJob/JobList.php11
-rw-r--r--lib/public/BackgroundJob/IJobList.php14
2 files changed, 22 insertions, 3 deletions
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<IJob>|null $job
* @return iterable<IJob> 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<IJob>|null $job
- * @return iterable<IJob>
+ * @return array<IJob>
* @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<IJob>|null $job
+ * @return iterable<IJob>
+ * @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