Skip to content

Firefly III: a personal finances manager

Fix #7457

James Colefb823ed42226
diff --git a/app/Handlers/Events/Model/BudgetLimitHandler.php b/app/Handlers/Events/Model/BudgetLimitHandler.php
index 7b050fd2f9..e9d5748589 100644
--- a/app/Handlers/Events/Model/BudgetLimitHandler.php
+++ b/app/Handlers/Events/Model/BudgetLimitHandler.php
@@ -180,7 +180,14 @@ class BudgetLimitHandler
$start = app('navigation')->startOfPeriod($budgetLimit->start_date, $viewRange);
$end = app('navigation')->startOfPeriod($budgetLimit->end_date, $viewRange);
$end = app('navigation')->endOfPeriod($end, $viewRange);
- $user = $budgetLimit->budget->user;
+ $user = $budgetLimit?->budget?->user;
+
+ // sanity check. It's rare but this happens.
+ if(null === $user) {
+ Log::warning('User is null, cannot continue.');
+ $budgetLimit->forceDelete();
+ return;
+ }
// limit period in total is:
$limitPeriod = Period::make($start, $end, precision: Precision::DAY(), boundaries: Boundaries::EXCLUDE_NONE());