diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index 8dc9a621fc..38db72eb10 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -31,7 +31,6 @@ use FireflyIII\Exceptions\FireflyException; use FireflyIII\Helpers\Collector\GroupCollectorInterface; use FireflyIII\Http\Middleware\Installer; use FireflyIII\Models\AccountType; -use FireflyIII\Models\TransactionJournal; use FireflyIII\Repositories\Account\AccountRepositoryInterface; use FireflyIII\Repositories\Bill\BillRepositoryInterface; use FireflyIII\User; @@ -69,7 +68,7 @@ class HomeController extends Controller public function dateRange(Request $request): JsonResponse { $stringStart = ''; - $stringEnd = ''; + $stringEnd = ''; try { $stringStart = e((string)$request->get('start')); $start = Carbon::createFromFormat('Y-m-d', $stringStart); @@ -84,6 +83,13 @@ class HomeController extends Controller app('log')->error(sprintf('End could not parse date string "%s" so ignore it.', $stringEnd)); $end = Carbon::now()->endOfMonth(); } + if (false === $start) { + $start = Carbon::now()->startOfMonth(); + } + if (false === $end) { + $end = Carbon::now()->endOfMonth(); + } + $label = $request->get('label'); $isCustomRange = false; @@ -128,20 +134,26 @@ class HomeController extends Controller if (0 === $count) { return redirect(route('new-user.index')); } - $subTitle = (string)trans('firefly.welcome_back'); - $transactions = []; - $frontPage = app('preferences')->getFresh('frontPageAccounts', $repository->getAccountsByType([AccountType::ASSET])->pluck('id')->toArray()); + $subTitle = (string)trans('firefly.welcome_back'); + $transactions = []; + $frontPage = app('preferences')->getFresh('frontPageAccounts', $repository->getAccountsByType([AccountType::ASSET])->pluck('id')->toArray()); + $frontPageArray = $frontPage->data; + if (!is_array($frontPageArray)) { + $frontPageArray = []; + } + + /** @var Carbon $start */ $start = session('start', today(config('app.timezone'))->startOfMonth()); /** @var Carbon $end */ $end = session('end', today(config('app.timezone'))->endOfMonth()); - $accounts = $repository->getAccountsById($frontPage->data); + $accounts = $repository->getAccountsById($frontPageArray); $today = today(config('app.timezone')); // sort frontpage accounts by order $accounts = $accounts->sortBy('order'); - app('log')->debug('Frontpage accounts are ', $frontPage->data); + app('log')->debug('Frontpage accounts are ', $frontPageArray); /** @var BillRepositoryInterface $billRepository */ $billRepository = app(BillRepositoryInterface::class); diff --git a/app/Http/Controllers/Json/RecurrenceController.php b/app/Http/Controllers/Json/RecurrenceController.php index 37c7ca28a4..40dfe3f987 100644 --- a/app/Http/Controllers/Json/RecurrenceController.php +++ b/app/Http/Controllers/Json/RecurrenceController.php @@ -79,6 +79,11 @@ class RecurrenceController extends Controller $repetitionType = explode(',', $request->get('type'))[0]; $repetitions = (int)$request->get('reps'); $repetitionMoment = ''; + + if(false === $start || false === $end || false === $firstDate || false === $endDate) { + return response()->json(); + } + $start->startOfDay(); // if $firstDate is beyond $end, simply return an empty array. @@ -148,10 +153,14 @@ class RecurrenceController extends Controller $string = '' === (string)$request->get('date') ? date('Y-m-d') : (string)$request->get('date'); $today = today(config('app.timezone'))->startOfDay(); try { - $date = Carbon::createFromFormat('Y-m-d', $string, config('app.timezone'))->startOfDay(); + $date = Carbon::createFromFormat('Y-m-d', $string, config('app.timezone')); } catch (InvalidFormatException $e) { $date = Carbon::today(config('app.timezone')); } + if(false === $date) { + return response()->json(); + } + $date->startOfDay(); $preSelected = (string)$request->get('pre_select'); $locale = app('steam')->getLocale(); diff --git a/app/Http/Controllers/PreferencesController.php b/app/Http/Controllers/PreferencesController.php index e112c3b8eb..cc5d9852cd 100644 --- a/app/Http/Controllers/PreferencesController.php +++ b/app/Http/Controllers/PreferencesController.php @@ -91,13 +91,18 @@ class PreferencesController extends Controller if ('opt_group_' === $role) { $role = 'opt_group_defaultAsset'; } - $groupedAccounts[trans(sprintf('firefly.%s', $role))][$account->id] = $account->name; + $groupedAccounts[(string)trans(sprintf('firefly.%s', $role))][$account->id] = $account->name; } ksort($groupedAccounts); - $accountIds = $accounts->pluck('id')->toArray(); - $viewRange = app('navigation')->getViewRange(false); - $frontPageAccounts = app('preferences')->get('frontPageAccounts', $accountIds); + /** @var array $accountIds */ + $accountIds = $accounts->pluck('id')->toArray(); + $viewRange = app('navigation')->getViewRange(false); + $frontPageAccountsPref = app('preferences')->get('frontPageAccounts', $accountIds); + $frontPageAccounts = $frontPageAccountsPref->data; + if (!is_array($frontPageAccounts)) { + $frontPageAccounts = $accountIds; + } $language = app('steam')->getLanguage(); $languages = config('firefly.languages'); $locale = app('preferences')->get('locale', config('firefly.default_locale', 'equal'))->data; @@ -106,7 +111,10 @@ class PreferencesController extends Controller $slackUrl = app('preferences')->get('slack_webhook_url', '')->data; $customFiscalYear = app('preferences')->get('customFiscalYear', 0)->data; $fiscalYearStartStr = app('preferences')->get('fiscalYearStart', '01-01')->data; - $fiscalYearStart = date('Y') . '-' . $fiscalYearStartStr; + if (is_array($fiscalYearStartStr)) { + $fiscalYearStartStr = '01-01'; + } + $fiscalYearStart = sprintf('%s-%s', date('Y'), (string)$fiscalYearStartStr); $tjOptionalFields = app('preferences')->get('transaction_journal_optional_fields', [])->data; $availableDarkModes = config('firefly.available_dark_modes'); @@ -121,7 +129,7 @@ class PreferencesController extends Controller // list of locales also has "equal" which makes it equal to whatever the language is. try { - $locales = json_decode(file_get_contents(resource_path(sprintf('lang/%s/locales.json', $language))), true, 512, JSON_THROW_ON_ERROR); + $locales = json_decode((string)file_get_contents(resource_path(sprintf('lang/%s/locales.json', $language))), true, 512, JSON_THROW_ON_ERROR); } catch (JsonException $e) { app('log')->error($e->getMessage()); $locales = []; @@ -129,12 +137,12 @@ class PreferencesController extends Controller $locales = ['equal' => (string)trans('firefly.equal_to_language')] + $locales; // an important fallback is that the frontPageAccount array gets refilled automatically // when it turns up empty. - if (0 === count($frontPageAccounts->data)) { + if (0 === count($frontPageAccounts)) { $frontPageAccounts = $accountIds; } // for the demo user, the slackUrl is automatically emptied. - // this isn't really secure but it means that the demo site has a semi-secret + // this isn't really secure, but it means that the demo site has a semi-secret // slackUrl. if (auth()->user()->hasRole('demo')) { $slackUrl = ''; diff --git a/app/Http/Controllers/ProfileController.php b/app/Http/Controllers/ProfileController.php index 7f40e7098c..5f724b5714 100644 --- a/app/Http/Controllers/ProfileController.php +++ b/app/Http/Controllers/ProfileController.php @@ -36,7 +36,6 @@ use FireflyIII\Http\Requests\ProfileFormRequest; use FireflyIII\Http\Requests\TokenFormRequest; use FireflyIII\Models\Preference; use FireflyIII\Repositories\User\UserRepositoryInterface; -use FireflyIII\Support\Facades\Preferences; use FireflyIII\Support\Http\Controllers\CreateStuff; use FireflyIII\User; use Google2FA; @@ -129,6 +128,9 @@ class ProfileController extends Controller // get secret from session and flash $secret = $secretPreference->data; } + if (is_array($secret)) { + $secret = ''; + } // generate recovery codes if not in session: $recoveryCodes = ''; @@ -144,10 +146,13 @@ class ProfileController extends Controller if (null !== $codesPreference) { $recoveryCodes = $codesPreference->data; } + if (!is_array($recoveryCodes)) { + $recoveryCodes = []; + } $codes = implode("\r\n", $recoveryCodes); - $image = Google2FA::getQRCodeInline($domain, auth()->user()->email, $secret); + $image = Google2FA::getQRCodeInline($domain, auth()->user()->email, (string)$secret); return view('profile.code', compact('image', 'secret', 'codes')); } @@ -283,7 +288,11 @@ class ProfileController extends Controller $subTitle = $user->email; $userId = $user->id; $enabled2FA = null !== $user->mfa_secret; - $mfaBackupCount = count(app('preferences')->get('mfa_recovery', [])->data); + $recoveryData = app('preferences')->get('mfa_recovery', [])->data; + if (!is_array($recoveryData)) { + $recoveryData = []; + } + $mfaBackupCount = count($recoveryData); $this->createOAuthKeys(); if (0 === $count) { @@ -499,6 +508,12 @@ class ProfileController extends Controller /** @var UserRepositoryInterface $repository */ $repository = app(UserRepositoryInterface::class); $secret = app('preferences')->get('temp-mfa-secret')?->data; + if (is_array($secret)) { + $secret = null; + } + if (is_int($secret)) { + $secret = (string)$secret; + } $repository->setMFACode($user, $secret); diff --git a/app/Http/Controllers/Recurring/EditController.php b/app/Http/Controllers/Recurring/EditController.php index f61ae3ac60..8b674ec82c 100644 --- a/app/Http/Controllers/Recurring/EditController.php +++ b/app/Http/Controllers/Recurring/EditController.php @@ -181,6 +181,7 @@ class EditController extends Controller $request->session()->flash('success', (string)trans('firefly.updated_recurrence', ['title' => $recurrence->title])); // store new attachment(s): + /** @var array|null $files */ $files = $request->hasFile('attachments') ? $request->file('attachments') : null; if (null !== $files && !auth()->user()->hasRole('demo')) { $this->attachments->saveAttachmentsForModel($recurrence, $files); diff --git a/app/Http/Controllers/ReportController.php b/app/Http/Controllers/ReportController.php index cfa14e62f8..39a90fe943 100644 --- a/app/Http/Controllers/ReportController.php +++ b/app/Http/Controllers/ReportController.php @@ -49,12 +49,8 @@ use Psr\Container\NotFoundExceptionInterface; class ReportController extends Controller { use RenderPartialViews; - - /** @var ReportHelperInterface Helper interface. */ - protected $helper; - - /** @var BudgetRepositoryInterface The budget repository */ - private $repository; + protected ReportHelperInterface $helper; + private BudgetRepositoryInterface $repository; /** * ReportController constructor. @@ -291,7 +287,7 @@ class ReportController extends Controller if ('opt_group_' === $role) { $role = 'opt_group_defaultAsset'; } - $groupedAccounts[trans(sprintf('firefly.%s', $role))][$account->id] = $account; + $groupedAccounts[(string)trans(sprintf('firefly.%s', $role))][$account->id] = $account; } ksort($groupedAccounts); diff --git a/app/Http/Controllers/Rule/CreateController.php b/app/Http/Controllers/Rule/CreateController.php index 6314df0193..86a8f17d60 100644 --- a/app/Http/Controllers/Rule/CreateController.php +++ b/app/Http/Controllers/Rule/CreateController.php @@ -220,7 +220,7 @@ class CreateController extends Controller ]; // restore actions and triggers from old input: - if (null !== $request->old() && count($request->old()) > 0) { + if (null !== $request->old() && is_array($request->old()) && count($request->old()) > 0) { $oldTriggers = $this->getPreviousTriggers($request); $oldActions = $this->getPreviousActions($request); } diff --git a/app/Http/Controllers/Rule/EditController.php b/app/Http/Controllers/Rule/EditController.php index 87fd751ce2..c159ca4685 100644 --- a/app/Http/Controllers/Rule/EditController.php +++ b/app/Http/Controllers/Rule/EditController.php @@ -100,7 +100,7 @@ class EditController extends Controller $oldTriggers = $this->parseFromOperators($operators); } // has old input? - if (count($request->old()) > 0) { + if (null !== $request->old() && is_array($request->old()) && count($request->old()) > 0) { $oldTriggers = $this->getPreviousTriggers($request); $oldActions = $this->getPreviousActions($request); } diff --git a/app/Http/Controllers/Rule/SelectController.php b/app/Http/Controllers/Rule/SelectController.php index ff5983b7c8..64f675da48 100644 --- a/app/Http/Controllers/Rule/SelectController.php +++ b/app/Http/Controllers/Rule/SelectController.php @@ -137,6 +137,7 @@ class SelectController extends Controller { // build fake rule $rule = new Rule(); + /** @var \Illuminate\Database\Eloquent\Collection $triggers */ $triggers = new Collection(); $rule->strict = '1' === $request->get('strict'); diff --git a/app/Http/Controllers/System/InstallController.php b/app/Http/Controllers/System/InstallController.php index 14bc3d2445..534a977f90 100644 --- a/app/Http/Controllers/System/InstallController.php +++ b/app/Http/Controllers/System/InstallController.php @@ -117,7 +117,7 @@ class InstallController extends Controller } catch (FireflyException $e) { app('log')->error($e->getMessage()); app('log')->error($e->getTraceAsString()); - if (strpos($e->getMessage(), 'open_basedir restriction in effect')) { + if (str_contains($e->getMessage(), 'open_basedir restriction in effect')) { $this->lastError = self::BASEDIR_ERROR; } $result = false; diff --git a/app/Http/Controllers/Transaction/DeleteController.php b/app/Http/Controllers/Transaction/DeleteController.php index 374272acd8..9088adbbf5 100644 --- a/app/Http/Controllers/Transaction/DeleteController.php +++ b/app/Http/Controllers/Transaction/DeleteController.php @@ -99,9 +99,9 @@ class DeleteController extends Controller * * @param TransactionGroup $group * - * @return RedirectResponse + * @return RedirectResponse|Redirector */ - public function destroy(TransactionGroup $group): RedirectResponse + public function destroy(TransactionGroup $group): RedirectResponse|Redirector { app('log')->debug(sprintf('Now in %s(#%d).', __METHOD__, $group->id)); if (!$this->isEditableGroup($group)) { diff --git a/app/Http/Controllers/Transaction/ShowController.php b/app/Http/Controllers/Transaction/ShowController.php index 741a4041ae..cdc5615e79 100644 --- a/app/Http/Controllers/Transaction/ShowController.php +++ b/app/Http/Controllers/Transaction/ShowController.php @@ -163,9 +163,9 @@ class ShowController extends Controller $amounts[$symbol]['amount'] = bcadd($amounts[$symbol]['amount'], $transaction['amount']); if (null !== $transaction['foreign_amount'] && '' !== $transaction['foreign_amount'] && bccomp( - '0', - $transaction['foreign_amount'] - ) !== 0) { + '0', + $transaction['foreign_amount'] + ) !== 0) { // same for foreign currency: $foreignSymbol = $transaction['foreign_currency_symbol']; if (!array_key_exists($foreignSymbol, $amounts)) { @@ -192,7 +192,10 @@ class ShowController extends Controller */ private function getAccounts(array $group): array { - $accounts = []; + $accounts = [ + 'source' => [], + 'destination' => [], + ]; foreach ($group['transactions'] as $transaction) { $accounts['source'][] = [ diff --git a/app/Http/Middleware/Range.php b/app/Http/Middleware/Range.php index 602ad020c6..71578d4114 100644 --- a/app/Http/Middleware/Range.php +++ b/app/Http/Middleware/Range.php @@ -69,6 +69,10 @@ class Range // ignore preference. set the range to be the current month: if (!app('session')->has('start') && !app('session')->has('end')) { $viewRange = app('preferences')->get('viewRange', '1M')->data; + if(is_array($viewRange)) { + $viewRange = '1M'; + } + $today = today(config('app.timezone')); $start = app('navigation')->updateStartDate($viewRange, $today); $end = app('navigation')->updateEndDate($viewRange, $start); diff --git a/app/Http/Requests/ReportFormRequest.php b/app/Http/Requests/ReportFormRequest.php index aad840a078..2620ca025f 100644 --- a/app/Http/Requests/ReportFormRequest.php +++ b/app/Http/Requests/ReportFormRequest.php @@ -151,7 +151,7 @@ class ReportFormRequest extends FormRequest // validate as date // if regex for YYYY-MM-DD: $pattern = '/^(19|20)\d\d-(0[1-9]|1[012])-(0[1-9]|[12][\d]|3[01])$/'; - if (preg_match($pattern, $string)) { + if (false !== preg_match($pattern, $string)) { try { $date = new Carbon($parts[1]); } catch (Exception $e) { // intentional generic exception @@ -186,7 +186,7 @@ class ReportFormRequest extends FormRequest // validate as date // if regex for YYYY-MM-DD: $pattern = '/^(19|20)\d\d-(0[1-9]|1[012])-(0[1-9]|[12][\d]|3[01])$/'; - if (preg_match($pattern, $string)) { + if (false !== preg_match($pattern, $string)) { try { $date = new Carbon($parts[0]); } catch (Exception $e) { // intentional generic exception diff --git a/app/Jobs/DownloadExchangeRates.php b/app/Jobs/DownloadExchangeRates.php index a4eb9d25b4..24a7da19e9 100644 --- a/app/Jobs/DownloadExchangeRates.php +++ b/app/Jobs/DownloadExchangeRates.php @@ -121,6 +121,9 @@ class DownloadExchangeRates implements ShouldQueue return; } $date = Carbon::createFromFormat('Y-m-d', $json['date'], config('app.timezone')); + if(false === $date) { + return; + } $this->saveRates($currency, $date, $json['rates']); } diff --git a/app/Mail/InvitationMail.php b/app/Mail/InvitationMail.php index faa1fa8582..78d84086b1 100644 --- a/app/Mail/InvitationMail.php +++ b/app/Mail/InvitationMail.php @@ -53,7 +53,7 @@ class InvitationMail extends Mailable $this->invitee = $invitee; $this->admin = $admin; $this->url = $url; - $this->host = parse_url($url, PHP_URL_HOST); + $this->host = (string) parse_url($url, PHP_URL_HOST); } /** diff --git a/app/Models/Bill.php b/app/Models/Bill.php index 1011a7f553..043b85b7e0 100644 --- a/app/Models/Bill.php +++ b/app/Models/Bill.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace FireflyIII\Models; +use Carbon\Carbon; use Eloquent; use FireflyIII\Support\Models\ReturnsIntegerIdTrait; use FireflyIII\Support\Models\ReturnsIntegerUserIdTrait; @@ -33,11 +34,9 @@ use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Relations\MorphMany; -use Illuminate\Database\Eloquent\Relations\MorphTo; use Illuminate\Database\Eloquent\Relations\MorphToMany; use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Query\Builder; -use Carbon\Carbon; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; /** @@ -47,8 +46,8 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; * @property Carbon|null $created_at * @property Carbon|null $updated_at * @property Carbon|null $deleted_at - * @property int $user_id - * @property int $transaction_currency_id + * @property int $user_id + * @property int $transaction_currency_id * @property string $name * @property string $match * @property string $amount_min @@ -57,12 +56,12 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; * @property Carbon|null $end_date * @property Carbon|null $extension_date * @property string $repeat_freq - * @property int|string $skip + * @property int $skip * @property bool $automatch * @property bool $active * @property bool $name_encrypted * @property bool $match_encrypted - * @property int $order + * @property int $order * @property-read Collection|Attachment[] $attachments * @property-read int|null $attachments_count * @property-read Collection|Note[] $notes @@ -99,7 +98,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; * @method static \Illuminate\Database\Eloquent\Builder|Bill whereUserId($value) * @method static Builder|Bill withTrashed() * @method static Builder|Bill withoutTrashed() - * @property int $user_group_id + * @property int $user_group_id * @method static \Illuminate\Database\Eloquent\Builder|Bill whereUserGroupId($value) * @mixin Eloquent */ @@ -247,6 +246,18 @@ class Bill extends Model ); } + /** + * Get the skip + * + * @return Attribute + */ + protected function skip(): Attribute + { + return Attribute::make( + get: static fn ($value) => (int)$value, + ); + } + /** * Get the min amount * @@ -265,7 +276,7 @@ class Bill extends Model protected function transactionCurrencyId(): Attribute { return Attribute::make( - get: static fn($value) => (int)$value, + get: static fn ($value) => (int)$value, ); } @@ -275,7 +286,7 @@ class Bill extends Model protected function order(): Attribute { return Attribute::make( - get: static fn($value) => (int)$value, + get: static fn ($value) => (int)$value, ); } diff --git a/app/Models/Preference.php b/app/Models/Preference.php index db27acd374..fb1c31e8b6 100644 --- a/app/Models/Preference.php +++ b/app/Models/Preference.php @@ -94,7 +94,7 @@ class Preference extends Model $preference = new self(); $preference->name = $value; $preference->data = $default[$value]; - $preference->user_id = $user->id; + $preference->user_id = (int) $user->id; $preference->save(); return $preference; diff --git a/app/Models/TransactionJournalMeta.php b/app/Models/TransactionJournalMeta.php index 254c4843d6..cbb17514d0 100644 --- a/app/Models/TransactionJournalMeta.php +++ b/app/Models/TransactionJournalMeta.php @@ -95,7 +95,7 @@ class TransactionJournalMeta extends Model { $data = json_encode($value); $this->attributes['data'] = $data; - $this->attributes['hash'] = hash('sha256', $data); + $this->attributes['hash'] = (string) hash('sha256', $data); } /** diff --git a/app/Notifications/User/BillReminder.php b/app/Notifications/User/BillReminder.php index c049d48726..a6aad8fc3d 100644 --- a/app/Notifications/User/BillReminder.php +++ b/app/Notifications/User/BillReminder.php @@ -122,8 +122,11 @@ class BillReminder extends Notification { /** @var User|null $user */ $user = auth()->user(); - $slackUrl = null === $user ? '' : (string)app('preferences')->getForUser(auth()->user(), 'slack_webhook_url', '')->data; - if (UrlValidator::isValidWebhookURL($slackUrl)) { + $slackUrl = null === $user ? '' : app('preferences')->getForUser(auth()->user(), 'slack_webhook_url', '')->data; + if (is_array($slackUrl)) { + $slackUrl = ''; + } + if (UrlValidator::isValidWebhookURL((string) $slackUrl)) { return ['mail', 'slack']; } return ['mail']; diff --git a/app/Notifications/User/NewAccessToken.php b/app/Notifications/User/NewAccessToken.php index 907d27df9e..be8b50abd4 100644 --- a/app/Notifications/User/NewAccessToken.php +++ b/app/Notifications/User/NewAccessToken.php @@ -98,8 +98,11 @@ class NewAccessToken extends Notification { /** @var User|null $user */ $user = auth()->user(); - $slackUrl = null === $user ? '' : (string)app('preferences')->getForUser(auth()->user(), 'slack_webhook_url', '')->data; - if (UrlValidator::isValidWebhookURL($slackUrl)) { + $slackUrl = null === $user ? '' : app('preferences')->getForUser(auth()->user(), 'slack_webhook_url', '')->data; + if (is_array($slackUrl)) { + $slackUrl = ''; + } + if (UrlValidator::isValidWebhookURL((string)$slackUrl)) { return ['mail', 'slack']; } return ['mail']; diff --git a/app/Notifications/User/RuleActionFailed.php b/app/Notifications/User/RuleActionFailed.php index fff1ec6192..5fa16410fe 100644 --- a/app/Notifications/User/RuleActionFailed.php +++ b/app/Notifications/User/RuleActionFailed.php @@ -106,8 +106,11 @@ class RuleActionFailed extends Notification { /** @var User|null $user */ $user = auth()->user(); - $slackUrl = null === $user ? '' : (string)app('preferences')->getForUser(auth()->user(), 'slack_webhook_url', '')->data; - if (UrlValidator::isValidWebhookURL($slackUrl)) { + $slackUrl = null === $user ? '' : app('preferences')->getForUser(auth()->user(), 'slack_webhook_url', '')->data; + if (is_array($slackUrl)) { + $slackUrl = ''; + } + if (UrlValidator::isValidWebhookURL((string)$slackUrl)) { app('log')->debug('Will send ruleActionFailed through Slack!'); return ['slack']; } diff --git a/app/Notifications/User/UserLogin.php b/app/Notifications/User/UserLogin.php index 073dd7a406..dc642f6cc3 100644 --- a/app/Notifications/User/UserLogin.php +++ b/app/Notifications/User/UserLogin.php @@ -125,8 +125,11 @@ class UserLogin extends Notification { /** @var User|null $user */ $user = auth()->user(); - $slackUrl = null === $user ? '' : (string)app('preferences')->getForUser(auth()->user(), 'slack_webhook_url', '')->data; - if (UrlValidator::isValidWebhookURL($slackUrl)) { + $slackUrl = null === $user ? '' : app('preferences')->getForUser(auth()->user(), 'slack_webhook_url', '')->data; + if (is_array($slackUrl)) { + $slackUrl = ''; + } + if (UrlValidator::isValidWebhookURL((string) $slackUrl)) { return ['mail', 'slack']; } return ['mail']; diff --git a/app/Repositories/Account/AccountRepositoryInterface.php b/app/Repositories/Account/AccountRepositoryInterface.php index df8e3ec943..8d9ecba952 100644 --- a/app/Repositories/Account/AccountRepositoryInterface.php +++ b/app/Repositories/Account/AccountRepositoryInterface.php @@ -123,7 +123,7 @@ interface AccountRepositoryInterface public function getAccountsById(array $accountIds): Collection; /** - * @param array $types + * @param array $types * @param array|null $sort * * @return Collection