This commit is contained in:
James Cole
2019-09-21 07:33:13 +02:00
parent 750b2360c3
commit 3aba7e1db7
11 changed files with 153 additions and 72 deletions

View File

@@ -72,7 +72,7 @@ php artisan firefly-iii:back-to-journals
php artisan firefly-iii:rename-account-meta
php artisan firefly-iii:migrate-recurrence-meta
# there are 14 verify commands
# there are 15 verify commands
php artisan firefly-iii:fix-piggies
php artisan firefly-iii:create-link-types
php artisan firefly-iii:create-access-tokens
@@ -87,6 +87,7 @@ php artisan firefly-iii:delete-empty-groups
php artisan firefly-iii:fix-account-types
php artisan firefly-iii:rename-meta-fields
php artisan firefly-iii:fix-ob-currencies
php artisan firefly-iii:fix-long-descriptions
# report commands
php artisan firefly-iii:report-empty-objects

View File

@@ -74,7 +74,7 @@ class TransactionStoreRequest extends Request
{
$rules = [
// basic fields for group:
'group_title' => 'between:1,255',
'group_title' => 'between:1,1000',
// transaction rules (in array for splits):
'transactions.*.type' => 'required|in:withdrawal,deposit,transfer,opening-balance,reconciliation',
@@ -92,7 +92,7 @@ class TransactionStoreRequest extends Request
'transactions.*.foreign_amount' => 'numeric|more:0',
// description
'transactions.*.description' => 'nullable|between:1,255',
'transactions.*.description' => 'nullable|between:1,1000',
// source of transaction
'transactions.*.source_id' => ['numeric', 'nullable', new BelongsUser],

View File

@@ -149,7 +149,7 @@ class TransactionUpdateRequest extends Request
{
$rules = [
// basic fields for group:
'group_title' => 'between:1,255',
'group_title' => 'between:1,1000',
// transaction rules (in array for splits):
'transactions.*.type' => 'in:withdrawal,deposit,transfer,opening-balance,reconciliation',
@@ -163,11 +163,11 @@ class TransactionUpdateRequest extends Request
'transactions.*.foreign_currency_code' => 'min:3|max:3|exists:transaction_currencies,code',
// amount
'transactions.*.amount' => 'numeric|more:0',
'transactions.*.amount' => 'numeric|more:0|max:100000000000',
'transactions.*.foreign_amount' => 'numeric|gte:0',
// description
'transactions.*.description' => 'nullable|between:1,255',
'transactions.*.description' => 'nullable|between:1,1000',
// source of transaction
'transactions.*.source_id' => ['numeric', 'nullable', new BelongsUser],

View File

@@ -70,7 +70,8 @@ class CorrectDatabase extends Command
'firefly-iii:delete-empty-groups',
'firefly-iii:fix-account-types',
'firefly-iii:rename-meta-fields',
'firefly-iii:fix-ob-currencies'
'firefly-iii:fix-ob-currencies',
'firefly-iii:fix-long-descriptions'
];
foreach ($commands as $command) {
$this->line(sprintf('Now executing %s', $command));

View File

@@ -0,0 +1,76 @@
<?php
/**
* FixLongDescriptions.php
* Copyright (c) 2019 thegrumpydictator@gmail.com
*
* This file is part of Firefly III.
*
* Firefly III is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Firefly III is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
namespace FireflyIII\Console\Commands\Correction;
use FireflyIII\Models\TransactionGroup;
use FireflyIII\Models\TransactionJournal;
use Illuminate\Console\Command;
/**
* Class FixLongDescriptions
*/
class FixLongDescriptions extends Command
{
private const MAX_LENGTH = 1000;
/**
* The console command description.
*
* @var string
*/
protected $description = 'Fixes long descriptions in journals and groups.';
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'firefly-iii:fix-long-descriptions';
/**
* Execute the console command.
*
* @return int
*/
public function handle(): int
{
$journals = TransactionJournal::get(['id', 'description']);
/** @var TransactionJournal $journal */
foreach ($journals as $journal) {
if (strlen($journal->description) > self::MAX_LENGTH) {
$journal->description = substr($journal->description, 0, self::MAX_LENGTH);
$journal->save();
$this->line(sprintf('Truncated description of transaction journal #%d', $journal->id));
}
}
$groups = TransactionGroup::get(['id', 'title']);
/** @var TransactionGroup $group */
foreach ($groups as $group) {
if (strlen($group->title) > self::MAX_LENGTH) {
$group->title = substr($group->title, 0, self::MAX_LENGTH);
$group->save();
$this->line(sprintf('Truncated description of transaction group #%d', $group->id));
}
}
return 0;
}
}

View File

@@ -73,7 +73,7 @@ class UpgradeDatabase extends Command
'firefly-iii:rename-account-meta',
'firefly-iii:migrate-recurrence-meta',
// there are 14 verify commands.
// there are 15 verify commands.
'firefly-iii:fix-piggies',
'firefly-iii:create-link-types',
'firefly-iii:create-access-tokens',
@@ -88,6 +88,7 @@ class UpgradeDatabase extends Command
'firefly-iii:fix-account-types',
'firefly-iii:rename-meta-fields',
'firefly-iii:fix-ob-currencies',
'firefly-iii:fix-long-descriptions',
// two report commands
'firefly-iii:report-empty-objects',

View File

@@ -61,7 +61,7 @@ class TransactionGroupFactory
$title = '' === $title ? null : $title;
if (null !== $title) {
$title = substr($title, 0, 255);
$title = substr($title, 0, 1000);
}
$group = new TransactionGroup;

View File

@@ -287,7 +287,7 @@ class TransactionJournalFactory
'transaction_type_id' => $type->id,
'bill_id' => $billId,
'transaction_currency_id' => $currency->id,
'description' => $description,
'description' => substr($description,0,1000),
'date' => $carbon->format('Y-m-d H:i:s'),
'order' => $order,
'tag_count' => 0,

View File

@@ -85,7 +85,7 @@ class InstallController extends Controller
'firefly-iii:rename-account-meta' => [],
'firefly-iii:migrate-recurrence-meta' => [],
// there are 14 verify commands.
// there are 15 verify commands.
'firefly-iii:fix-piggies' => [],
'firefly-iii:create-link-types' => [],
'firefly-iii:create-access-tokens' => [],
@@ -100,6 +100,7 @@ class InstallController extends Controller
'firefly-iii:fix-account-types' => [],
'firefly-iii:rename-meta-fields' => [],
'firefly-iii:fix-ob-currencies' => [],
'firefly-iii:fix-long-descriptions' => [],
];
}

View File

@@ -163,6 +163,7 @@
"@php artisan firefly-iii:fix-account-types",
"@php artisan firefly-iii:rename-meta-fields",
"@php artisan firefly-iii:fix-ob-currencies",
"@php artisan firefly-iii:fix-long-descriptions",
"@php artisan firefly-iii:report-empty-objects",
"@php artisan firefly-iii:report-sum",

122
composer.lock generated
View File

@@ -171,12 +171,12 @@
"source": {
"type": "git",
"url": "https://github.com/bunq/sdk_php.git",
"reference": "cfde75f644e5105a8634b0cd9a891c49c50b0e28"
"reference": "9f4ce9a3f1027936e2253bd75534a3e12fed55ae"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/bunq/sdk_php/zipball/cfde75f644e5105a8634b0cd9a891c49c50b0e28",
"reference": "cfde75f644e5105a8634b0cd9a891c49c50b0e28",
"url": "https://api.github.com/repos/bunq/sdk_php/zipball/9f4ce9a3f1027936e2253bd75534a3e12fed55ae",
"reference": "9f4ce9a3f1027936e2253bd75534a3e12fed55ae",
"shasum": ""
},
"require": {
@@ -227,7 +227,7 @@
"payment",
"sepa"
],
"time": "2019-09-10T15:00:27+00:00"
"time": "2019-09-16T07:15:00+00:00"
},
{
"name": "danhunsaker/laravel-flysystem-others",
@@ -2035,16 +2035,16 @@
},
{
"name": "league/flysystem-sftp",
"version": "1.0.20",
"version": "1.0.21",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/flysystem-sftp.git",
"reference": "518ac7dc9e80ca55ab6c3cebc8bccb4c2a5af302"
"reference": "4c2f2fcc4da251127c315d37eb3dfa5e94658df0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/thephpleague/flysystem-sftp/zipball/518ac7dc9e80ca55ab6c3cebc8bccb4c2a5af302",
"reference": "518ac7dc9e80ca55ab6c3cebc8bccb4c2a5af302",
"url": "https://api.github.com/repos/thephpleague/flysystem-sftp/zipball/4c2f2fcc4da251127c315d37eb3dfa5e94658df0",
"reference": "4c2f2fcc4da251127c315d37eb3dfa5e94658df0",
"shasum": ""
},
"require": {
@@ -2073,7 +2073,7 @@
}
],
"description": "Flysystem adapter for SFTP",
"time": "2019-06-07T20:54:19+00:00"
"time": "2019-09-19T09:11:05+00:00"
},
{
"name": "league/fractal",
@@ -2657,16 +2657,16 @@
},
{
"name": "phpseclib/phpseclib",
"version": "2.0.21",
"version": "2.0.23",
"source": {
"type": "git",
"url": "https://github.com/phpseclib/phpseclib.git",
"reference": "9f1287e68b3f283339a9f98f67515dd619e5bf9d"
"reference": "c78eb5058d5bb1a183133c36d4ba5b6675dfa099"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/9f1287e68b3f283339a9f98f67515dd619e5bf9d",
"reference": "9f1287e68b3f283339a9f98f67515dd619e5bf9d",
"url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/c78eb5058d5bb1a183133c36d4ba5b6675dfa099",
"reference": "c78eb5058d5bb1a183133c36d4ba5b6675dfa099",
"shasum": ""
},
"require": {
@@ -2700,28 +2700,28 @@
"authors": [
{
"name": "Jim Wigginton",
"role": "Lead Developer",
"email": "terrafrost@php.net"
"email": "terrafrost@php.net",
"role": "Lead Developer"
},
{
"name": "Patrick Monnerat",
"role": "Developer",
"email": "pm@datasphere.ch"
"email": "pm@datasphere.ch",
"role": "Developer"
},
{
"name": "Andreas Fischer",
"role": "Developer",
"email": "bantu@phpbb.com"
"email": "bantu@phpbb.com",
"role": "Developer"
},
{
"name": "Hans-Jürgen Petrich",
"role": "Developer",
"email": "petrich@tronic-media.com"
"email": "petrich@tronic-media.com",
"role": "Developer"
},
{
"name": "Graham Campbell",
"role": "Developer",
"email": "graham@alt-three.com"
"email": "graham@alt-three.com",
"role": "Developer"
}
],
"description": "PHP Secure Communications Library - Pure-PHP implementations of RSA, AES, SSH2, SFTP, X.509 etc.",
@@ -2745,20 +2745,20 @@
"x.509",
"x509"
],
"time": "2019-07-12T12:53:49+00:00"
"time": "2019-09-17T03:41:22+00:00"
},
{
"name": "pragmarx/google2fa",
"version": "v6.0.0",
"version": "v6.0.1",
"source": {
"type": "git",
"url": "https://github.com/antonioribeiro/google2fa.git",
"reference": "03f6fb65aaccc21d6f70969db652316ad003b83d"
"reference": "8df7d8fe0734c7ddad5fce2251adf4b3e9218643"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/antonioribeiro/google2fa/zipball/03f6fb65aaccc21d6f70969db652316ad003b83d",
"reference": "03f6fb65aaccc21d6f70969db652316ad003b83d",
"url": "https://api.github.com/repos/antonioribeiro/google2fa/zipball/8df7d8fe0734c7ddad5fce2251adf4b3e9218643",
"reference": "8df7d8fe0734c7ddad5fce2251adf4b3e9218643",
"shasum": ""
},
"require": {
@@ -2801,20 +2801,20 @@
"Two Factor Authentication",
"google2fa"
],
"time": "2019-09-11T19:19:55+00:00"
"time": "2019-09-18T22:34:47+00:00"
},
{
"name": "pragmarx/google2fa-laravel",
"version": "v1.1.1",
"version": "v1.1.2",
"source": {
"type": "git",
"url": "https://github.com/antonioribeiro/google2fa-laravel.git",
"reference": "3b14f1fa2753c7f9bb5abb6504601662d836d104"
"reference": "6d9787e0311879965c15d743be5022795af19653"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/antonioribeiro/google2fa-laravel/zipball/3b14f1fa2753c7f9bb5abb6504601662d836d104",
"reference": "3b14f1fa2753c7f9bb5abb6504601662d836d104",
"url": "https://api.github.com/repos/antonioribeiro/google2fa-laravel/zipball/6d9787e0311879965c15d743be5022795af19653",
"reference": "6d9787e0311879965c15d743be5022795af19653",
"shasum": ""
},
"require": {
@@ -2872,7 +2872,7 @@
"google2fa",
"laravel"
],
"time": "2019-09-13T02:06:13+00:00"
"time": "2019-09-13T22:23:38+00:00"
},
{
"name": "pragmarx/google2fa-qrcode",
@@ -5046,16 +5046,16 @@
},
{
"name": "tightenco/collect",
"version": "v6.0.2",
"version": "v6.0.3",
"source": {
"type": "git",
"url": "https://github.com/tightenco/collect.git",
"reference": "e35230cde9e682881e9ac27105d0f26c32eca6d6"
"reference": "4aea0cd7acbdff113968c9c4e735532e10ea1393"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/tightenco/collect/zipball/e35230cde9e682881e9ac27105d0f26c32eca6d6",
"reference": "e35230cde9e682881e9ac27105d0f26c32eca6d6",
"url": "https://api.github.com/repos/tightenco/collect/zipball/4aea0cd7acbdff113968c9c4e735532e10ea1393",
"reference": "4aea0cd7acbdff113968c9c4e735532e10ea1393",
"shasum": ""
},
"require": {
@@ -5092,7 +5092,7 @@
"collection",
"laravel"
],
"time": "2019-09-09T14:07:34+00:00"
"time": "2019-09-17T12:13:52+00:00"
},
{
"name": "tijsverkoyen/css-to-inline-styles",
@@ -6513,16 +6513,16 @@
},
{
"name": "phpunit/php-code-coverage",
"version": "7.0.7",
"version": "7.0.8",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-code-coverage.git",
"reference": "7743bbcfff2a907e9ee4a25be13d0f8ec5e73800"
"reference": "aa0d179a13284c7420fc281fc32750e6cc7c9e2f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/7743bbcfff2a907e9ee4a25be13d0f8ec5e73800",
"reference": "7743bbcfff2a907e9ee4a25be13d0f8ec5e73800",
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/aa0d179a13284c7420fc281fc32750e6cc7c9e2f",
"reference": "aa0d179a13284c7420fc281fc32750e6cc7c9e2f",
"shasum": ""
},
"require": {
@@ -6531,7 +6531,7 @@
"php": "^7.2",
"phpunit/php-file-iterator": "^2.0.2",
"phpunit/php-text-template": "^1.2.1",
"phpunit/php-token-stream": "^3.1.0",
"phpunit/php-token-stream": "^3.1.1",
"sebastian/code-unit-reverse-lookup": "^1.0.1",
"sebastian/environment": "^4.2.2",
"sebastian/version": "^2.0.1",
@@ -6572,7 +6572,7 @@
"testing",
"xunit"
],
"time": "2019-07-25T05:31:54+00:00"
"time": "2019-09-17T06:24:36+00:00"
},
{
"name": "phpunit/php-file-iterator",
@@ -6716,16 +6716,16 @@
},
{
"name": "phpunit/php-token-stream",
"version": "3.1.0",
"version": "3.1.1",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-token-stream.git",
"reference": "e899757bb3df5ff6e95089132f32cd59aac2220a"
"reference": "995192df77f63a59e47f025390d2d1fdf8f425ff"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/e899757bb3df5ff6e95089132f32cd59aac2220a",
"reference": "e899757bb3df5ff6e95089132f32cd59aac2220a",
"url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/995192df77f63a59e47f025390d2d1fdf8f425ff",
"reference": "995192df77f63a59e47f025390d2d1fdf8f425ff",
"shasum": ""
},
"require": {
@@ -6761,20 +6761,20 @@
"keywords": [
"tokenizer"
],
"time": "2019-07-25T05:29:42+00:00"
"time": "2019-09-17T06:23:10+00:00"
},
{
"name": "phpunit/phpunit",
"version": "8.3.4",
"version": "8.3.5",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "e31cce0cf4499c0ccdbbb211a3280d36ab341e36"
"reference": "302faed7059fde575cf3403a78c730c5e3a62750"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/e31cce0cf4499c0ccdbbb211a3280d36ab341e36",
"reference": "e31cce0cf4499c0ccdbbb211a3280d36ab341e36",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/302faed7059fde575cf3403a78c730c5e3a62750",
"reference": "302faed7059fde575cf3403a78c730c5e3a62750",
"shasum": ""
},
"require": {
@@ -6797,7 +6797,7 @@
"sebastian/comparator": "^3.0.2",
"sebastian/diff": "^3.0.2",
"sebastian/environment": "^4.2.2",
"sebastian/exporter": "^3.1.0",
"sebastian/exporter": "^3.1.1",
"sebastian/global-state": "^3.0.0",
"sebastian/object-enumerator": "^3.0.3",
"sebastian/resource-operations": "^2.0.1",
@@ -6844,7 +6844,7 @@
"testing",
"xunit"
],
"time": "2019-08-11T06:56:55+00:00"
"time": "2019-09-14T09:12:03+00:00"
},
{
"name": "roave/security-advisories",
@@ -7281,16 +7281,16 @@
},
{
"name": "sebastian/exporter",
"version": "3.1.1",
"version": "3.1.2",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/exporter.git",
"reference": "06a9a5947f47b3029d76118eb5c22802e5869687"
"reference": "68609e1261d215ea5b21b7987539cbfbe156ec3e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/06a9a5947f47b3029d76118eb5c22802e5869687",
"reference": "06a9a5947f47b3029d76118eb5c22802e5869687",
"url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/68609e1261d215ea5b21b7987539cbfbe156ec3e",
"reference": "68609e1261d215ea5b21b7987539cbfbe156ec3e",
"shasum": ""
},
"require": {
@@ -7344,7 +7344,7 @@
"export",
"exporter"
],
"time": "2019-08-11T12:43:14+00:00"
"time": "2019-09-14T09:02:43+00:00"
},
{
"name": "sebastian/global-state",