cosmetic nullsafe fix

This commit is contained in:
Jean-Christian Denis 2023-04-20 22:39:11 +02:00
parent 79f41ea79b
commit d44eade799
Signed by: JcDenis
GPG key ID: 1B5B8C5B90B6C951
3 changed files with 25 additions and 0 deletions

View file

@ -43,6 +43,11 @@ class Backend extends dcNsProcess
dcCore::app()->addBehaviors([ dcCore::app()->addBehaviors([
'initWidgets' => [Widgets::class, 'initWidgets'], 'initWidgets' => [Widgets::class, 'initWidgets'],
'adminDashboardItemsV2' => function (ArrayObject $__dashboard_items): void { 'adminDashboardItemsV2' => function (ArrayObject $__dashboard_items): void {
// nullsafe PHP < 8.0
if (is_null(dcCore::app()->auth) || is_null(dcCore::app()->auth->user_prefs) || is_null(dcCore::app()->blog)) {
return;
}
if (!dcCore::app()->auth->user_prefs->get('dashboard')->get('dcLatestVersionsItems')) { if (!dcCore::app()->auth->user_prefs->get('dashboard')->get('dcLatestVersionsItems')) {
return; return;
} }
@ -92,6 +97,11 @@ class Backend extends dcNsProcess
}, },
'adminDashboardOptionsFormV2' => function (): void { 'adminDashboardOptionsFormV2' => function (): void {
// nullsafe PHP < 8.0
if (is_null(dcCore::app()->auth) || is_null(dcCore::app()->auth->user_prefs)) {
return;
}
if (!dcCore::app()->auth->user_prefs->get('dashboard')->prefExists('dcLatestVersionsItems')) { if (!dcCore::app()->auth->user_prefs->get('dashboard')->prefExists('dcLatestVersionsItems')) {
dcCore::app()->auth->user_prefs->get('dashboard')->put( dcCore::app()->auth->user_prefs->get('dashboard')->put(
'dcLatestVersionsItems', 'dcLatestVersionsItems',
@ -111,6 +121,11 @@ class Backend extends dcNsProcess
}, },
'adminAfterDashboardOptionsUpdate' => function (?string $user_id): void { 'adminAfterDashboardOptionsUpdate' => function (?string $user_id): void {
// nullsafe PHP < 8.0
if (is_null(dcCore::app()->auth) || is_null(dcCore::app()->auth->user_prefs)) {
return;
}
dcCore::app()->auth->user_prefs->get('dashboard')->put( dcCore::app()->auth->user_prefs->get('dashboard')->put(
'dcLatestVersionsItems', 'dcLatestVersionsItems',
!empty($_POST['dcLatestVersionsItems']), !empty($_POST['dcLatestVersionsItems']),

View file

@ -33,6 +33,11 @@ class Install extends dcNsProcess
return false; return false;
} }
// nullsafe PHP < 8.0
if (is_null(dcCore::app()->blog)) {
return false;
}
dcCore::app()->blog->settings->get(My::id())->put( dcCore::app()->blog->settings->get(My::id())->put(
'builds', 'builds',
'stable,unstable,testing', 'stable,unstable,testing',

View file

@ -53,6 +53,11 @@ class Widgets
return ''; return '';
} }
// nullsafe PHP < 8.0
if (is_null(dcCore::app()->blog)) {
return '';
}
# Builds to check # Builds to check
$builds = explode(',', (string) dcCore::app()->blog->settings->get(My::id())->get('builds')); $builds = explode(',', (string) dcCore::app()->blog->settings->get(My::id())->get('builds'));
if (empty($builds[0])) { if (empty($builds[0])) {