Add null/empty string parameter value case in BBCode::convert

- Remove obsolete coalesce operator uses
This commit is contained in:
Hypolite Petovan 2020-06-08 19:15:08 -04:00
parent 0c1e876ee0
commit 89b3ae2657
6 changed files with 11 additions and 6 deletions

View file

@ -465,7 +465,7 @@ function notification($params)
if ($show_in_notification_page) {
$notification = DI::notify()->insert([
'name' => $params['source_name'] ?? '',
'name_cache' => substr(strip_tags(BBCode::convert($params['source_name'] ?? '')), 0, 255),
'name_cache' => substr(strip_tags(BBCode::convert($params['source_name'])), 0, 255),
'url' => $params['source_link'] ?? '',
'photo' => $params['source_photo'] ?? '',
'link' => $itemlink ?? '',

View file

@ -78,7 +78,7 @@ function cal_init(App $a)
'$photo' => $profile['photo'],
'$addr' => $profile['addr'] ?: '',
'$account_type' => $account_type,
'$about' => BBCode::convert($profile['about'] ?: ''),
'$about' => BBCode::convert($profile['about']),
]);
$cal_widget = Widget\CalendarExport::getHTML();

View file

@ -82,7 +82,7 @@ function photos_init(App $a) {
'$photo' => $profile['photo'],
'$addr' => $profile['addr'] ?? '',
'$account_type' => $account_type,
'$about' => BBCode::convert($profile['about'] ?? ''),
'$about' => BBCode::convert($profile['about']),
]);
$albums = Photo::getAlbums($a->data['user']['uid']);

View file

@ -67,7 +67,7 @@ function videos_init(App $a)
'$photo' => $profile['photo'],
'$addr' => $profile['addr'] ?? '',
'$account_type' => $account_type,
'$about' => BBCode::convert($profile['about'] ?? ''),
'$about' => BBCode::convert($profile['about']),
]);
// If not there, create 'aside' empty

View file

@ -1252,8 +1252,13 @@ class BBCode
* @return string
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function convert($text, $try_oembed = true, $simple_html = self::INTERNAL, $for_plaintext = false)
public static function convert(string $text = null, $try_oembed = true, $simple_html = self::INTERNAL, $for_plaintext = false)
{
// Accounting for null default column values
if (is_null($text) || $text === '') {
return '';
}
$a = DI::app();
$text = self::performWithEscapedTags($text, ['code'], function ($text) use ($try_oembed, $simple_html, $for_plaintext, $a) {

View file

@ -70,7 +70,7 @@ class Notify extends BaseModel
private function setNameCache()
{
try {
$this->name_cache = strip_tags(BBCode::convert($this->source_name ?? ''));
$this->name_cache = strip_tags(BBCode::convert($this->source_name));
} catch (InternalServerErrorException $e) {
}
}