From cebab2b4565b31ec1a05ad91e2ceddce0d44843e Mon Sep 17 00:00:00 2001 From: Jean-Christian Denis Date: Fri, 21 Apr 2023 00:14:29 +0200 Subject: [PATCH] cosmetic nullsafe fix --- src/BackendBehaviors.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/BackendBehaviors.php b/src/BackendBehaviors.php index e4a2185..a9833b8 100644 --- a/src/BackendBehaviors.php +++ b/src/BackendBehaviors.php @@ -26,6 +26,11 @@ class BackendBehaviors { public static function adminUserForm(): void { + // nullsafe PHP < 8.0 + if (is_null(dcCore::app()->auth)) { + return; + } + $options = dcCore::app()->auth->getOptions(); echo @@ -43,6 +48,9 @@ class BackendBehaviors public static function adminBeforeUserUpdate(cursor $cur, string $user_id = ''): void { - $cur->user_options['notify_comments'] = $_POST['notify_comments']; + $opt = $cur->getField('user_options'); + $opt = is_null($opt) ? [] : $opt; + $opt['notify_comments'] = $_POST['notify_comments']; + $cur->setField('user_options', $opt); } }