mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Various improved error catching.
This commit is contained in:
parent
70b6e39cd7
commit
5068fc76c1
@ -24,6 +24,7 @@ declare(strict_types=1);
|
|||||||
namespace FireflyIII\Http\Controllers;
|
namespace FireflyIII\Http\Controllers;
|
||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
use Carbon\Exceptions\InvalidFormatException;
|
||||||
use Exception;
|
use Exception;
|
||||||
use FireflyIII\Events\RequestedVersionCheckStatus;
|
use FireflyIII\Events\RequestedVersionCheckStatus;
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
@ -66,12 +67,24 @@ class HomeController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function dateRange(Request $request): JsonResponse
|
public function dateRange(Request $request): JsonResponse
|
||||||
{
|
{
|
||||||
$start = new Carbon($request->get('start'));
|
try {
|
||||||
$end = new Carbon($request->get('end'));
|
$stringStart = e((string)$request->get('start'));
|
||||||
|
$start = Carbon::createFromFormat('Y-m-d', $stringStart);
|
||||||
|
} catch (InvalidFormatException $e) {
|
||||||
|
Log::error(sprintf('Start: could not parse date string "%s" so ignore it.', $stringStart));
|
||||||
|
$start = Carbon::now()->startOfMonth();
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
$stringEnd = e((string)$request->get('end'));
|
||||||
|
$end = Carbon::createFromFormat('Y-m-d', $stringEnd);
|
||||||
|
} catch (InvalidFormatException $e) {
|
||||||
|
Log::error(sprintf('End could not parse date string "%s" so ignore it.', $stringEnd));
|
||||||
|
$end = Carbon::now()->endOfMonth();
|
||||||
|
}
|
||||||
$label = $request->get('label');
|
$label = $request->get('label');
|
||||||
$isCustomRange = false;
|
$isCustomRange = false;
|
||||||
|
|
||||||
Log::debug('Received dateRange', ['start' => $request->get('start'), 'end' => $request->get('end'), 'label' => $request->get('label')]);
|
Log::debug('Received dateRange', ['start' => $stringStart, 'end' => $stringEnd, 'label' => $request->get('label')]);
|
||||||
// check if the label is "everything" or "Custom range" which will betray
|
// check if the label is "everything" or "Custom range" which will betray
|
||||||
// a possible problem with the budgets.
|
// a possible problem with the budgets.
|
||||||
if ($label === (string)trans('firefly.everything') || $label === (string)trans('firefly.customRange')) {
|
if ($label === (string)trans('firefly.everything') || $label === (string)trans('firefly.customRange')) {
|
||||||
|
@ -84,6 +84,22 @@ class CreateSupportTables extends Migration
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function createConfigurationTable(): void
|
||||||
|
{
|
||||||
|
if (!Schema::hasTable('configuration')) {
|
||||||
|
Schema::create(
|
||||||
|
'configuration',
|
||||||
|
static function (Blueprint $table) {
|
||||||
|
$table->increments('id');
|
||||||
|
$table->timestamps();
|
||||||
|
$table->softDeletes();
|
||||||
|
$table->string('name', 50);
|
||||||
|
$table->text('data');
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private function createCurrencyTable(): void
|
private function createCurrencyTable(): void
|
||||||
{
|
{
|
||||||
if (!Schema::hasTable('transaction_currencies')) {
|
if (!Schema::hasTable('transaction_currencies')) {
|
||||||
@ -104,24 +120,6 @@ class CreateSupportTables extends Migration
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function createTransactionTypeTable(): void
|
|
||||||
{
|
|
||||||
if (!Schema::hasTable('transaction_types')) {
|
|
||||||
Schema::create(
|
|
||||||
'transaction_types',
|
|
||||||
static function (Blueprint $table) {
|
|
||||||
$table->increments('id');
|
|
||||||
$table->timestamps();
|
|
||||||
$table->softDeletes();
|
|
||||||
$table->string('type', 50);
|
|
||||||
|
|
||||||
// type must be unique.
|
|
||||||
$table->unique(['type']);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private function createJobsTable(): void
|
private function createJobsTable(): void
|
||||||
{
|
{
|
||||||
if (!Schema::hasTable('jobs')) {
|
if (!Schema::hasTable('jobs')) {
|
||||||
@ -158,6 +156,24 @@ class CreateSupportTables extends Migration
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function createPermissionRoleTable(): void
|
||||||
|
{
|
||||||
|
if (!Schema::hasTable('permission_role')) {
|
||||||
|
Schema::create(
|
||||||
|
'permission_role',
|
||||||
|
static function (Blueprint $table) {
|
||||||
|
$table->integer('permission_id')->unsigned();
|
||||||
|
$table->integer('role_id')->unsigned();
|
||||||
|
|
||||||
|
$table->foreign('permission_id')->references('id')->on('permissions')->onUpdate('cascade')->onDelete('cascade');
|
||||||
|
$table->foreign('role_id')->references('id')->on('roles')->onUpdate('cascade')->onDelete('cascade');
|
||||||
|
|
||||||
|
$table->primary(['permission_id', 'role_id']);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private function createPermissionsTable(): void
|
private function createPermissionsTable(): void
|
||||||
{
|
{
|
||||||
if (!Schema::hasTable('permissions')) {
|
if (!Schema::hasTable('permissions')) {
|
||||||
@ -190,24 +206,6 @@ class CreateSupportTables extends Migration
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function createPermissionRoleTable(): void
|
|
||||||
{
|
|
||||||
if (!Schema::hasTable('permission_role')) {
|
|
||||||
Schema::create(
|
|
||||||
'permission_role',
|
|
||||||
static function (Blueprint $table) {
|
|
||||||
$table->integer('permission_id')->unsigned();
|
|
||||||
$table->integer('role_id')->unsigned();
|
|
||||||
|
|
||||||
$table->foreign('permission_id')->references('id')->on('permissions')->onUpdate('cascade')->onDelete('cascade');
|
|
||||||
$table->foreign('role_id')->references('id')->on('roles')->onUpdate('cascade')->onDelete('cascade');
|
|
||||||
|
|
||||||
$table->primary(['permission_id', 'role_id']);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private function createSessionsTable(): void
|
private function createSessionsTable(): void
|
||||||
{
|
{
|
||||||
if (!Schema::hasTable('sessions')) {
|
if (!Schema::hasTable('sessions')) {
|
||||||
@ -225,17 +223,19 @@ class CreateSupportTables extends Migration
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function createConfigurationTable(): void
|
private function createTransactionTypeTable(): void
|
||||||
{
|
{
|
||||||
if (!Schema::hasTable('configuration')) {
|
if (!Schema::hasTable('transaction_types')) {
|
||||||
Schema::create(
|
Schema::create(
|
||||||
'configuration',
|
'transaction_types',
|
||||||
static function (Blueprint $table) {
|
static function (Blueprint $table) {
|
||||||
$table->increments('id');
|
$table->increments('id');
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
$table->softDeletes();
|
$table->softDeletes();
|
||||||
$table->string('name', 50);
|
$table->string('type', 50);
|
||||||
$table->text('data');
|
|
||||||
|
// type must be unique.
|
||||||
|
$table->unique(['type']);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -124,44 +124,6 @@ class CreateMainTables extends Migration
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function createPiggyBanksTable(): void
|
|
||||||
{
|
|
||||||
if (!Schema::hasTable('piggy_banks')) {
|
|
||||||
Schema::create(
|
|
||||||
'piggy_banks',
|
|
||||||
static function (Blueprint $table) {
|
|
||||||
$table->increments('id');
|
|
||||||
$table->timestamps();
|
|
||||||
$table->softDeletes();
|
|
||||||
$table->integer('account_id', false, true);
|
|
||||||
$table->string('name', 1024);
|
|
||||||
$table->decimal('targetamount', 32, 12);
|
|
||||||
$table->date('startdate')->nullable();
|
|
||||||
$table->date('targetdate')->nullable();
|
|
||||||
$table->integer('order', false, true)->default(0);
|
|
||||||
$table->boolean('active')->default(0);
|
|
||||||
$table->boolean('encrypted')->default(1);
|
|
||||||
$table->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade');
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!Schema::hasTable('piggy_bank_repetitions')) {
|
|
||||||
Schema::create(
|
|
||||||
'piggy_bank_repetitions',
|
|
||||||
static function (Blueprint $table) {
|
|
||||||
$table->increments('id');
|
|
||||||
$table->timestamps();
|
|
||||||
$table->integer('piggy_bank_id', false, true);
|
|
||||||
$table->date('startdate')->nullable();
|
|
||||||
$table->date('targetdate')->nullable();
|
|
||||||
$table->decimal('currentamount', 32, 12);
|
|
||||||
$table->foreign('piggy_bank_id')->references('id')->on('piggy_banks')->onDelete('cascade');
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private function createAttachmentsTable(): void
|
private function createAttachmentsTable(): void
|
||||||
{
|
{
|
||||||
if (!Schema::hasTable('attachments')) {
|
if (!Schema::hasTable('attachments')) {
|
||||||
@ -323,6 +285,44 @@ class CreateMainTables extends Migration
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function createPiggyBanksTable(): void
|
||||||
|
{
|
||||||
|
if (!Schema::hasTable('piggy_banks')) {
|
||||||
|
Schema::create(
|
||||||
|
'piggy_banks',
|
||||||
|
static function (Blueprint $table) {
|
||||||
|
$table->increments('id');
|
||||||
|
$table->timestamps();
|
||||||
|
$table->softDeletes();
|
||||||
|
$table->integer('account_id', false, true);
|
||||||
|
$table->string('name', 1024);
|
||||||
|
$table->decimal('targetamount', 32, 12);
|
||||||
|
$table->date('startdate')->nullable();
|
||||||
|
$table->date('targetdate')->nullable();
|
||||||
|
$table->integer('order', false, true)->default(0);
|
||||||
|
$table->boolean('active')->default(0);
|
||||||
|
$table->boolean('encrypted')->default(1);
|
||||||
|
$table->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade');
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Schema::hasTable('piggy_bank_repetitions')) {
|
||||||
|
Schema::create(
|
||||||
|
'piggy_bank_repetitions',
|
||||||
|
static function (Blueprint $table) {
|
||||||
|
$table->increments('id');
|
||||||
|
$table->timestamps();
|
||||||
|
$table->integer('piggy_bank_id', false, true);
|
||||||
|
$table->date('startdate')->nullable();
|
||||||
|
$table->date('targetdate')->nullable();
|
||||||
|
$table->decimal('currentamount', 32, 12);
|
||||||
|
$table->foreign('piggy_bank_id')->references('id')->on('piggy_banks')->onDelete('cascade');
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private function createPreferencesTable(): void
|
private function createPreferencesTable(): void
|
||||||
{
|
{
|
||||||
if (!Schema::hasTable('preferences')) {
|
if (!Schema::hasTable('preferences')) {
|
||||||
|
@ -23,7 +23,9 @@
|
|||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\QueryException;
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
use Illuminate\Support\Facades\Schema;
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -41,8 +43,16 @@ return new class () extends Migration {
|
|||||||
'currency_exchange_rates',
|
'currency_exchange_rates',
|
||||||
function (Blueprint $table) {
|
function (Blueprint $table) {
|
||||||
if (!Schema::hasColumn('currency_exchange_rates', 'user_group_id')) {
|
if (!Schema::hasColumn('currency_exchange_rates', 'user_group_id')) {
|
||||||
|
try {
|
||||||
$table->bigInteger('user_group_id', false, true)->nullable()->after('user_id');
|
$table->bigInteger('user_group_id', false, true)->nullable()->after('user_id');
|
||||||
|
} catch (QueryException $e) {
|
||||||
|
Log::error(sprintf('Could not add column "user_group_id" to table "currency_exchange_rates": %s', $e->getMessage()));
|
||||||
|
}
|
||||||
|
try {
|
||||||
$table->foreign('user_group_id', 'cer_to_ugi')->references('id')->on('user_groups')->onDelete('set null')->onUpdate('cascade');
|
$table->foreign('user_group_id', 'cer_to_ugi')->references('id')->on('user_groups')->onDelete('set null')->onUpdate('cascade');
|
||||||
|
} catch (QueryException $e) {
|
||||||
|
Log::error(sprintf('Could not add foreign key "cer_to_ugi" to table "currency_exchange_rates": %s', $e->getMessage()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -58,9 +68,17 @@ return new class () extends Migration {
|
|||||||
Schema::table(
|
Schema::table(
|
||||||
'currency_exchange_rates',
|
'currency_exchange_rates',
|
||||||
function (Blueprint $table) {
|
function (Blueprint $table) {
|
||||||
|
try {
|
||||||
$table->dropForeign('cer_to_ugi');
|
$table->dropForeign('cer_to_ugi');
|
||||||
|
} catch (QueryException $e) {
|
||||||
|
Log::error(sprintf('Could not drop foreign key "cer_to_ugi" from table "currency_exchange_rates": %s', $e->getMessage()));
|
||||||
|
}
|
||||||
if (Schema::hasColumn('currency_exchange_rates', 'user_group_id')) {
|
if (Schema::hasColumn('currency_exchange_rates', 'user_group_id')) {
|
||||||
|
try {
|
||||||
$table->dropColumn('user_group_id');
|
$table->dropColumn('user_group_id');
|
||||||
|
} catch (QueryException $e) {
|
||||||
|
Log::error(sprintf('Could not drop column "user_group_id" from table "currency_exchange_rates": %s', $e->getMessage()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -23,7 +23,9 @@
|
|||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\QueryException;
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
use Illuminate\Support\Facades\Schema;
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
return new class() extends Migration {
|
return new class() extends Migration {
|
||||||
@ -34,6 +36,7 @@ return new class () extends Migration {
|
|||||||
*/
|
*/
|
||||||
public function up()
|
public function up()
|
||||||
{
|
{
|
||||||
|
try {
|
||||||
Schema::create('notifications', function (Blueprint $table) {
|
Schema::create('notifications', function (Blueprint $table) {
|
||||||
$table->uuid('id')->primary();
|
$table->uuid('id')->primary();
|
||||||
$table->string('type');
|
$table->string('type');
|
||||||
@ -42,6 +45,9 @@ return new class () extends Migration {
|
|||||||
$table->timestamp('read_at')->nullable();
|
$table->timestamp('read_at')->nullable();
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
});
|
});
|
||||||
|
} catch (QueryException $e) {
|
||||||
|
Log::error(sprintf('Could not create table "notifications": %s', $e->getMessage()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -23,7 +23,9 @@
|
|||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\QueryException;
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
use Illuminate\Support\Facades\Schema;
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
return new class() extends Migration {
|
return new class() extends Migration {
|
||||||
@ -34,6 +36,7 @@ return new class () extends Migration {
|
|||||||
*/
|
*/
|
||||||
public function up(): void
|
public function up(): void
|
||||||
{
|
{
|
||||||
|
try {
|
||||||
Schema::create('invited_users', function (Blueprint $table) {
|
Schema::create('invited_users', function (Blueprint $table) {
|
||||||
$table->id();
|
$table->id();
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
@ -44,6 +47,9 @@ return new class () extends Migration {
|
|||||||
$table->boolean('redeemed');
|
$table->boolean('redeemed');
|
||||||
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
||||||
});
|
});
|
||||||
|
} catch (QueryException $e) {
|
||||||
|
Log::error(sprintf('Could not create table "invited_users": %s', $e->getMessage()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -23,7 +23,9 @@
|
|||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\QueryException;
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
use Illuminate\Support\Facades\Schema;
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
return new class() extends Migration {
|
return new class() extends Migration {
|
||||||
@ -34,6 +36,7 @@ return new class () extends Migration {
|
|||||||
*/
|
*/
|
||||||
public function up()
|
public function up()
|
||||||
{
|
{
|
||||||
|
try {
|
||||||
Schema::create('audit_log_entries', function (Blueprint $table) {
|
Schema::create('audit_log_entries', function (Blueprint $table) {
|
||||||
$table->id();
|
$table->id();
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
@ -49,6 +52,9 @@ return new class () extends Migration {
|
|||||||
$table->text('before')->nullable();
|
$table->text('before')->nullable();
|
||||||
$table->text('after')->nullable();
|
$table->text('after')->nullable();
|
||||||
});
|
});
|
||||||
|
} catch (QueryException $e) {
|
||||||
|
Log::error(sprintf('Could not create table "audit_log_entries": %s', $e->getMessage()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user