From 16c184e2cb1110797935107987d0fc9536031df8 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Fri, 19 Jul 2024 18:03:54 +0200 Subject: [PATCH 1/2] fix: cast to bigint on postgresql Signed-off-by: Robin Appelman --- .../QueryBuilder/ExpressionBuilder/PgSqlExpressionBuilder.php | 2 +- tests/lib/Preview/BackgroundCleanupJobTest.php | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/private/DB/QueryBuilder/ExpressionBuilder/PgSqlExpressionBuilder.php b/lib/private/DB/QueryBuilder/ExpressionBuilder/PgSqlExpressionBuilder.php index 1a162f04a496d..53a566a7eb6e4 100644 --- a/lib/private/DB/QueryBuilder/ExpressionBuilder/PgSqlExpressionBuilder.php +++ b/lib/private/DB/QueryBuilder/ExpressionBuilder/PgSqlExpressionBuilder.php @@ -23,7 +23,7 @@ class PgSqlExpressionBuilder extends ExpressionBuilder { public function castColumn($column, $type): IQueryFunction { switch ($type) { case IQueryBuilder::PARAM_INT: - return new QueryFunction('CAST(' . $this->helper->quoteColumnName($column) . ' AS INT)'); + return new QueryFunction('CAST(' . $this->helper->quoteColumnName($column) . ' AS BIGINT)'); case IQueryBuilder::PARAM_STR: return new QueryFunction('CAST(' . $this->helper->quoteColumnName($column) . ' AS TEXT)'); default: diff --git a/tests/lib/Preview/BackgroundCleanupJobTest.php b/tests/lib/Preview/BackgroundCleanupJobTest.php index a221829b712ec..c07ec42b36b34 100644 --- a/tests/lib/Preview/BackgroundCleanupJobTest.php +++ b/tests/lib/Preview/BackgroundCleanupJobTest.php @@ -180,9 +180,11 @@ public function testOldPreviews() { $f1->newFile('foo.jpg', 'foo'); $f2 = $appdata->newFolder('123456782'); $f2->newFile('foo.jpg', 'foo'); + $f2 = $appdata->newFolder((string)PHP_INT_MAX - 1); + $f2->newFile('foo.jpg', 'foo'); $appdata = \OC::$server->getAppDataDir('preview'); - $this->assertSame(2, count($appdata->getDirectoryListing())); + $this->assertSame(3, count($appdata->getDirectoryListing())); $job = new BackgroundCleanupJob($this->timeFactory, $this->connection, $this->getRoot(), $this->mimeTypeLoader, true); $job->run([]); From 5ea972922bcb03007728b3a2e24dce18cd9cebf0 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Fri, 19 Jul 2024 18:05:07 +0200 Subject: [PATCH 2/2] fix: explicitly filter for storageid in preview cleanup job Signed-off-by: Robin Appelman --- lib/private/Preview/BackgroundCleanupJob.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/private/Preview/BackgroundCleanupJob.php b/lib/private/Preview/BackgroundCleanupJob.php index 49ff01486a3a4..deadcd007b1af 100644 --- a/lib/private/Preview/BackgroundCleanupJob.php +++ b/lib/private/Preview/BackgroundCleanupJob.php @@ -72,6 +72,8 @@ private function getOldPreviewLocations(): \Iterator { )) ->where( $qb->expr()->isNull('b.fileid') + )->andWhere( + $qb->expr()->eq('a.storage', $qb->createNamedParameter($this->previewFolder->getStorageId())) )->andWhere( $qb->expr()->eq('a.parent', $qb->createNamedParameter($this->previewFolder->getId())) )->andWhere(