]> git.mxchange.org Git - friendica.git/commitdiff
Add null/empty string parameter value case in BBCode::convert
authorHypolite Petovan <hypolite@mrpetovan.com>
Mon, 8 Jun 2020 23:15:08 +0000 (19:15 -0400)
committerHypolite Petovan <hypolite@mrpetovan.com>
Mon, 8 Jun 2020 23:15:08 +0000 (19:15 -0400)
- Remove obsolete coalesce operator uses

include/enotify.php
mod/cal.php
mod/photos.php
mod/videos.php
src/Content/Text/BBCode.php
src/Model/Notify.php

index ae2e2e7fefba2526e381350dfd9b00861f5f8cf2..89a81833d08308bfea5ed3303f6a9f2fac242118 100644 (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 ?? '',
index edcbaa7e8ff875ba5da970f2b54f4c7b0cab117e..4b90b02cd845474ea4988d6444428f15e7b4582e 100644 (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();
index 7240c0052b57c2d33fb38bfc4e9482549b5b5267..2b72fd3e4ec91c70b5d9eb52071d47ab83afd683 100644 (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']);
index 49c64ef973589d6eccf75e569c93176078085e08..a3344a8b4300d2c04550489c35f07a286bb55a7c 100644 (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
index fb0d99d8ac902e37ba16b9420ccf2a862ca00173..0f3c4ad529d8be9d0457a6614869f0e6cde5a313 100644 (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) {
index fe1497316fc5428224a6a5ef4feccca1d6935b3d..9ebf5c23b3efc0ee07ef91e6b9b07490560a8727 100644 (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) {
                }
        }