From 917e75430696706e4ffb643d7154af8d60258742 Mon Sep 17 00:00:00 2001 From: Moritz Strohm Date: Fri, 25 Feb 2022 17:44:26 +0100 Subject: fixed PHP8 warnings in user profile pages --- app/controllers/profile.php | 3 ++- app/controllers/profilemodules.php | 4 ++-- lib/classes/I18N.php | 2 +- lib/classes/I18NString.php | 2 +- lib/user_visible.inc.php | 4 ++-- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/app/controllers/profile.php b/app/controllers/profile.php index 32e8801..e9b8fc1 100644 --- a/app/controllers/profile.php +++ b/app/controllers/profile.php @@ -90,7 +90,8 @@ class ProfileController extends AuthenticatedController $this->privadr = $this->profile->getVisibilityValue('privadr', 'privadr'); $this->homepage = $this->profile->getVisibilityValue('Home', 'homepage'); - // skype informations + // skype information + $this->skype_name = ''; if (Config::get()->ENABLE_SKYPE_INFO && Visibility::verify('skype_name', $this->current_user->user_id)) { $this->skype_name = UserConfig::get($this->current_user->user_id)->SKYPE_NAME; } diff --git a/app/controllers/profilemodules.php b/app/controllers/profilemodules.php index 5f7548b..c85331f 100644 --- a/app/controllers/profilemodules.php +++ b/app/controllers/profilemodules.php @@ -300,8 +300,8 @@ class ProfileModulesController extends AuthenticatedController 'description' => str_replace('\n', ' ', $metadata['descriptionlong'] ?? $metadata['description']), 'screenshots' => [], 'keywords' => $metadata['keywords'] ? explode(';', $metadata['keywords']) : [], - 'homepage' => $metadata['homepage'], - 'helplink' => $metadata['helplink'], + 'homepage' => $metadata['homepage'] ?? '', + 'helplink' => $metadata['helplink'] ?? '', ]; if (isset($metadata['screenshot'])) { diff --git a/lib/classes/I18N.php b/lib/classes/I18N.php index 4ed94b7..1837327 100644 --- a/lib/classes/I18N.php +++ b/lib/classes/I18N.php @@ -125,7 +125,7 @@ class I18N return $template->render([ 'languages' => $GLOBALS['CONTENT_LANGUAGES'], 'base_lang' => key($GLOBALS['CONTENT_LANGUAGES']), - 'wysiwyg' => in_array('wysiwyg', words($attributes['class'])), + 'wysiwyg' => !empty($attributes['class']) ? in_array('wysiwyg', words($attributes['class'])) : false, 'name' => $this->name, 'value' => $this->value, 'attributes' => $attributes, diff --git a/lib/classes/I18NString.php b/lib/classes/I18NString.php index 4c997f4..8b9735d 100644 --- a/lib/classes/I18NString.php +++ b/lib/classes/I18NString.php @@ -172,7 +172,7 @@ class I18NString */ public function translation($lang) { - return $this->toArray()[$lang]; + return $this->toArray()[$lang] ?? ''; } /** diff --git a/lib/user_visible.inc.php b/lib/user_visible.inc.php index c7b07f0..73b33ad 100644 --- a/lib/user_visible.inc.php +++ b/lib/user_visible.inc.php @@ -292,13 +292,13 @@ function get_local_visibility_by_id($user_id, $context, $return_user_perm=false) } } - if ($homepage_settings) { + if (!empty($homepage_settings)) { $data[$context] = json_encode($homepage_settings); } } if ($data[$context] === null) { - $user_perm = $data['perm']; + $user_perm = $data['perm'] ?? null; $data['perms'] = $user_perm; $data[$context] = Config::get()->getValue(mb_strtoupper($context) . '_VISIBILITY_DEFAULT'); -- cgit v1.0