From 96e24b3da059107d317dbc5729659a0eef2ad837 Mon Sep 17 00:00:00 2001 From: Maksim Sukharev Date: Wed, 18 Mar 2026 11:26:36 +0100 Subject: [PATCH 1/2] fix(bg_jobs): store job argument as a text, increase length cap from 4000 to 32000 Signed-off-by: Maksim Sukharev --- .../Version34000Date20260318095645.php | 41 +++++++++++++++++++ lib/private/BackgroundJob/JobList.php | 6 ++- tests/lib/BackgroundJob/JobListTest.php | 18 ++++++++ version.php | 2 +- 4 files changed, 64 insertions(+), 3 deletions(-) create mode 100644 core/Migrations/Version34000Date20260318095645.php diff --git a/core/Migrations/Version34000Date20260318095645.php b/core/Migrations/Version34000Date20260318095645.php new file mode 100644 index 0000000000000..8be6dfc912277 --- /dev/null +++ b/core/Migrations/Version34000Date20260318095645.php @@ -0,0 +1,41 @@ +hasTable('jobs')) { + $table = $schema->getTable('jobs'); + $argumentColumn = $table->getColumn('argument'); + + if ($argumentColumn->getType() !== Type::getType(Types::TEXT)) { + $argumentColumn->setType(Type::getType(Types::TEXT)); + return $schema; + } + } + + return null; + } +} diff --git a/lib/private/BackgroundJob/JobList.php b/lib/private/BackgroundJob/JobList.php index c00a51e385166..0cd951c0abff9 100644 --- a/lib/private/BackgroundJob/JobList.php +++ b/lib/private/BackgroundJob/JobList.php @@ -24,6 +24,8 @@ use function strlen; class JobList implements IJobList { + public const MAX_ARGUMENT_JSON_LENGTH = 32000; + /** @var array */ protected array $alreadyVisitedParallelBlocked = []; @@ -43,8 +45,8 @@ public function add($job, $argument = null, ?int $firstCheck = null): void { $class = ($job instanceof IJob) ? get_class($job) : $job; $argumentJson = json_encode($argument); - if (strlen($argumentJson) > 4000) { - throw new \InvalidArgumentException('Background job arguments can\'t exceed 4000 characters (json encoded)'); + if (strlen($argumentJson) > self::MAX_ARGUMENT_JSON_LENGTH) { + throw new \InvalidArgumentException('Background job arguments can\'t exceed ' . self::MAX_ARGUMENT_JSON_LENGTH . ' characters (json encoded)'); } $query = $this->connection->getQueryBuilder(); diff --git a/tests/lib/BackgroundJob/JobListTest.php b/tests/lib/BackgroundJob/JobListTest.php index 6f946187c52bb..a7fb0c7c787e1 100644 --- a/tests/lib/BackgroundJob/JobListTest.php +++ b/tests/lib/BackgroundJob/JobListTest.php @@ -111,6 +111,24 @@ public function testAddRemove($argument): void { $this->assertEquals($existingJobs, $jobs); } + public function testAddAcceptsArgumentUnderMaxLength(): void { + $argument = str_repeat('a', $this->instance::MAX_ARGUMENT_JSON_LENGTH - 100); + $job = new TestJob(); + $this->assertFalse($this->instance->has($job, $argument)); + $this->instance->add($job, $argument); + + $this->assertTrue($this->instance->has($job, $argument)); + } + + public function testAddRejectsArgumentAboveMaxLength(): void { + $argument = str_repeat('a', $this->instance::MAX_ARGUMENT_JSON_LENGTH + 100); + + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('Background job arguments can\'t exceed ' . $this->instance::MAX_ARGUMENT_JSON_LENGTH . ' characters (json encoded)'); + + $this->instance->add(new TestJob(), $argument); + } + /** * @param $argument */ diff --git a/version.php b/version.php index d4ccca163f7e8..84b7d3aea71c4 100644 --- a/version.php +++ b/version.php @@ -9,7 +9,7 @@ // between betas, final and RCs. This is _not_ the public version number. Reset minor/patch level // when updating major/minor version number. -$OC_Version = [32, 0, 6, 1]; +$OC_Version = [32, 0, 6, 2]; // The human-readable string $OC_VersionString = '32.0.6'; From 7e2cad054514dfa306a0ce138334ede97bcda14a Mon Sep 17 00:00:00 2001 From: Maksim Sukharev Date: Thu, 19 Mar 2026 11:32:19 +0100 Subject: [PATCH 2/2] chore: recompile autoload files Signed-off-by: Maksim Sukharev --- lib/composer/composer/autoload_classmap.php | 1 + lib/composer/composer/autoload_static.php | 1 + 2 files changed, 2 insertions(+) diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php index 9e2eea88394c0..a3bd2d88dda43 100644 --- a/lib/composer/composer/autoload_classmap.php +++ b/lib/composer/composer/autoload_classmap.php @@ -1533,6 +1533,7 @@ 'OC\\Core\\Migrations\\Version32000Date20250731062008' => $baseDir . '/core/Migrations/Version32000Date20250731062008.php', 'OC\\Core\\Migrations\\Version32000Date20250806110519' => $baseDir . '/core/Migrations/Version32000Date20250806110519.php', 'OC\\Core\\Migrations\\Version33000Date20251209123503' => $baseDir . '/core/Migrations/Version33000Date20251209123503.php', + 'OC\\Core\\Migrations\\Version34000Date20260318095645' => $baseDir . '/core/Migrations/Version34000Date20260318095645.php', 'OC\\Core\\Notification\\CoreNotifier' => $baseDir . '/core/Notification/CoreNotifier.php', 'OC\\Core\\ResponseDefinitions' => $baseDir . '/core/ResponseDefinitions.php', 'OC\\Core\\Service\\LoginFlowV2Service' => $baseDir . '/core/Service/LoginFlowV2Service.php', diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php index 6659de71da142..f3d325b4e77e9 100644 --- a/lib/composer/composer/autoload_static.php +++ b/lib/composer/composer/autoload_static.php @@ -1574,6 +1574,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2 'OC\\Core\\Migrations\\Version32000Date20250731062008' => __DIR__ . '/../../..' . '/core/Migrations/Version32000Date20250731062008.php', 'OC\\Core\\Migrations\\Version32000Date20250806110519' => __DIR__ . '/../../..' . '/core/Migrations/Version32000Date20250806110519.php', 'OC\\Core\\Migrations\\Version33000Date20251209123503' => __DIR__ . '/../../..' . '/core/Migrations/Version33000Date20251209123503.php', + 'OC\\Core\\Migrations\\Version34000Date20260318095645' => __DIR__ . '/../../..' . '/core/Migrations/Version34000Date20260318095645.php', 'OC\\Core\\Notification\\CoreNotifier' => __DIR__ . '/../../..' . '/core/Notification/CoreNotifier.php', 'OC\\Core\\ResponseDefinitions' => __DIR__ . '/../../..' . '/core/ResponseDefinitions.php', 'OC\\Core\\Service\\LoginFlowV2Service' => __DIR__ . '/../../..' . '/core/Service/LoginFlowV2Service.php',