Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/Db/Card.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
use Sabre\VObject\Component\VCalendar;

class Card extends RelationalEntity {
public const TITLE_MAX_LENGTH = 255;

protected $title;
protected $description;
protected $descriptionPrev;
Expand Down
17 changes: 1 addition & 16 deletions lib/Migration/Version1000Date20200306161713.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,7 @@
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();

Expand Down
28 changes: 3 additions & 25 deletions lib/Migration/Version1000Date20200308073933.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,7 @@
* 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();

Expand All @@ -39,16 +24,9 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt
'notnull' => true,
'default' => 0
]);
$table->addIndex(['participant'], 'deck_assigned_users_idx_t');
//$table->addIndex(['participant'], 'deck_assigned_users_idx_t');
$table->addIndex(['type'], 'deck_assigned_users_idx_ty');

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) {
}
}
104 changes: 104 additions & 0 deletions lib/Migration/Version10200Date20201111150114.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
<?php

declare(strict_types=1);

namespace OCA\Deck\Migration;

use Closure;
use OCP\DB\ISchemaWrapper;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;

class Version10200Date20201111150114 extends SimpleMigrationStep {
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();

// Fix wrong index added in Version1000Date20200308073933
$table = $schema->getTable('deck_assigned_users');
if ($table->hasIndex('deck_assigned_users_idx_t')) {
$table->dropIndex('deck_assigned_users_idx_t');
if (!$table->hasIndex('deck_assigned_users_idx_ty')) {
$table->addIndex(['type'], 'deck_assigned_users_idx_ty');
}
}

// 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;
}
}
12 changes: 12 additions & 0 deletions lib/Service/CardService.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ public function create($title, $stackId, $type, $order, $owner, $description = '
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');
}
Expand Down Expand Up @@ -270,6 +274,10 @@ public function update($id, $title, $stackId, $type, $order = 0, $description =
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 $$$');
}
Expand Down Expand Up @@ -361,6 +369,10 @@ public function rename($id, $title) {
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.');
Expand Down