Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Fix null pointer
James Colef9463e02a2d6
diff --git a/app/Api/V1/Controllers/Data/DestroyController.php b/app/Api/V1/Controllers/Data/DestroyController.phpindex 3d2caf491a..61da46dcf1 100644--- a/app/Api/V1/Controllers/Data/DestroyController.php+++ b/app/Api/V1/Controllers/Data/DestroyController.php@@ -45,6 +45,7 @@ use FireflyIII\Repositories\Tag\TagRepositoryInterface;use FireflyIII\Services\Internal\Destroy\AccountDestroyService;use FireflyIII\Services\Internal\Destroy\JournalDestroyService;use Illuminate\Http\JsonResponse;+use Illuminate\Support\Facades\Log;/*** Class DestroyController@@ -175,12 +176,14 @@ class DestroyController extends Controller$count = $account->transactions()->count();if (true === $this->unused && 0 === $count) {app('log')->info(sprintf('Deleted unused account #%d "%s"', $account->id, $account->name));+ Log::channel('audit')->info(sprintf('Deleted unused account #%d "%s"', $account->id, $account->name));$service->destroy($account, null);continue;}if (false === $this->unused) {app('log')->info(sprintf('Deleting account #%d "%s"', $account->id, $account->name));+ Log::channel('audit')->info(sprintf('Deleted account #%d "%s"', $account->id, $account->name));$service->destroy($account, null);}}diff --git a/app/Http/Requests/RecurrenceFormRequest.php b/app/Http/Requests/RecurrenceFormRequest.phpindex 544788e740..0075c3babf 100644--- a/app/Http/Requests/RecurrenceFormRequest.php+++ b/app/Http/Requests/RecurrenceFormRequest.php@@ -280,12 +280,12 @@ class RecurrenceFormRequest extends FormRequestif ('deposit' === $type) {$throwError = false;$sourceId = (int) $data['deposit_source_id'];- $destinationId = (int) $data['destination_id'];+ $destinationId = (int) ($data['destination_id'] ?? 0);}if ('transfer' === $type) {$throwError = false;$sourceId = (int) $data['source_id'];- $destinationId = (int) $data['destination_id'];+ $destinationId = (int) ($data['destination_id'] ?? 0);}if (true === $throwError) {throw new FireflyException(sprintf('Cannot handle transaction type "%s"', $this->convertString('transaction_type')));diff --git a/app/Repositories/Bill/BillRepository.php b/app/Repositories/Bill/BillRepository.phpindex 1c5ded5333..59d04874ab 100644--- a/app/Repositories/Bill/BillRepository.php+++ b/app/Repositories/Bill/BillRepository.php@@ -42,6 +42,7 @@ use Illuminate\Contracts\Auth\Authenticatable;use Illuminate\Database\Query\JoinClause;use Illuminate\Pagination\LengthAwarePaginator;use Illuminate\Support\Collection;+use Illuminate\Support\Facades\Log;/*** Class BillRepository.@@ -105,6 +106,7 @@ class BillRepository implements BillRepositoryInterfacepublic function destroyAll(): void{+ Log::channel('audit')->info('Delete all bills through destroyAll');$this->user->bills()->delete();}diff --git a/app/Repositories/Budget/AvailableBudgetRepository.php b/app/Repositories/Budget/AvailableBudgetRepository.phpindex 237b4faea4..d5e09c4798 100644--- a/app/Repositories/Budget/AvailableBudgetRepository.php+++ b/app/Repositories/Budget/AvailableBudgetRepository.php@@ -30,6 +30,7 @@ use FireflyIII\User;use Illuminate\Contracts\Auth\Authenticatable;use Illuminate\Database\Eloquent\Builder;use Illuminate\Support\Collection;+use Illuminate\Support\Facades\Log;/*** Class AvailableBudgetRepository@@ -79,6 +80,7 @@ class AvailableBudgetRepository implements AvailableBudgetRepositoryInterface*/public function destroyAll(): void{+ Log::channel('audit')->info('Delete all available budgets through destroyAll');$this->user->availableBudgets()->delete();}diff --git a/app/Repositories/Budget/BudgetLimitRepository.php b/app/Repositories/Budget/BudgetLimitRepository.phpindex db41011401..0975c9f943 100644--- a/app/Repositories/Budget/BudgetLimitRepository.php+++ b/app/Repositories/Budget/BudgetLimitRepository.php@@ -33,6 +33,7 @@ use FireflyIII\User;use Illuminate\Contracts\Auth\Authenticatable;use Illuminate\Database\Eloquent\Builder;use Illuminate\Support\Collection;+use Illuminate\Support\Facades\Log;/*** Class BudgetLimitRepository@@ -108,6 +109,7 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface/** @var Budget $budget */foreach ($budgets as $budget) {+ Log::channel('audit')->info(sprintf('Delete all budget limits of budget #%d ("%s") through destroyAll', $budget->id, $budget->name));$budget->budgetlimits()->delete();}}diff --git a/app/Repositories/Budget/BudgetRepository.php b/app/Repositories/Budget/BudgetRepository.phpindex 4d556a2d0a..8cc0b7b851 100644--- a/app/Repositories/Budget/BudgetRepository.php+++ b/app/Repositories/Budget/BudgetRepository.php@@ -45,6 +45,7 @@ use FireflyIII\User;use Illuminate\Contracts\Auth\Authenticatable;use Illuminate\Database\QueryException;use Illuminate\Support\Collection;+use Illuminate\Support\Facades\Log;/*** Class BudgetRepository.@@ -329,6 +330,7 @@ class BudgetRepository implements BudgetRepositoryInterfaceRuleAction::where('action_type', 'set_budget')->where('action_value', (string) $budget->id)->delete();$budget->delete();}+ Log::channel('audit')->info('Delete all budgets through destroyAll');}public function getBudgets(): Collectiondiff --git a/app/Repositories/Category/CategoryRepository.php b/app/Repositories/Category/CategoryRepository.phpindex 97e64c10cb..f9161c4735 100644--- a/app/Repositories/Category/CategoryRepository.php+++ b/app/Repositories/Category/CategoryRepository.php@@ -36,6 +36,7 @@ use FireflyIII\Services\Internal\Update\CategoryUpdateService;use FireflyIII\User;use Illuminate\Contracts\Auth\Authenticatable;use Illuminate\Support\Collection;+use Illuminate\Support\Facades\Log;/*** Class CategoryRepository.@@ -88,6 +89,7 @@ class CategoryRepository implements CategoryRepositoryInterfaceRuleAction::where('action_type', 'set_category')->where('action_value', $category->name)->delete();$category->delete();}+ Log::channel('audit')->info('Delete all categories through destroyAll');}/**diff --git a/app/Repositories/PiggyBank/PiggyBankRepository.php b/app/Repositories/PiggyBank/PiggyBankRepository.phpindex 75710cdedc..0e55fc4265 100644--- a/app/Repositories/PiggyBank/PiggyBankRepository.php+++ b/app/Repositories/PiggyBank/PiggyBankRepository.php@@ -36,6 +36,7 @@ use FireflyIII\Repositories\Journal\JournalRepositoryInterface;use FireflyIII\User;use Illuminate\Contracts\Auth\Authenticatable;use Illuminate\Support\Collection;+use Illuminate\Support\Facades\Log;/*** Class PiggyBankRepository.@@ -48,6 +49,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterfacepublic function destroyAll(): void{+ Log::channel('audit')->info('Delete all piggy banks through destroyAll');$this->user->piggyBanks()->delete();}diff --git a/app/Repositories/Recurring/RecurringRepository.php b/app/Repositories/Recurring/RecurringRepository.phpindex c3e0ae0b2c..ec301f9134 100644--- a/app/Repositories/Recurring/RecurringRepository.php+++ b/app/Repositories/Recurring/RecurringRepository.php@@ -47,6 +47,7 @@ use Illuminate\Contracts\Auth\Authenticatable;use Illuminate\Database\Eloquent\Builder;use Illuminate\Pagination\LengthAwarePaginator;use Illuminate\Support\Collection;+use Illuminate\Support\Facades\Log;/*** Class RecurringRepository@@ -116,6 +117,7 @@ class RecurringRepository implements RecurringRepositoryInterfacepublic function destroyAll(): void{+ Log::channel('audit')->info('Delete all recurring transactions through destroyAll');$this->user->recurrences()->delete();}diff --git a/app/Repositories/RuleGroup/RuleGroupRepository.php b/app/Repositories/RuleGroup/RuleGroupRepository.phpindex fa641f7d17..5655ab11f0 100644--- a/app/Repositories/RuleGroup/RuleGroupRepository.php+++ b/app/Repositories/RuleGroup/RuleGroupRepository.php@@ -31,6 +31,7 @@ use FireflyIII\User;use Illuminate\Contracts\Auth\Authenticatable;use Illuminate\Database\Eloquent\Relations\HasMany;use Illuminate\Support\Collection;+use Illuminate\Support\Facades\Log;/*** Class RuleGroupRepository.@@ -152,7 +153,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterfacepublic function destroyAll(): void{- $groups = $this->get();+ Log::channel('audit')->info('Delete all rule groups through destroyAll'); $groups = $this->get();/** @var RuleGroup $group */foreach ($groups as $group) {diff --git a/app/Repositories/Tag/TagRepository.php b/app/Repositories/Tag/TagRepository.phpindex f9c7beb935..4a9b73f028 100644--- a/app/Repositories/Tag/TagRepository.php+++ b/app/Repositories/Tag/TagRepository.php@@ -34,6 +34,7 @@ use FireflyIII\Models\TransactionType;use FireflyIII\User;use Illuminate\Contracts\Auth\Authenticatable;use Illuminate\Support\Collection;+use Illuminate\Support\Facades\Log;/*** Class TagRepository.@@ -64,6 +65,7 @@ class TagRepository implements TagRepositoryInterface*/public function destroyAll(): void{+ Log::channel('audit')->info('Delete all tags through destroyAll');$tags = $this->get();/** @var Tag $tag */