From 0ec7238da49d7e9a98b0a49f86e8ed2ca721ae9a Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Wed, 23 Nov 2022 13:38:40 -0500 Subject: [PATCH] Fix null value passed to string functions deprecation notices - Address part of https://github.com/friendica/friendica/issues/12011#issuecomment-1321796513 --- src/Content/Conversation.php | 2 +- src/Database/Database.php | 2 +- src/Model/Post/Media.php | 2 +- src/Module/Admin/Site.php | 4 ++-- src/Module/Contact/Profile.php | 2 +- src/Module/User/PortableContacts.php | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Content/Conversation.php b/src/Content/Conversation.php index be7448a336..6d19eb1635 100644 --- a/src/Content/Conversation.php +++ b/src/Content/Conversation.php @@ -794,7 +794,7 @@ class Conversation return []; } - $str_blocked = str_replace(["\n", "\r"], ",", $this->pConfig->get($this->session->getLocalUserId(), 'system', 'blocked')); + $str_blocked = str_replace(["\n", "\r"], ",", $this->pConfig->get($this->session->getLocalUserId(), 'system', 'blocked') ?? ''); if (empty($str_blocked)) { return []; } diff --git a/src/Database/Database.php b/src/Database/Database.php index a34b17adbe..036e6ec2cb 100644 --- a/src/Database/Database.php +++ b/src/Database/Database.php @@ -110,7 +110,7 @@ class Database $this->connected = false; $port = 0; - $serveraddr = trim($this->configCache->get('database', 'hostname')); + $serveraddr = trim($this->configCache->get('database', 'hostname') ?? ''); $serverdata = explode(':', $serveraddr); $host = trim($serverdata[0]); if (count($serverdata) > 1) { diff --git a/src/Model/Post/Media.php b/src/Model/Post/Media.php index 04c0db0f80..854e5d8f91 100644 --- a/src/Model/Post/Media.php +++ b/src/Model/Post/Media.php @@ -687,7 +687,7 @@ class Media $previews[] = $medium['preview']; } - $type = explode('/', explode(';', $medium['mimetype'])[0]); + $type = explode('/', explode(';', $medium['mimetype'] ?? '')[0]); if (count($type) < 2) { Logger::info('Unknown MimeType', ['type' => $type, 'media' => $medium]); $filetype = 'unkn'; diff --git a/src/Module/Admin/Site.php b/src/Module/Admin/Site.php index f7fc9d7934..ab6624f776 100644 --- a/src/Module/Admin/Site.php +++ b/src/Module/Admin/Site.php @@ -324,8 +324,8 @@ class Site extends BaseAdmin /* Installed langs */ $lang_choices = DI::l10n()->getAvailableLanguages(); - if (strlen(DI::config()->get('system', 'directory_submit_url')) && - !strlen(DI::config()->get('system', 'directory'))) { + if (DI::config()->get('system', 'directory_submit_url') && + !DI::config()->get('system', 'directory')) { DI::config()->set('system', 'directory', dirname(DI::config()->get('system', 'directory_submit_url'))); DI::config()->delete('system', 'directory_submit_url'); } diff --git a/src/Module/Contact/Profile.php b/src/Module/Contact/Profile.php index b3d0c03733..eadc67818d 100644 --- a/src/Module/Contact/Profile.php +++ b/src/Module/Contact/Profile.php @@ -327,7 +327,7 @@ class Profile extends BaseModule '$submit' => $this->t('Submit'), '$lbl_info1' => $lbl_info1, '$lbl_info2' => $this->t('Their personal note'), - '$reason' => trim($contact['reason']), + '$reason' => trim($contact['reason'] ?? ''), '$infedit' => $this->t('Edit contact notes'), '$common_link' => 'contact/' . $contact['id'] . '/contacts/common', '$relation_text' => $relation_text, diff --git a/src/Module/User/PortableContacts.php b/src/Module/User/PortableContacts.php index 6629994810..6a3c1201d9 100644 --- a/src/Module/User/PortableContacts.php +++ b/src/Module/User/PortableContacts.php @@ -233,7 +233,7 @@ class PortableContacts extends BaseModule } if ($selectedFields['tags']) { - $tags = str_replace(',', ' ', $contact['keywords']); + $tags = str_replace(',', ' ', $contact['keywords'] ?? ''); $tags = explode(' ', $tags); $cleaned = [];