diff --git a/lib/Db/Card.php b/lib/Db/Card.php index fe91387ae..9a6954239 100644 --- a/lib/Db/Card.php +++ b/lib/Db/Card.php @@ -28,6 +28,8 @@ use DateTimeZone; use Sabre\VObject\Component\VCalendar; class Card extends RelationalEntity { + public const TITLE_MAX_LENGTH = 255; + protected $title; protected $description; protected $descriptionPrev; diff --git a/lib/Migration/Version1000Date20200306161713.php b/lib/Migration/Version1000Date20200306161713.php index 5ea48c20b..62693a0fd 100644 --- a/lib/Migration/Version1000Date20200306161713.php +++ b/lib/Migration/Version1000Date20200306161713.php @@ -10,22 +10,7 @@ use OCP\Migration\IOutput; use OCP\Migration\SimpleMigrationStep; class Version1000Date20200306161713 extends SimpleMigrationStep { - - /** - * @param IOutput $output - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` - * @param array $options - */ - public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options) { - } - - /** - * @param IOutput $output - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` - * @param array $options - * @return null|ISchemaWrapper - */ - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) { + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { /** @var ISchemaWrapper $schema */ $schema = $schemaClosure(); diff --git a/lib/Migration/Version1000Date20200308073933.php b/lib/Migration/Version1000Date20200308073933.php index 64259231b..5e91e2537 100644 --- a/lib/Migration/Version1000Date20200308073933.php +++ b/lib/Migration/Version1000Date20200308073933.php @@ -13,22 +13,7 @@ use OCP\Migration\SimpleMigrationStep; * Auto-generated migration step: Please modify to your needs! */ class Version1000Date20200308073933 extends SimpleMigrationStep { - - /** - * @param IOutput $output - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` - * @param array $options - */ - public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options) { - } - - /** - * @param IOutput $output - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` - * @param array $options - * @return null|ISchemaWrapper - */ - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) { + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { /** @var ISchemaWrapper $schema */ $schema = $schemaClosure(); @@ -44,12 +29,4 @@ class Version1000Date20200308073933 extends SimpleMigrationStep { return $schema; } - - /** - * @param IOutput $output - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` - * @param array $options - */ - public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options) { - } } diff --git a/lib/Migration/Version10200Date20201111150114.php b/lib/Migration/Version10200Date20201111150114.php index 85bbffabe..101e45aae 100644 --- a/lib/Migration/Version10200Date20201111150114.php +++ b/lib/Migration/Version10200Date20201111150114.php @@ -10,11 +10,6 @@ use OCP\Migration\IOutput; use OCP\Migration\SimpleMigrationStep; class Version10200Date20201111150114 extends SimpleMigrationStep { - - - function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void { - } - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { /** @var ISchemaWrapper $schema */ $schema = $schemaClosure(); @@ -28,9 +23,82 @@ class Version10200Date20201111150114 extends SimpleMigrationStep { } } + // Check consistency of the labels table when updating from a version < 0.6 + // git commit for database.xml change at b0eaae6705dbfb9ce834d4047912d3e34eaa157f + $table = $schema->getTable('deck_labels'); + if (!$table->hasColumn('last_modified')) { + $table->addColumn('last_modified', 'integer', [ + 'notnull' => false, + 'default' => 0, + 'unsigned' => true, + ]); + } + + // Check consistency of the cards table when updating from a version < 0.5.1 + // git commit for database.xml change at dd104466d61e32f59552da183034522e04effe35 + $table = $schema->getTable('deck_cards'); + if (!$table->hasColumn('description_prev')) { + $table->addColumn('description_prev', 'text', [ + 'notnull' => false, + ]); + } + if (!$table->hasColumn('last_editor')) { + $table->addColumn('last_editor', 'string', [ + 'notnull' => false, + 'length' => 64, + ]); + } + + // Check consistency of the cards table when updating from a version < 0.5.0 + // git commit for database.xml change at a068d6e1c6588662f0ea131e57f974238538eda6 + $table = $schema->getTable('deck_boards'); + if (!$table->hasColumn('last_modified')) { + $table->addColumn('last_modified', 'integer', [ + 'notnull' => false, + 'default' => 0, + 'unsigned' => true, + ]); + } + $table = $schema->getTable('deck_stacks'); + if (!$table->hasColumn('last_modified')) { + $table->addColumn('last_modified', 'integer', [ + 'notnull' => false, + 'default' => 0, + 'unsigned' => true, + ]); + } + + // Check consistency of the cards table when updating from a version < 0.5.0 + // git commit for database.xml change at ef4ce31c47a5ef70d1a4d00f2d4cd182ac067f2c + $table = $schema->getTable('deck_stacks'); + if (!$table->hasColumn('deleted_at')) { + $table->addColumn('deleted_at', 'bigint', [ + 'notnull' => false, + 'length' => 8, + 'default' => 0, + 'unsigned' => true, + ]); + } + + // Check consistency of the cards table when updating from a version < 0.5.0 + // git commit for database.xml change at 2ef4b55af427d90412544e77916e9449db7dbbcd + $table = $schema->getTable('deck_cards'); + if (!$table->hasColumn('deleted_at')) { + $table->addColumn('deleted_at', 'bigint', [ + 'notnull' => false, + 'length' => 8, + 'default' => 0, + 'unsigned' => true, + ]); + } + + $table = $schema->getTable('deck_cards'); + if ($table->getColumn('title')->getLength() !== 255) { + $table->changeColumn('title', [ + 'length' => 255 + ]); + } + return $schema; } - - public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void { - } } diff --git a/lib/Service/CardService.php b/lib/Service/CardService.php index 46cf3307d..90cb1ee26 100644 --- a/lib/Service/CardService.php +++ b/lib/Service/CardService.php @@ -172,6 +172,10 @@ class CardService { throw new BadRequestException('title must be provided'); } + if (mb_strlen($title) > Card::TITLE_MAX_LENGTH) { + throw new BadRequestException('The title cannot exceed 255 characters'); + } + if (is_numeric($stackId) === false) { throw new BadRequestException('stack id must be a number'); } @@ -270,6 +274,10 @@ class CardService { throw new BadRequestException('title must be provided'); } + if (mb_strlen($title) > Card::TITLE_MAX_LENGTH) { + throw new BadRequestException('The title cannot exceed 255 characters'); + } + if (is_numeric($stackId) === false) { throw new BadRequestException('stack id must be a number $$$'); } @@ -361,6 +369,10 @@ class CardService { throw new BadRequestException('title must be provided'); } + if (mb_strlen($title) > Card::TITLE_MAX_LENGTH) { + throw new BadRequestException('The title cannot exceed 255 characters'); + } + $this->permissionService->checkPermission($this->cardMapper, $id, Acl::PERMISSION_EDIT); if ($this->boardService->isArchived($this->cardMapper, $id)) { throw new StatusException('Operation not allowed. This board is archived.');