Skip to content

Commit 6bc75b8

Browse files
authored
Merge pull request #47804 from nextcloud/backport/47801/stable30
2 parents 97aa0f7 + 2853496 commit 6bc75b8

File tree

4 files changed

+45
-2
lines changed

4 files changed

+45
-2
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
7+
* SPDX-License-Identifier: AGPL-3.0-or-later
8+
*/
9+
10+
namespace OC\Core\Migrations;
11+
12+
use Closure;
13+
use OCP\DB\ISchemaWrapper;
14+
use OCP\Migration\Attributes\ModifyColumn;
15+
use OCP\Migration\IOutput;
16+
use OCP\Migration\SimpleMigrationStep;
17+
18+
#[ModifyColumn(table: 'taskprocessing_tasks', name: 'error_message', description: 'Increase column length to 4000 bytes to support longer error messages')]
19+
class Version30000Date20240906095113 extends SimpleMigrationStep {
20+
21+
/**
22+
* @param IOutput $output
23+
* @param Closure(): ISchemaWrapper $schemaClosure
24+
* @param array $options
25+
* @return null|ISchemaWrapper
26+
*/
27+
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
28+
/** @var ISchemaWrapper $schema */
29+
$schema = $schemaClosure();
30+
31+
$table = $schema->getTable('taskprocessing_tasks');
32+
$column = $table->getColumn('error_message');
33+
34+
if ($column->getLength() < 4000) {
35+
$column->setLength(4000);
36+
}
37+
38+
return $schema;
39+
}
40+
}

lib/composer/composer/autoload_classmap.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1372,6 +1372,7 @@
13721372
'OC\\Core\\Migrations\\Version30000Date20240717111406' => $baseDir . '/core/Migrations/Version30000Date20240717111406.php',
13731373
'OC\\Core\\Migrations\\Version30000Date20240814180800' => $baseDir . '/core/Migrations/Version30000Date20240814180800.php',
13741374
'OC\\Core\\Migrations\\Version30000Date20240815080800' => $baseDir . '/core/Migrations/Version30000Date20240815080800.php',
1375+
'OC\\Core\\Migrations\\Version30000Date20240906095113' => $baseDir . '/core/Migrations/Version30000Date20240906095113.php',
13751376
'OC\\Core\\Notification\\CoreNotifier' => $baseDir . '/core/Notification/CoreNotifier.php',
13761377
'OC\\Core\\ResponseDefinitions' => $baseDir . '/core/ResponseDefinitions.php',
13771378
'OC\\Core\\Service\\LoginFlowV2Service' => $baseDir . '/core/Service/LoginFlowV2Service.php',

lib/composer/composer/autoload_static.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1405,6 +1405,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
14051405
'OC\\Core\\Migrations\\Version30000Date20240717111406' => __DIR__ . '/../../..' . '/core/Migrations/Version30000Date20240717111406.php',
14061406
'OC\\Core\\Migrations\\Version30000Date20240814180800' => __DIR__ . '/../../..' . '/core/Migrations/Version30000Date20240814180800.php',
14071407
'OC\\Core\\Migrations\\Version30000Date20240815080800' => __DIR__ . '/../../..' . '/core/Migrations/Version30000Date20240815080800.php',
1408+
'OC\\Core\\Migrations\\Version30000Date20240906095113' => __DIR__ . '/../../..' . '/core/Migrations/Version30000Date20240906095113.php',
14081409
'OC\\Core\\Notification\\CoreNotifier' => __DIR__ . '/../../..' . '/core/Notification/CoreNotifier.php',
14091410
'OC\\Core\\ResponseDefinitions' => __DIR__ . '/../../..' . '/core/ResponseDefinitions.php',
14101411
'OC\\Core\\Service\\LoginFlowV2Service' => __DIR__ . '/../../..' . '/core/Service/LoginFlowV2Service.php',

lib/private/TaskProcessing/Manager.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -891,7 +891,8 @@ public function setTaskResult(int $id, ?string $error, ?array $result, bool $isU
891891
if ($error !== null) {
892892
$task->setStatus(Task::STATUS_FAILED);
893893
$task->setEndedAt(time());
894-
$task->setErrorMessage($error);
894+
// truncate error message to 1000 characters
895+
$task->setErrorMessage(mb_substr($error, 0, 1000));
895896
$this->logger->warning('A TaskProcessing ' . $task->getTaskTypeId() . ' task with id ' . $id . ' failed with the following message: ' . $error);
896897
} elseif ($result !== null) {
897898
$taskTypes = $this->getAvailableTaskTypes();
@@ -956,7 +957,7 @@ public function setTaskResult(int $id, ?string $error, ?array $result, bool $isU
956957
$this->taskMapper->update($taskEntity);
957958
$this->runWebhook($task);
958959
} catch (\OCP\DB\Exception $e) {
959-
throw new \OCP\TaskProcessing\Exception\Exception('There was a problem finding the task', 0, $e);
960+
throw new \OCP\TaskProcessing\Exception\Exception($e->getMessage());
960961
}
961962
if ($task->getStatus() === Task::STATUS_SUCCESSFUL) {
962963
$event = new TaskSuccessfulEvent($task);

0 commit comments

Comments
 (0)