]> git.mxchange.org Git - friendica.git/commitdiff
Merge remote-tracking branch 'upstream/develop' into sanitize-gcontact
authorMichael <heluecht@pirati.ca>
Fri, 18 Oct 2019 18:48:32 +0000 (18:48 +0000)
committerMichael <heluecht@pirati.ca>
Fri, 18 Oct 2019 18:48:32 +0000 (18:48 +0000)
144 files changed:
boot.php
doc/Developers-Intro.md
include/api.php
include/conversation.php
include/enotify.php
include/items.php
mod/cal.php
mod/common.php
mod/crepair.php
mod/dfrn_confirm.php
mod/dfrn_notify.php
mod/dfrn_poll.php
mod/dfrn_request.php
mod/display.php
mod/events.php
mod/fbrowser.php
mod/follow.php
mod/fsuggest.php
mod/hcard.php
mod/hovercard.php
mod/ignored.php
mod/item.php
mod/match.php
mod/message.php
mod/msearch.php
mod/network.php
mod/noscrape.php
mod/notifications.php
mod/photos.php
mod/poco.php
mod/pubsub.php
mod/redir.php
mod/regmod.php
mod/settings.php
mod/tagrm.php
mod/unfollow.php
mod/videos.php
mod/wallmessage.php
mods/sample-Lighttpd.config
src/App/Arguments.php
src/App/BaseURL.php
src/BaseObject.php
src/Content/Pager.php
src/Content/Text/BBCode.php
src/Content/Text/HTML.php
src/Content/Widget/CalendarExport.php
src/Content/Widget/ContactBlock.php
src/Core/ACL.php
src/Core/Authentication.php
src/Core/Config/Configuration.php
src/Core/Config/PConfiguration.php
src/Core/NotificationsManager.php
src/Core/Renderer.php
src/Core/Search.php
src/Core/Session.php
src/Core/StorageManager.php
src/Database/DBStructure.php
src/Model/Contact.php
src/Model/Conversation.php
src/Model/Event.php
src/Model/GContact.php
src/Model/GServer.php
src/Model/Item.php
src/Model/ItemContent.php
src/Model/PermissionSet.php
src/Model/Profile.php
src/Model/Storage/Filesystem.php
src/Model/Term.php
src/Module/Acctlink.php
src/Module/Admin/Addons/Details.php
src/Module/Admin/Addons/Index.php
src/Module/Admin/Blocklist/Contact.php
src/Module/Admin/Logs/Settings.php
src/Module/Admin/Site.php
src/Module/Admin/Themes/Index.php
src/Module/Admin/Users.php
src/Module/AllFriends.php
src/Module/Bookmarklet.php
src/Module/Contact.php
src/Module/Debug/Babel.php
src/Module/Debug/Feed.php
src/Module/Debug/Localtime.php
src/Module/Debug/Probe.php
src/Module/Debug/WebFinger.php
src/Module/Feed.php
src/Module/Filer/RemoveTag.php
src/Module/Filer/SaveTag.php
src/Module/FollowConfirm.php
src/Module/Followers.php
src/Module/Following.php
src/Module/Install.php
src/Module/Like.php
src/Module/Login.php
src/Module/Magic.php
src/Module/Outbox.php
src/Module/Profile.php
src/Module/Profile/Contacts.php
src/Module/Proxy.php
src/Module/Register.php
src/Module/Search/Acl.php
src/Module/Settings/TwoFactor/Index.php
src/Module/Settings/TwoFactor/Verify.php
src/Module/Smilies.php
src/Module/Special/HTTPException.php
src/Module/Starred.php
src/Module/ThemeDetails.php
src/Module/TwoFactor/Recovery.php
src/Module/Xrd.php
src/Network/CurlResult.php
src/Network/Probe.php
src/Object/Post.php
src/Protocol/ActivityPub.php
src/Protocol/ActivityPub/Processor.php
src/Protocol/ActivityPub/Receiver.php
src/Protocol/ActivityPub/Transmitter.php
src/Protocol/DFRN.php
src/Protocol/Email.php
src/Protocol/OStatus.php
src/Util/Emailer.php
src/Util/Logger/SyslogLogger.php
src/Util/Network.php
src/Util/ParseUrl.php
src/Util/Profiler.php
src/Worker/Delivery.php
src/Worker/GProbe.php
view/js/linkPreview.js
view/js/main.js
view/theme/duepuntozero/style.php
view/theme/duepuntozero/theme.php
view/theme/frio/config.php
view/theme/frio/js/textedit.js
view/theme/frio/php/default.php
view/theme/frio/php/frio_boot.php
view/theme/frio/php/minimal.php
view/theme/frio/php/standard.php
view/theme/frio/templates/field_checkbox.tpl
view/theme/frio/templates/footer.tpl
view/theme/frio/templates/nav.tpl
view/theme/quattro/js/quattro.js
view/theme/quattro/style.php
view/theme/smoothly/templates/bottom.tpl
view/theme/smoothly/theme.php
view/theme/vier/style.php
view/theme/vier/theme.php

index ae9c35ae5d32207db6b4f0196f1e44e8676c48c5..3571a77c165de564f633520b3b32f19386146dd1 100644 (file)
--- a/boot.php
+++ b/boot.php
@@ -322,47 +322,6 @@ function get_app()
        return BaseObject::getApp();
 }
 
-/**
- * Return the provided variable value if it exists and is truthy or the provided
- * default value instead.
- *
- * Works with initialized variables and potentially uninitialized array keys
- *
- * Usages:
- * - defaults($var, $default)
- * - defaults($array, 'key', $default)
- *
- * @param array $args
- * @brief Returns a defaut value if the provided variable or array key is falsy
- * @return mixed
- * @deprecated since version 2019.06, use native coalesce operator (??) instead
- */
-function defaults(...$args)
-{
-       if (count($args) < 2) {
-               throw new BadFunctionCallException('defaults() requires at least 2 parameters');
-       }
-       if (count($args) > 3) {
-               throw new BadFunctionCallException('defaults() cannot use more than 3 parameters');
-       }
-       if (count($args) === 3 && is_null($args[1])) {
-               throw new BadFunctionCallException('defaults($arr, $key, $def) $key is null');
-       }
-
-       // The default value always is the last argument
-       $return = array_pop($args);
-
-       if (count($args) == 2 && is_array($args[0]) && !empty($args[0][$args[1]])) {
-               $return = $args[0][$args[1]];
-       }
-
-       if (count($args) == 1 && !empty($args[0])) {
-               $return = $args[0];
-       }
-
-       return $return;
-}
-
 /**
  * @brief Used to end the current process, after saving session state.
  * @deprecated
index d7f3f81fe6eddb237d82ba2b435c567085316268..ae9a856b8e784025ba5e337487f7200b80148a6e 100644 (file)
@@ -81,6 +81,7 @@ Here's a few primers if you are new to Friendica or to the PSR-2 coding standard
 * No closing PHP tag
 * No trailing spaces
 * Array declarations use the new square brackets syntax
+* Quoting style is single quotes by default, except for needed string interpolation, SQL query strings by convention and comments that should stay in natural language.
 
 Don't worry, you don't have to know by heart the PSR-2 coding standards to start contributing to Friendica.
 There are a few tools you can use to check or fix your files before you commit.
index e986a5173490791e432b28ada142971c5fa4e4d1..7daf134551594b3e45ca1a389c318a91aae148a0 100644 (file)
@@ -322,7 +322,7 @@ function api_call(App $a)
 
                                $stamp =  microtime(true);
                                $return = call_user_func($info['func'], $type);
-                               $duration = (float) (microtime(true) - $stamp);
+                               $duration = floatval(microtime(true) - $stamp);
 
                                Logger::info(API_LOG_PREFIX . 'username {username}', ['module' => 'api', 'action' => 'call', 'username' => $a->user['username'], 'duration' => round($duration, 2)]);
 
index 74c8a6d27243ef9a6ac09361707783a2d26f3abd..b6faa4d2c88e3e97f5f1b06449f9a7a3b0e0de88 100644 (file)
@@ -1208,7 +1208,7 @@ function status_editor(App $a, $x, $notes_cid = 0, $popup = false)
                '$new_post' => L10n::t('New Post'),
                '$return_path'  => $query_str,
                '$action'       => 'item',
-               '$share'        => defaults($x, 'button', L10n::t('Share')),
+               '$share'        => ($x['button'] ?? '') ?: L10n::t('Share'),
                '$upload'       => L10n::t('Upload photo'),
                '$shortupload'  => L10n::t('upload photo'),
                '$attach'       => L10n::t('Attach file'),
@@ -1225,17 +1225,17 @@ function status_editor(App $a, $x, $notes_cid = 0, $popup = false)
                '$shortsetloc'  => L10n::t('set location'),
                '$noloc'        => L10n::t('Clear browser location'),
                '$shortnoloc'   => L10n::t('clear location'),
-               '$title'        => defaults($x, 'title', ''),
+               '$title'        => $x['title'] ?? '',
                '$placeholdertitle' => L10n::t('Set title'),
-               '$category'     => defaults($x, 'category', ''),
+               '$category'     => $x['category'] ?? '',
                '$placeholdercategory' => Feature::isEnabled(local_user(), 'categories') ? L10n::t("Categories \x28comma-separated list\x29") : '',
                '$wait'         => L10n::t('Please wait'),
                '$permset'      => L10n::t('Permission settings'),
                '$shortpermset' => L10n::t('permissions'),
                '$wall'         => $notes_cid ? 0 : 1,
                '$posttype'     => $notes_cid ? Item::PT_PERSONAL_NOTE : Item::PT_ARTICLE,
-               '$content'      => defaults($x, 'content', ''),
-               '$post_id'      => defaults($x, 'post_id', ''),
+               '$content'      => $x['content'] ?? '',
+               '$post_id'      => $x['post_id'] ?? '',
                '$baseurl'      => System::baseUrl(true),
                '$defloc'       => $x['default_location'],
                '$visitor'      => $x['visitor'],
@@ -1527,9 +1527,9 @@ function get_responses(array $conv_responses, array $response_verbs, array $item
        $ret = [];
        foreach ($response_verbs as $v) {
                $ret[$v] = [];
-               $ret[$v]['count'] = defaults($conv_responses[$v], $item['uri'], 0);
-               $ret[$v]['list']  = defaults($conv_responses[$v], $item['uri'] . '-l', []);
-               $ret[$v]['self']  = defaults($conv_responses[$v], $item['uri'] . '-self', '0');
+               $ret[$v]['count'] = $conv_responses[$v][$item['uri']] ?? 0;
+               $ret[$v]['list']  = $conv_responses[$v][$item['uri'] . '-l'] ?? [];
+               $ret[$v]['self']  = $conv_responses[$v][$item['uri'] . '-self'] ?? '0';
                if (count($ret[$v]['list']) > MAX_LIKERS) {
                        $ret[$v]['list_part'] = array_slice($ret[$v]['list'], 0, MAX_LIKERS);
                        array_push($ret[$v]['list_part'], '<a href="#" data-toggle="modal" data-target="#' . $v . 'Modal-'
index 6a66c8fa09a1822d7df160420e651659ce4dcb91..01c946d1ff9d83d3c8ecb87a7e761e799c5ce7e2 100644 (file)
@@ -46,10 +46,10 @@ function notification($params)
                return false;
        }
 
-       $params['notify_flags'] = defaults($params, 'notify_flags', $user['notify-flags']);
-       $params['language']     = defaults($params, 'language'    , $user['language']);
-       $params['to_name']      = defaults($params, 'to_name'     , $user['username']);
-       $params['to_email']     = defaults($params, 'to_email'    , $user['email']);
+       $params['notify_flags'] = ($params['notify_flags'] ?? '') ?: $user['notify-flags'];
+       $params['language']     = ($params['language']     ?? '') ?: $user['language'];
+       $params['to_name']      = ($params['to_name']      ?? '') ?: $user['username'];
+       $params['to_email']     = ($params['to_email']     ?? '') ?: $user['email'];
 
        // from here on everything is in the recipients language
        L10n::pushLang($params['language']);
@@ -456,17 +456,17 @@ function notification($params)
                if (!isset($params['subject'])) {
                        Logger::warning('subject isn\'t set.', ['type' => $params['type']]);
                }
-               $subject = defaults($params, 'subject', '');
+               $subject = $params['subject'] ?? '';
 
                if (!isset($params['preamble'])) {
                        Logger::warning('preamble isn\'t set.', ['type' => $params['type'], 'subject' => $subject]);
                }
-               $preamble = defaults($params, 'preamble', '');
+               $preamble = $params['preamble'] ?? '';
 
                if (!isset($params['body'])) {
                        Logger::warning('body isn\'t set.', ['type' => $params['type'], 'subject' => $subject, 'preamble' => $preamble]);
                }
-               $body = defaults($params, 'body', '');
+               $body = $params['body'] ?? '';
 
                $show_in_notification_page = false;
        }
@@ -613,11 +613,11 @@ function notification($params)
                $datarray['siteurl'] = $siteurl;
                $datarray['type'] = $params['type'];
                $datarray['parent'] = $parent_id;
-               $datarray['source_name'] = defaults($params, 'source_name', '');
-               $datarray['source_link'] = defaults($params, 'source_link', '');
-               $datarray['source_photo'] = defaults($params, 'source_photo', '');
+               $datarray['source_name'] = $params['source_name'] ?? '';
+               $datarray['source_link'] = $params['source_link'] ?? '';
+               $datarray['source_photo'] = $params['source_photo'] ?? '';
                $datarray['uid'] = $params['uid'];
-               $datarray['username'] = defaults($params, 'to_name', '');
+               $datarray['username'] = $params['to_name'] ?? '';
                $datarray['hsitelink'] = $hsitelink;
                $datarray['tsitelink'] = $tsitelink;
                $datarray['hitemlink'] = '<a href="'.$itemlink.'">'.$itemlink.'</a>';
index 4cc10e628cd50ec95f56884f2c4b6e58f856e50e..3868db40a29770b186d918baa3d0651706bfb568 100644 (file)
@@ -42,7 +42,7 @@ function add_page_info_data(array $data, $no_photos = false)
                $data["type"] = "link";
        }
 
-       $data["title"] = defaults($data, "title", "");
+       $data["title"] = $data["title"] ?? '';
 
        if ((($data["type"] != "link") && ($data["type"] != "video") && ($data["type"] != "photo")) || ($data["title"] == $data["url"])) {
                return "";
index eba8d975865b2728a114b8981be0035375d8216b..51d17a10a43b98cb850d25bb39d7197b0f5969d1 100644 (file)
@@ -200,7 +200,7 @@ function cal_content(App $a)
 
                // put the event parametes in an array so we can better transmit them
                $event_params = [
-                       'event_id'      => intval(defaults($_GET, 'id', 0)),
+                       'event_id'      => intval($_GET['id'] ?? 0),
                        'start'         => $start,
                        'finish'        => $finish,
                        'adjust_start'  => $adjust_start,
index a2821921c6ca21a4f4c8a0ba48999b4e6619782f..9d441f18a7c5aaa81d343ca08a14260df5d06c34 100644 (file)
@@ -118,7 +118,7 @@ function common_content(App $a)
 
                $entry = [
                        'url'          => Model\Contact::magicLink($common_friend['url']),
-                       'itemurl'      => defaults($contact_details, 'addr', $common_friend['url']),
+                       'itemurl'      => ($contact_details['addr'] ?? '') ?: $common_friend['url'],
                        'name'         => $contact_details['name'],
                        'thumb'        => ProxyUtils::proxifyUrl($contact_details['thumb'], false, ProxyUtils::SIZE_THUMB),
                        'img_hover'    => $contact_details['name'],
index ce27b44982a26a295dd68d75ea2bdaa76b339b02..84cb458fa2ab77dd5f4bb1b3f67d1d22db10757e 100644 (file)
@@ -38,17 +38,17 @@ function crepair_post(App $a)
                return;
        }
 
-       $name        = defaults($_POST, 'name'       , $contact['name']);
-       $nick        = defaults($_POST, 'nick'       , '');
-       $url         = defaults($_POST, 'url'        , '');
-       $alias       = defaults($_POST, 'alias'      , '');
-       $request     = defaults($_POST, 'request'    , '');
-       $confirm     = defaults($_POST, 'confirm'    , '');
-       $notify      = defaults($_POST, 'notify'     , '');
-       $poll        = defaults($_POST, 'poll'       , '');
-       $attag       = defaults($_POST, 'attag'      , '');
-       $photo       = defaults($_POST, 'photo'      , '');
-       $remote_self = defaults($_POST, 'remote_self', false);
+       $name        = ($_POST['name']        ?? '') ?: $contact['name'];
+       $nick        =  $_POST['nick']        ?? '';
+       $url         =  $_POST['url']         ?? '';
+       $alias       =  $_POST['alias']       ?? '';
+       $request     =  $_POST['request']     ?? '';
+       $confirm     =  $_POST['confirm']     ?? '';
+       $notify      =  $_POST['notify']      ?? '';
+       $poll        =  $_POST['poll']        ?? '';
+       $attag       =  $_POST['attag']       ?? '';
+       $photo       =  $_POST['photo']       ?? '';
+       $remote_self =  $_POST['remote_self'] ?? false;
        $nurl        = Strings::normaliseLink($url);
 
        $r = DBA::update(
index 9f9684e0936e9b40ede108ac7a00b7903d4d78c6..944ba98be2fffb4bff09bb99b6ccf9a1c80bb8ec 100644 (file)
@@ -59,7 +59,7 @@ function dfrn_confirm_post(App $a, $handsfree = null)
         * since we are operating on behalf of our registered user to approve a friendship.
         */
        if (empty($_POST['source_url'])) {
-               $uid = defaults($handsfree, 'uid', local_user());
+               $uid = ($handsfree['uid'] ?? 0) ?: local_user();
                if (!$uid) {
                        notice(L10n::t('Permission denied.') . EOL);
                        return;
@@ -78,13 +78,13 @@ function dfrn_confirm_post(App $a, $handsfree = null)
                        $intro_id = $handsfree['intro_id'];
                        $duplex   = $handsfree['duplex'];
                        $cid      = 0;
-                       $hidden   = intval(defaults($handsfree, 'hidden'  , 0));
+                       $hidden   = intval($handsfree['hidden'] ?? 0);
                } else {
-                       $dfrn_id  = Strings::escapeTags(trim(defaults($_POST, 'dfrn_id'   , '')));
-                       $intro_id =      intval(defaults($_POST, 'intro_id'  , 0));
-                       $duplex   =      intval(defaults($_POST, 'duplex'    , 0));
-                       $cid      =      intval(defaults($_POST, 'contact_id', 0));
-                       $hidden   =      intval(defaults($_POST, 'hidden'    , 0));
+                       $dfrn_id  = Strings::escapeTags(trim($_POST['dfrn_id'] ?? ''));
+                       $intro_id = intval($_POST['intro_id']   ?? 0);
+                       $duplex   = intval($_POST['duplex']     ?? 0);
+                       $cid      = intval($_POST['contact_id'] ?? 0);
+                       $hidden   = intval($_POST['hidden']     ?? 0);
                }
 
                /*
@@ -347,12 +347,12 @@ function dfrn_confirm_post(App $a, $handsfree = null)
         */
        if (!empty($_POST['source_url'])) {
                // We are processing an external confirmation to an introduction created by our user.
-               $public_key =         defaults($_POST, 'public_key', '');
-               $dfrn_id    = hex2bin(defaults($_POST, 'dfrn_id'   , ''));
-               $source_url = hex2bin(defaults($_POST, 'source_url', ''));
-               $aes_key    =         defaults($_POST, 'aes_key'   , '');
-               $duplex     =  intval(defaults($_POST, 'duplex'    , 0));
-               $page       =  intval(defaults($_POST, 'page'      , 0));
+               $public_key =         $_POST['public_key'] ?? '';
+               $dfrn_id    = hex2bin($_POST['dfrn_id']    ?? '');
+               $source_url = hex2bin($_POST['source_url'] ?? '');
+               $aes_key    =         $_POST['aes_key']    ?? '';
+               $duplex     =  intval($_POST['duplex']     ?? 0);
+               $page       =  intval($_POST['page']       ?? 0);
 
                $forum = (($page == 1) ? 1 : 0);
                $prv   = (($page == 2) ? 1 : 0);
index 3f0ecba005e8e8333ee97dee626ff61c45dac13a..dee6bad779538e3c540ba856befc2781a6df88e8 100644 (file)
@@ -26,7 +26,7 @@ function dfrn_notify_post(App $a) {
        if (empty($_POST) || !empty($postdata)) {
                $data = json_decode($postdata);
                if (is_object($data)) {
-                       $nick = defaults($a->argv, 1, '');
+                       $nick = $a->argv[1] ?? '';
 
                        $user = DBA::selectFirst('user', [], ['nickname' => $nick, 'account_expired' => false, 'account_removed' => false]);
                        if (!DBA::isResult($user)) {
@@ -42,8 +42,8 @@ function dfrn_notify_post(App $a) {
        $dfrn_id      = (!empty($_POST['dfrn_id'])      ? Strings::escapeTags(trim($_POST['dfrn_id']))   : '');
        $dfrn_version = (!empty($_POST['dfrn_version']) ? (float) $_POST['dfrn_version']    : 2.0);
        $challenge    = (!empty($_POST['challenge'])    ? Strings::escapeTags(trim($_POST['challenge'])) : '');
-       $data         = defaults($_POST, 'data', '');
-       $key          = defaults($_POST, 'key', '');
+       $data         = $_POST['data'] ?? '';
+       $key          = $_POST['key'] ?? '';
        $rino_remote  = (!empty($_POST['rino'])         ? intval($_POST['rino'])            :  0);
        $dissolve     = (!empty($_POST['dissolve'])     ? intval($_POST['dissolve'])        :  0);
        $perm         = (!empty($_POST['perm'])         ? Strings::escapeTags(trim($_POST['perm']))      : 'r');
index c6134bb45d48ee636606a0059377d0776c376a84..ca60cc87a100f07dca83f88395f8ac8f4cf39d27 100644 (file)
@@ -22,17 +22,17 @@ function dfrn_poll_init(App $a)
 {
        Login::sessionAuth();
 
-       $dfrn_id         = defaults($_GET, 'dfrn_id'        , '');
-       $type            = defaults($_GET, 'type'           , 'data');
-       $last_update     = defaults($_GET, 'last_update'    , '');
-       $destination_url = defaults($_GET, 'destination_url', '');
-       $challenge       = defaults($_GET, 'challenge'      , '');
-       $sec             = defaults($_GET, 'sec'            , '');
-       $dfrn_version    = (float) defaults($_GET, 'dfrn_version'   , 2.0);
+       $dfrn_id         =  $_GET['dfrn_id']         ?? '';
+       $type            = ($_GET['type']            ?? '') ?: 'data';
+       $last_update     =  $_GET['last_update']     ?? '';
+       $destination_url =  $_GET['destination_url'] ?? '';
+       $challenge       =  $_GET['challenge']       ?? '';
+       $sec             =  $_GET['sec']             ?? '';
+       $dfrn_version    = floatval(($_GET['dfrn_version'] ?? 0.0) ?: 2.0);
        $quiet                   = !empty($_GET['quiet']);
 
        // Possibly it is an OStatus compatible server that requests a user feed
-       $user_agent = defaults($_SERVER, 'HTTP_USER_AGENT', '');
+       $user_agent = $_SERVER['HTTP_USER_AGENT'] ?? '';
        if (($a->argc > 1) && ($dfrn_id == '') && !strstr($user_agent, 'Friendica')) {
                $nickname = $a->argv[1];
                header("Content-type: application/atom+xml");
@@ -225,13 +225,13 @@ function dfrn_poll_init(App $a)
 
 function dfrn_poll_post(App $a)
 {
-       $dfrn_id      = defaults($_POST, 'dfrn_id'  , '');
-       $challenge    = defaults($_POST, 'challenge', '');
-       $url          = defaults($_POST, 'url'      , '');
-       $sec          = defaults($_POST, 'sec'      , '');
-       $ptype        = defaults($_POST, 'type'     , '');
-       $perm         = defaults($_POST, 'perm'     , 'r');
-       $dfrn_version = !empty($_POST['dfrn_version']) ? (float) $_POST['dfrn_version'] : 2.0;
+       $dfrn_id      =  $_POST['dfrn_id']   ?? '';
+       $challenge    =  $_POST['challenge'] ?? '';
+       $url          =  $_POST['url']       ?? '';
+       $sec          =  $_POST['sec']       ?? '';
+       $ptype        =  $_POST['type']      ?? '';
+       $perm         = ($_POST['perm']      ?? '') ?: 'r';
+       $dfrn_version = floatval(($_GET['dfrn_version'] ?? 0.0) ?: 2.0);
 
        if ($ptype === 'profile-check') {
                if (strlen($challenge) && strlen($sec)) {
@@ -391,12 +391,12 @@ function dfrn_poll_post(App $a)
 
 function dfrn_poll_content(App $a)
 {
-       $dfrn_id         = defaults($_GET, 'dfrn_id'        , '');
-       $type            = defaults($_GET, 'type'           , 'data');
-       $last_update     = defaults($_GET, 'last_update'    , '');
-       $destination_url = defaults($_GET, 'destination_url', '');
-       $sec             = defaults($_GET, 'sec'            , '');
-       $dfrn_version    = !empty($_GET['dfrn_version'])    ? (float) $_GET['dfrn_version'] : 2.0;
+       $dfrn_id         =  $_GET['dfrn_id']         ?? '';
+       $type            = ($_GET['type']            ?? '') ?: 'data';
+       $last_update     =  $_GET['last_update']     ?? '';
+       $destination_url =  $_GET['destination_url'] ?? '';
+       $sec             =  $_GET['sec']             ?? '';
+       $dfrn_version    = floatval(($_GET['dfrn_version'] ?? 0.0) ?: 2.0);
        $quiet           = !empty($_GET['quiet']);
 
        $direction = -1;
index f78da7fb04d70a40c5b841de3d2b82c5edf5da75..f37064573bf0762a852c508b4d08b888c0abee1a 100644 (file)
@@ -80,7 +80,7 @@ function dfrn_request_post(App $a)
                if (local_user() && ($a->user['nickname'] == $a->argv[1]) && !empty($_POST['dfrn_url'])) {
                        $dfrn_url    = Strings::escapeTags(trim($_POST['dfrn_url']));
                        $aes_allow   = !empty($_POST['aes_allow']);
-                       $confirm_key = defaults($_POST, 'confirm_key', "");
+                       $confirm_key = $_POST['confirm_key'] ?? '';
                        $hidden      = (!empty($_POST['hidden-contact']) ? intval($_POST['hidden-contact']) : 0);
                        $contact_record = null;
                        $blocked     = 1;
@@ -169,7 +169,7 @@ function dfrn_request_post(App $a)
                                $r = q("SELECT `id`, `network` FROM `contact` WHERE `uid` = %d AND `url` = '%s' AND `site-pubkey` = '%s' LIMIT 1",
                                        intval(local_user()),
                                        DBA::escape($dfrn_url),
-                                       defaults($parms, 'key', '') // Potentially missing
+                                       $parms['key'] ?? '' // Potentially missing
                                );
                                if (DBA::isResult($r)) {
                                        Group::addMember(User::getDefaultGroup(local_user(), $r[0]["network"]), $r[0]['id']);
@@ -423,7 +423,7 @@ function dfrn_request_post(App $a)
                                        intval($uid),
                                        intval($contact_record['id']),
                                        intval(!empty($_POST['knowyou'])),
-                                       DBA::escape(Strings::escapeTags(trim(defaults($_POST, 'dfrn-request-message', '')))),
+                                       DBA::escape(Strings::escapeTags(trim($_POST['dfrn-request-message'] ?? ''))),
                                        DBA::escape($hash),
                                        DBA::escape(DateTimeFormat::utcNow())
                                );
@@ -499,7 +499,7 @@ function dfrn_request_content(App $a)
 
                $dfrn_url = Strings::escapeTags(trim(hex2bin($_GET['dfrn_url'])));
                $aes_allow = !empty($_GET['aes_allow']);
-               $confirm_key = defaults($_GET, 'confirm_key', "");
+               $confirm_key = $_GET['confirm_key'] ?? '';
 
                // Checking fastlane for validity
                if (!empty($_SESSION['fastlane']) && (Strings::normaliseLink($_SESSION["fastlane"]) == Strings::normaliseLink($dfrn_url))) {
index 8513788dfca9eb9244434b67b1d13bd3868a323e..12fa8d7ecefb9c320e71b641b2f0e9af216cc2d0 100644 (file)
@@ -276,8 +276,8 @@ function display_content(App $a, $update = false, $update_uid = 0)
        if (isset($item_parent_uri)) {
                $parent = Item::selectFirst(['uid'], ['uri' => $item_parent_uri, 'wall' => true]);
                if (DBA::isResult($parent)) {
-                       $a->profile['uid'] = defaults($a->profile, 'uid', $parent['uid']);
-                       $a->profile['profile_uid'] = defaults($a->profile, 'profile_uid', $parent['uid']);
+                       $a->profile['uid'] = ($a->profile['uid'] ?? 0) ?: $parent['uid'];
+                       $a->profile['profile_uid'] = ($a->profile['profile_uid'] ?? 0) ?: $parent['uid'];
                        $is_remote_contact = Session::getRemoteContactID($a->profile['profile_uid']);
                        if ($is_remote_contact) {
                                $item_uid = $parent['uid'];
index 82257a84814f653bf8bc3b7c8a2e678c16a0f531..649a25ab1b35505e29c5ee5b121f836c400446a0 100644 (file)
@@ -59,11 +59,11 @@ function events_post(App $a)
        $cid = !empty($_POST['cid']) ? intval($_POST['cid']) : 0;
        $uid = local_user();
 
-       $start_text  = Strings::escapeHtml(defaults($_REQUEST, 'start_text', ''));
-       $finish_text = Strings::escapeHtml(defaults($_REQUEST, 'finish_text', ''));
+       $start_text  = Strings::escapeHtml($_REQUEST['start_text'] ?? '');
+       $finish_text = Strings::escapeHtml($_REQUEST['finish_text'] ?? '');
 
-       $adjust   = intval(defaults($_POST, 'adjust', 0));
-       $nofinish = intval(defaults($_POST, 'nofinish', 0));
+       $adjust   = intval($_POST['adjust'] ?? 0);
+       $nofinish = intval($_POST['nofinish'] ?? 0);
 
        // The default setting for the `private` field in event_store() is false, so mirror that
        $private_event = false;
@@ -96,9 +96,9 @@ function events_post(App $a)
        // and we'll waste a bunch of time responding to it. Time that
        // could've been spent doing something else.
 
-       $summary  = trim(defaults($_POST, 'summary' , ''));
-       $desc     = trim(defaults($_POST, 'desc'    , ''));
-       $location = trim(defaults($_POST, 'location', ''));
+       $summary  = trim($_POST['summary']  ?? '');
+       $desc     = trim($_POST['desc']     ?? '');
+       $location = trim($_POST['location'] ?? '');
        $type     = 'event';
 
        $params = [
@@ -132,7 +132,7 @@ function events_post(App $a)
                $a->internalRedirect($onerror_path);
        }
 
-       $share = intval(defaults($_POST, 'share', 0));
+       $share = intval($_POST['share'] ?? 0);
 
        $c = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `self` LIMIT 1",
                intval(local_user())
@@ -146,10 +146,10 @@ function events_post(App $a)
 
 
        if ($share) {
-               $str_group_allow   = perms2str(defaults($_POST, 'group_allow'  , ''));
-               $str_contact_allow = perms2str(defaults($_POST, 'contact_allow', ''));
-               $str_group_deny    = perms2str(defaults($_POST, 'group_deny'   , ''));
-               $str_contact_deny  = perms2str(defaults($_POST, 'contact_deny' , ''));
+               $str_group_allow   = perms2str($_POST['group_allow']   ?? '');
+               $str_contact_allow = perms2str($_POST['contact_allow'] ?? '');
+               $str_group_deny    = perms2str($_POST['group_deny']    ?? '');
+               $str_contact_deny  = perms2str($_POST['contact_deny']  ?? '');
 
                // Undo the pseudo-contact of self, since there are real contacts now
                if (strpos($str_contact_allow, '<' . $self . '>') !== false) {
index f2bccb085a6f0d4d93c9a981728d94698b1727cd..102d0c613d1a9cfb22f2d862939e0bd7b624f016 100644 (file)
@@ -29,7 +29,7 @@ function fbrowser_content(App $a)
        }
 
        // Needed to match the correct template in a module that uses a different theme than the user/site/default
-       $theme = Strings::sanitizeFilePathItem(defaults($_GET, 'theme', null));
+       $theme = Strings::sanitizeFilePathItem($_GET['theme'] ?? null);
        if ($theme && is_file("view/theme/$theme/config.php")) {
                $a->setCurrentTheme($theme);
        }
index c7a96f734f6a01ad7dd9b0449618eee1e95787d3..31b92aa0dc06eb6873de05af9f3a647febc5901e 100644 (file)
@@ -62,7 +62,7 @@ function follow_content(App $a)
        $uid = local_user();
 
        // Issue 4815: Silently removing a prefixing @
-       $url = ltrim(Strings::escapeTags(trim(defaults($_REQUEST, 'url', ''))), '@!');
+       $url = ltrim(Strings::escapeTags(trim($_REQUEST['url'] ?? '')), '@!');
 
        // Issue 6874: Allow remote following from Peertube
        if (strpos($url, 'acct:') === 0) {
index 2bddf48133103510becfb1c90290c86a2c820059..d41363ad7b38d153043b2afa7484bff30fdd8370 100644 (file)
@@ -45,7 +45,7 @@ function fsuggest_post(App $a)
                return;
        }
 
-       $note = Strings::escapeHtml(trim(defaults($_POST, 'note', '')));
+       $note = Strings::escapeHtml(trim($_POST['note'] ?? ''));
 
        $fields = ['uid' => local_user(),'cid' => $contact_id, 'name' => $contact['name'],
                'url' => $contact['url'], 'request' => $contact['request'],
index ad84e24e545dd506911edf9ce7fc78adc689c7fa..013619bcba6ca94a9aeb0d273cf979f3398e3e1f 100644 (file)
@@ -41,7 +41,7 @@ function hcard_init(App $a)
        }
 
        if (!$blocked) {
-               $keywords = defaults($a->profile, 'pub_keywords', '');
+               $keywords = $a->profile['pub_keywords'] ?? '';
                $keywords = str_replace([',',' ',',,'], [' ',',',','], $keywords);
                if (strlen($keywords)) {
                        $a->page['htmlhead'] .= '<meta name="keywords" content="' . $keywords . '" />' . "\r\n";
index ca399196368b71b3151d616924b8e59a8ab19cca..d5951dbe00fa19457eed86c2f4d267818ce2a5d7 100644 (file)
@@ -26,8 +26,8 @@ function hovercard_init(App $a)
 
 function hovercard_content()
 {
-       $profileurl = defaults($_REQUEST, 'profileurl', '');
-       $datatype   = defaults($_REQUEST, 'datatype'  , 'json');
+       $profileurl =  $_REQUEST['profileurl'] ?? '';
+       $datatype   = ($_REQUEST['datatype']   ?? '') ?: 'json';
 
        // Get out if the system doesn't have public access allowed
        if (intval(Config::get('system', 'block_public'))) {
@@ -50,7 +50,7 @@ function hovercard_content()
        if (strpos($profileurl, 'redir/') === 0) {
                $cid = intval(substr($profileurl, 6));
                $remote_contact = DBA::selectFirst('contact', ['nurl'], ['id' => $cid]);
-               $profileurl = defaults($remote_contact, 'nurl', '');
+               $profileurl = $remote_contact['nurl'] ?? '';
        }
 
        $contact = [];
@@ -97,7 +97,7 @@ function hovercard_content()
        $profile = [
                'name'         => $contact['name'],
                'nick'         => $contact['nick'],
-               'addr'         => defaults($contact, 'addr', $contact['url']),
+               'addr'         => ($contact['addr'] ?? '') ?: $contact['url'],
                'thumb'        => ProxyUtils::proxifyUrl($contact['thumb'], false, ProxyUtils::SIZE_THUMB),
                'url'          => Contact::magicLink($contact['url']),
                'nurl'         => $contact['nurl'], // We additionally store the nurl as identifier
index 64edf6e151c17d7a6dac97ee727259d016ef6883..6e0cf92a65912b9906f2d1d4693d6a2d5c79e7bc 100644 (file)
@@ -33,7 +33,7 @@ function ignored_init(App $a)
        }
 
        // See if we've been passed a return path to redirect to
-       $return_path = defaults($_REQUEST, 'return', '');
+       $return_path = $_REQUEST['return'] ?? '';
        if ($return_path) {
                $rand = '_=' . time();
                if (strpos($return_path, '?')) {
index b1c0355e01a5c2032fd73a1aac76c5f7056aa486..7c8ebee4abfdf5e3ae5c8271b394bd8bf4d0147e 100644 (file)
@@ -64,12 +64,12 @@ function item_post(App $a) {
 
        Logger::log('postvars ' . print_r($_REQUEST, true), Logger::DATA);
 
-       $api_source = defaults($_REQUEST, 'api_source', false);
+       $api_source = $_REQUEST['api_source'] ?? false;
 
        $message_id = ((!empty($_REQUEST['message_id']) && $api_source) ? strip_tags($_REQUEST['message_id']) : '');
 
-       $return_path = defaults($_REQUEST, 'return', '');
-       $preview = intval(defaults($_REQUEST, 'preview', 0));
+       $return_path = $_REQUEST['return'] ?? '';
+       $preview = intval($_REQUEST['preview'] ?? 0);
 
        /*
         * Check for doubly-submitted posts, and reject duplicates
@@ -86,8 +86,8 @@ function item_post(App $a) {
        }
 
        // Is this a reply to something?
-       $toplevel_item_id = intval(defaults($_REQUEST, 'parent', 0));
-       $thr_parent_uri = trim(defaults($_REQUEST, 'parent_uri', ''));
+       $toplevel_item_id = intval($_REQUEST['parent'] ?? 0);
+       $thr_parent_uri = trim($_REQUEST['parent_uri'] ?? '');
 
        $thread_parent_id = 0;
        $thread_parent_contact = null;
@@ -98,8 +98,8 @@ function item_post(App $a) {
        $parent_contact = null;
 
        $objecttype = null;
-       $profile_uid = defaults($_REQUEST, 'profile_uid', local_user());
-       $posttype = defaults($_REQUEST, 'post_type', Item::PT_ARTICLE);
+       $profile_uid = ($_REQUEST['profile_uid'] ?? 0) ?: local_user();
+       $posttype = ($_REQUEST['post_type'] ?? '') ?: Item::PT_ARTICLE;
 
        if ($toplevel_item_id || $thr_parent_uri) {
                if ($toplevel_item_id) {
@@ -138,10 +138,10 @@ function item_post(App $a) {
                Logger::info('mod_item: item_post parent=' . $toplevel_item_id);
        }
 
-       $post_id     = intval(defaults($_REQUEST, 'post_id', 0));
-       $app         = strip_tags(defaults($_REQUEST, 'source', ''));
-       $extid       = strip_tags(defaults($_REQUEST, 'extid', ''));
-       $object      = defaults($_REQUEST, 'object', '');
+       $post_id     = intval($_REQUEST['post_id'] ?? 0);
+       $app         = strip_tags($_REQUEST['source'] ?? '');
+       $extid       = strip_tags($_REQUEST['extid'] ?? '');
+       $object      = $_REQUEST['object'] ?? '';
 
        // Don't use "defaults" here. It would turn 0 to 1
        if (!isset($_REQUEST['wall'])) {
@@ -194,20 +194,20 @@ function item_post(App $a) {
        $categories = '';
        $postopts = '';
        $emailcc = '';
-       $body = defaults($_REQUEST, 'body', '');
-       $has_attachment = defaults($_REQUEST, 'has_attachment', 0);
+       $body = $_REQUEST['body'] ?? '';
+       $has_attachment = $_REQUEST['has_attachment'] ?? 0;
 
        // If we have a speparate attachment, we need to add it to the body.
        if (!empty($has_attachment)) {
-               $attachment_type  = defaults($_REQUEST, 'attachment_type',  '');
-               $attachment_title = defaults($_REQUEST, 'attachment_title', '');
-               $attachment_text  = defaults($_REQUEST, 'attachment_text',  '');
+               $attachment_type  = $_REQUEST['attachment_type'] ??  '';
+               $attachment_title = $_REQUEST['attachment_title'] ?? '';
+               $attachment_text  = $_REQUEST['attachment_text'] ??  '';
 
-               $attachment_url     = hex2bin(defaults($_REQUEST, 'attachment_url',     ''));
-               $attachment_img_src = hex2bin(defaults($_REQUEST, 'attachment_img_src', ''));
+               $attachment_url     = hex2bin($_REQUEST['attachment_url'] ??     '');
+               $attachment_img_src = hex2bin($_REQUEST['attachment_img_src'] ?? '');
 
-               $attachment_img_width  = defaults($_REQUEST, 'attachment_img_width',  0);
-               $attachment_img_height = defaults($_REQUEST, 'attachment_img_height', 0);
+               $attachment_img_width  = $_REQUEST['attachment_img_width'] ??  0;
+               $attachment_img_height = $_REQUEST['attachment_img_height'] ?? 0;
                $attachment = [
                        'type'   => $attachment_type,
                        'title'  => $attachment_title,
@@ -229,6 +229,9 @@ function item_post(App $a) {
                $body .= $att_bbcode;
        }
 
+       // Convert links with empty descriptions to links without an explicit description
+       $body = preg_replace('#\[url=([^\]]*?)\]\[/url\]#ism', '[url]$1[/url]', $body);
+
        if (!empty($orig_post)) {
                $str_group_allow   = $orig_post['allow_gid'];
                $str_contact_allow = $orig_post['allow_cid'];
@@ -266,22 +269,22 @@ function item_post(App $a) {
                        $str_contact_deny  = $user['deny_cid'];
                } else {
                        // use the posted permissions
-                       $str_group_allow   = perms2str(defaults($_REQUEST, 'group_allow', ''));
-                       $str_contact_allow = perms2str(defaults($_REQUEST, 'contact_allow', ''));
-                       $str_group_deny    = perms2str(defaults($_REQUEST, 'group_deny', ''));
-                       $str_contact_deny  = perms2str(defaults($_REQUEST, 'contact_deny', ''));
+                       $str_group_allow   = perms2str($_REQUEST['group_allow'] ?? '');
+                       $str_contact_allow = perms2str($_REQUEST['contact_allow'] ?? '');
+                       $str_group_deny    = perms2str($_REQUEST['group_deny'] ?? '');
+                       $str_contact_deny  = perms2str($_REQUEST['contact_deny'] ?? '');
                }
 
-               $title             = Strings::escapeTags(trim(defaults($_REQUEST, 'title'   , '')));
-               $location          = Strings::escapeTags(trim(defaults($_REQUEST, 'location', '')));
-               $coord             = Strings::escapeTags(trim(defaults($_REQUEST, 'coord'   , '')));
-               $verb              = Strings::escapeTags(trim(defaults($_REQUEST, 'verb'    , '')));
-               $emailcc           = Strings::escapeTags(trim(defaults($_REQUEST, 'emailcc' , '')));
+               $title             = Strings::escapeTags(trim($_REQUEST['title']    ?? ''));
+               $location          = Strings::escapeTags(trim($_REQUEST['location'] ?? ''));
+               $coord             = Strings::escapeTags(trim($_REQUEST['coord']    ?? ''));
+               $verb              = Strings::escapeTags(trim($_REQUEST['verb']     ?? ''));
+               $emailcc           = Strings::escapeTags(trim($_REQUEST['emailcc']  ?? ''));
                $body              = Strings::escapeHtml(trim($body));
-               $network           = Strings::escapeTags(trim(defaults($_REQUEST, 'network' , Protocol::DFRN)));
+               $network           = Strings::escapeTags(trim(($_REQUEST['network']  ?? '') ?: Protocol::DFRN));
                $guid              = System::createUUID();
 
-               $postopts = defaults($_REQUEST, 'postopts', '');
+               $postopts = $_REQUEST['postopts'] ?? '';
 
                $private = ((strlen($str_group_allow) || strlen($str_contact_allow) || strlen($str_group_deny) || strlen($str_contact_deny)) ? 1 : 0);
 
@@ -304,7 +307,7 @@ function item_post(App $a) {
                        $wall              = $toplevel_item['wall'];
                }
 
-               $pubmail_enabled = defaults($_REQUEST, 'pubmail_enable', false) && !$private;
+               $pubmail_enabled = ($_REQUEST['pubmail_enable'] ?? false) && !$private;
 
                // if using the API, we won't see pubmail_enable - figure out if it should be set
                if ($api_source && $profile_uid && $profile_uid == local_user() && !$private) {
@@ -332,7 +335,7 @@ function item_post(App $a) {
 
        // save old and new categories, so we can determine what needs to be deleted from pconfig
        $categories_old = $categories;
-       $categories = FileTag::listToFile(trim(defaults($_REQUEST, 'category', '')), 'category');
+       $categories = FileTag::listToFile(trim($_REQUEST['category'] ?? ''), 'category');
        $categories_new = $categories;
 
        if (!empty($filedas) && is_array($filedas)) {
@@ -1012,7 +1015,7 @@ function handle_tag(&$body, &$inform, &$str_tags, $profile_uid, $tag, $network =
 
                        $profile = $contact["url"];
                        $alias   = $contact["alias"];
-                       $newname = defaults($contact, "name", $contact["nick"]);
+                       $newname = ($contact["name"] ?? '') ?: $contact["nick"];
                }
 
                //if there is an url for this persons profile
index 2b3c7ca525b695ae45571afb9e9f193676869301..41346bc89d6a12e3788b616246e4a1c92abc6212 100644 (file)
@@ -66,7 +66,7 @@ function match_content(App $a)
 
        $msearch = json_decode($msearch_json);
 
-       $start = defaults($_GET, 'start', 0);
+       $start = $_GET['start'] ?? 0;
        $entries = [];
        $paginate = '';
 
@@ -92,11 +92,11 @@ function match_content(App $a)
 
                        $entry = [
                                'url'          => Contact::magicLink($profile->url),
-                               'itemurl'      => defaults($contact_details, 'addr', $profile->url),
+                               'itemurl'      => $contact_details['addr'] ?? $profile->url,
                                'name'         => $profile->name,
-                               'details'      => defaults($contact_details, 'location', ''),
-                               'tags'         => defaults($contact_details, 'keywords', ''),
-                               'about'        => defaults($contact_details, 'about', ''),
+                               'details'      => $contact_details['location'] ?? '',
+                               'tags'         => $contact_details['keywords'] ?? '',
+                               'about'        => $contact_details['about'] ?? '',
                                'account_type' => Contact::getAccountType($contact_details),
                                'thumb'        => ProxyUtils::proxifyUrl($profile->photo, false, ProxyUtils::SIZE_THUMB),
                                'conntxt'      => L10n::t('Connect'),
index fe4429e0008b8bf8741d5edde312e52e03be1015..393d5d276bdee950a8ca48049e4b1ede011d5121 100644 (file)
@@ -249,8 +249,8 @@ function message_content(App $a)
                        '$prefill'    => $prefill,
                        '$preid'      => $preid,
                        '$subject'    => L10n::t('Subject:'),
-                       '$subjtxt'    => defaults($_REQUEST, 'subject', ''),
-                       '$text'       => defaults($_REQUEST, 'body', ''),
+                       '$subjtxt'    => $_REQUEST['subject'] ?? '',
+                       '$text'       => $_REQUEST['body'] ?? '',
                        '$readonly'   => '',
                        '$yourmessage'=> L10n::t('Your message:'),
                        '$select'     => $select,
@@ -530,7 +530,7 @@ function render_messages(array $msg, $t)
                        '$id' => $rr['id'],
                        '$from_name' => $participants,
                        '$from_url' => Contact::magicLink($rr['url']),
-                       '$from_addr' => defaults($contact, 'addr', ''),
+                       '$from_addr' => $contact['addr'] ?? '',
                        '$sparkle' => ' sparkle',
                        '$from_photo' => ProxyUtils::proxifyUrl($from_photo, false, ProxyUtils::SIZE_THUMB),
                        '$subject' => $rr['title'],
index fcb93a32f01b5ec495b38f4641d817eadf3a45ec..e87a8f522c8d4ef11aeaa9be41291bc8b58ef48d 100644 (file)
@@ -6,9 +6,9 @@ use Friendica\Database\DBA;
 
 function msearch_post(App $a)
 {
-       $search = defaults($_POST, 's', '');
-       $perpage  = intval(defaults($_POST, 'n', 80));
-       $page     = intval(defaults($_POST, 'p', 1));
+       $search = $_POST['s'] ?? '';
+       $perpage  = intval(($_POST['n'] ?? 0) ?: 80);
+       $page     = intval(($_POST['p'] ?? 0) ?: 1);
        $startrec = ($page - 1) * $perpage;
 
        $total = 0;
index 515219827adea97c87a97b0fec33325541795ae4..0438be7059d7680ba8dbd926ef922473ed4bd9b5 100644 (file)
@@ -66,7 +66,7 @@ function network_init(App $a)
 
        // fetch last used network view and redirect if needed
        if (!$is_a_date_query) {
-               $sel_nets = defaults($_GET, 'nets', '');
+               $sel_nets = $_GET['nets'] ?? '';
                $sel_tabs = network_query_get_sel_tab($a);
                $sel_groups = network_query_get_sel_group($a);
                $last_sel_tabs = PConfig::get(local_user(), 'network.view', 'tab.selected');
@@ -138,9 +138,9 @@ function network_init(App $a)
        $a->page['aside'] .= Group::sidebarWidget('network/0', 'network', 'standard', $group_id);
        $a->page['aside'] .= ForumManager::widget(local_user(), $cid);
        $a->page['aside'] .= Widget::postedByYear('network', local_user(), false);
-       $a->page['aside'] .= Widget::networks('network', defaults($_GET, 'nets', '') );
+       $a->page['aside'] .= Widget::networks('network', $_GET['nets'] ?? '');
        $a->page['aside'] .= Widget\SavedSearches::getHTML($a->query_string);
-       $a->page['aside'] .= Widget::fileAs('network', defaults($_GET, 'file', '') );
+       $a->page['aside'] .= Widget::fileAs('network', $_GET['file'] ?? '');
 }
 
 /**
@@ -356,7 +356,7 @@ function networkFlatView(App $a, $update = 0)
 
        $o = '';
 
-       $file = defaults($_GET, 'file', '');
+       $file = $_GET['file'] ?? '';
 
        if (!$update && !$rawmode) {
                $tabs = network_tabs($a);
@@ -479,12 +479,12 @@ function networkThreadedView(App $a, $update, $parent)
 
        $o = '';
 
-       $cid   = intval(defaults($_GET, 'cid'  , 0));
-       $star  = intval(defaults($_GET, 'star' , 0));
-       $bmark = intval(defaults($_GET, 'bmark', 0));
-       $conv  = intval(defaults($_GET, 'conv' , 0));
-       $order = Strings::escapeTags(defaults($_GET, 'order', 'comment'));
-       $nets  =        defaults($_GET, 'nets' , '');
+       $cid   = intval($_GET['cid']   ?? 0);
+       $star  = intval($_GET['star']  ?? 0);
+       $bmark = intval($_GET['bmark'] ?? 0);
+       $conv  = intval($_GET['conv']  ?? 0);
+       $order = Strings::escapeTags(($_GET['order'] ?? '') ?: 'comment');
+       $nets  =        $_GET['nets']  ?? '';
 
        $allowedCids = [];
        if ($cid) {
@@ -623,7 +623,7 @@ function networkThreadedView(App $a, $update, $parent)
                        $entries[0] = [
                                'id' => 'network',
                                'name' => $contact['name'],
-                               'itemurl' => defaults($contact, 'addr', $contact['nurl']),
+                               'itemurl' => ($contact['addr'] ?? '') ?: $contact['nurl'],
                                'thumb' => ProxyUtils::proxifyUrl($contact['thumb'], false, ProxyUtils::SIZE_THUMB),
                                'details' => $contact['location'],
                        ];
@@ -1013,7 +1013,7 @@ function network_infinite_scroll_head(App $a, &$htmlhead)
        global $pager;
 
        if (PConfig::get(local_user(), 'system', 'infinite_scroll')
-               && defaults($_GET, 'mode', '') != 'minimal'
+               && ($_GET['mode'] ?? '') != 'minimal'
        ) {
                $tpl = Renderer::getMarkupTemplate('infinite_scroll_head.tpl');
                $htmlhead .= Renderer::replaceMacros($tpl, [
index 5761df3ff902be078a0d91d0baec9cdbd8a4f5e0..7b8c0bdeb1f234b5310d605a117fd54089fe1085 100644 (file)
@@ -49,7 +49,7 @@ function noscrape_init(App $a)
                exit;
        }
 
-       $keywords = defaults($a->profile, 'pub_keywords', '');
+       $keywords = $a->profile['pub_keywords'] ?? '';
        $keywords = str_replace(['#',',',' ',',,'], ['',' ',',',','], $keywords);
        $keywords = explode(',', $keywords);
 
index cd572895f14b3abd23e83ca56c9558f04c0aa784..8fbc5dac4964599967fc69df58276f1fbb5dbc64 100644 (file)
@@ -78,8 +78,8 @@ function notifications_content(App $a)
                return Login::form();
        }
 
-       $page = defaults($_REQUEST, 'page', 1);
-       $show = defaults($_REQUEST, 'show', 0);
+       $page = ($_REQUEST['page'] ?? 0) ?: 1;
+       $show =  $_REQUEST['show'] ?? 0;
 
        Nav::setSelected('notifications');
 
@@ -158,7 +158,7 @@ function notifications_content(App $a)
        ];
 
        // Process the data for template creation
-       if (defaults($notifs, 'ident', '') === 'introductions') {
+       if (($notifs['ident'] ?? '') == 'introductions') {
                $sugg = Renderer::getMarkupTemplate('suggestions.tpl');
                $tpl = Renderer::getMarkupTemplate('intros.tpl');
 
index 84be1c8285d0f0080bbdbe1e71470379c1e226c2..1789c0710e1ea6d74fcf34b3f22dba1dc597576d 100644 (file)
@@ -63,9 +63,9 @@ function photos_init(App $a) {
                $vcard_widget = Renderer::replaceMacros($tpl, [
                        '$name' => $profile['name'],
                        '$photo' => $profile['photo'],
-                       '$addr' => defaults($profile, 'addr', ''),
+                       '$addr' => $profile['addr'] ?? '',
                        '$account_type' => $account_type,
-                       '$pdesc' => defaults($profile, 'pdesc', ''),
+                       '$pdesc' => $profile['pdesc'] ?? '',
                ]);
 
                $albums = Photo::getAlbums($a->data['user']['uid']);
@@ -630,10 +630,10 @@ function photos_post(App $a)
                $visible = 0;
        }
 
-       $group_allow   = defaults($_REQUEST, 'group_allow'  , []);
-       $contact_allow = defaults($_REQUEST, 'contact_allow', []);
-       $group_deny    = defaults($_REQUEST, 'group_deny'   , []);
-       $contact_deny  = defaults($_REQUEST, 'contact_deny' , []);
+       $group_allow   = $_REQUEST['group_allow']   ?? [];
+       $contact_allow = $_REQUEST['contact_allow'] ?? [];
+       $group_deny    = $_REQUEST['group_deny']    ?? [];
+       $contact_deny  = $_REQUEST['contact_deny']  ?? [];
 
        $str_group_allow   = perms2str(is_array($group_allow)   ? $group_allow   : explode(',', $group_allow));
        $str_contact_allow = perms2str(is_array($contact_allow) ? $contact_allow : explode(',', $contact_allow));
@@ -666,7 +666,7 @@ function photos_post(App $a)
                                notice(L10n::t('Image exceeds size limit of %s', ini_get('upload_max_filesize')) . EOL);
                                break;
                        case UPLOAD_ERR_FORM_SIZE:
-                               notice(L10n::t('Image exceeds size limit of %s', Strings::formatBytes(defaults($_REQUEST, 'MAX_FILE_SIZE', 0))) . EOL);
+                               notice(L10n::t('Image exceeds size limit of %s', Strings::formatBytes($_REQUEST['MAX_FILE_SIZE'] ?? 0)) . EOL);
                                break;
                        case UPLOAD_ERR_PARTIAL:
                                notice(L10n::t('Image upload didn\'t complete, please try again') . EOL);
@@ -1006,7 +1006,7 @@ function photos_content(App $a)
                $pager = new Pager($a->query_string, 20);
 
                /// @TODO I have seen this many times, maybe generalize it script-wide and encapsulate it?
-               $order_field = defaults($_GET, 'order', '');
+               $order_field = $_GET['order'] ?? '';
                if ($order_field === 'posted') {
                        $order = 'ASC';
                } else {
@@ -1158,7 +1158,7 @@ function photos_content(App $a)
                 * By now we hide it if someone wants to.
                 */
                if ($cmd === 'view' && !Config::get('system', 'no_count', false)) {
-                       $order_field = defaults($_GET, 'order', '');
+                       $order_field = $_GET['order'] ?? '';
 
                        if ($order_field === 'posted') {
                                $order = 'ASC';
index c288f6b6393bf8a7bf3eb082b8714cb3dc4a914a..2ed871285b76586b38e30eb63def4c6d49816cb9 100644 (file)
@@ -36,7 +36,7 @@ function poco_init(App $a) {
                $system_mode = true;
        }
 
-       $format = defaults($_GET, 'format', 'json');
+       $format = ($_GET['format'] ?? '') ?: 'json';
 
        $justme = false;
        $global = false;
index d10d7031d6e203507817288afed647e69a47ecc6..c008fb09dac3b93d887005f66c8874f576f45148 100644 (file)
@@ -33,10 +33,10 @@ function pubsub_init(App $a)
        $contact_id = (($a->argc > 2) ? intval($a->argv[2])       : 0 );
 
        if ($_SERVER['REQUEST_METHOD'] === 'GET') {
-               $hub_mode      = Strings::escapeTags(trim(defaults($_GET, 'hub_mode', '')));
-               $hub_topic     = Strings::escapeTags(trim(defaults($_GET, 'hub_topic', '')));
-               $hub_challenge = Strings::escapeTags(trim(defaults($_GET, 'hub_challenge', '')));
-               $hub_verify    = Strings::escapeTags(trim(defaults($_GET, 'hub_verify_token', '')));
+               $hub_mode      = Strings::escapeTags(trim($_GET['hub_mode'] ?? ''));
+               $hub_topic     = Strings::escapeTags(trim($_GET['hub_topic'] ?? ''));
+               $hub_challenge = Strings::escapeTags(trim($_GET['hub_challenge'] ?? ''));
+               $hub_verify    = Strings::escapeTags(trim($_GET['hub_verify_token'] ?? ''));
 
                Logger::log('Subscription from ' . $_SERVER['REMOTE_ADDR'] . ' Mode: ' . $hub_mode . ' Nick: ' . $nick);
                Logger::log('Data: ' . print_r($_GET,true), Logger::DATA);
index 12d93186e29d65e9a02052fa599ef9661cd59961..9d86f27a9624a70adcc8b86d11e76d4f20a63ee8 100644 (file)
@@ -13,7 +13,7 @@ use Friendica\Util\Strings;
 
 function redir_init(App $a) {
 
-       $url = defaults($_GET, 'url', '');
+       $url = $_GET['url'] ?? '';
        $quiet = !empty($_GET['quiet']) ? '&quiet=1' : '';
 
        if ($a->argc > 1 && intval($a->argv[1])) {
@@ -38,7 +38,7 @@ function redir_init(App $a) {
                if (!Session::isAuthenticated() // Visitors (not logged in or not remotes) can't authenticate.
                        || (!empty($a->contact['id']) && $a->contact['id'] == $cid)) // Local user is already authenticated.
                {
-                       $a->redirect(defaults($url, $contact_url));
+                       $a->redirect($url ?: $contact_url);
                }
 
                if ($contact['uid'] == 0 && local_user()) {
@@ -52,7 +52,7 @@ function redir_init(App $a) {
 
                        if (!empty($a->contact['id']) && $a->contact['id'] == $cid) {
                                // Local user is already authenticated.
-                               $target_url = defaults($url, $contact_url);
+                               $target_url = $url ?: $contact_url;
                                Logger::log($contact['name'] . " is already authenticated. Redirecting to " . $target_url, Logger::DEBUG);
                                $a->redirect($target_url);
                        }
@@ -68,7 +68,7 @@ function redir_init(App $a) {
                        // contact.
                        if (($host == $remotehost) && (Session::getRemoteContactID(Session::get('visitor_visiting')) == Session::get('visitor_id'))) {
                                // Remote user is already authenticated.
-                               $target_url = defaults($url, $contact_url);
+                               $target_url = $url ?: $contact_url;
                                Logger::log($contact['name'] . " is already authenticated. Redirecting to " . $target_url, Logger::DEBUG);
                                $a->redirect($target_url);
                        }
@@ -101,7 +101,7 @@ function redir_init(App $a) {
                                . '&dfrn_version=' . DFRN_PROTOCOL_VERSION . '&type=profile&sec=' . $sec . $dest . $quiet);
                }
 
-               $url = defaults($url, $contact_url);
+               $url = $url ?: $contact_url;
        }
 
        // If we don't have a connected contact, redirect with
@@ -142,7 +142,7 @@ function redir_magic($a, $cid, $url)
                }
        } else {
                $contact_url = $contact['url'];
-               $target_url = defaults($url, $contact_url);
+               $target_url = $url ?: $contact_url;
        }
 
        $basepath = Contact::getBasepath($contact_url);
index 6cf4c8836c8de48a5c2b617ff625b3253f58ce20..295d8df25f5a02066c41d74376f8bdd0941f7bb4 100644 (file)
@@ -44,7 +44,7 @@ function user_allow($hash)
                $user,
                Config::get('config', 'sitename'),
                $a->getBaseUrl(),
-               defaults($register, 'password', 'Sent in a previous email')
+               ($register['password'] ?? '') ?: 'Sent in a previous email'
        );
 
        L10n::popLang();
index 0d519e5a073ac3d26dbc3b14f02e06989c08d24b..b5011881cb9b5871308dba82c7d5f4211c955589 100644 (file)
@@ -35,7 +35,7 @@ function get_theme_config_file($theme)
        $theme = Strings::sanitizeFilePathItem($theme);
 
        $a = \get_app();
-       $base_theme = defaults($a->theme_info, 'extends');
+       $base_theme = $a->theme_info['extends'] ?? '';
 
        if (file_exists("view/theme/$theme/config.php")) {
                return "view/theme/$theme/config.php";
@@ -180,11 +180,11 @@ function settings_post(App $a)
        if (($a->argc > 2) && ($a->argv[1] === 'oauth')  && ($a->argv[2] === 'edit'||($a->argv[2] === 'add')) && !empty($_POST['submit'])) {
                BaseModule::checkFormSecurityTokenRedirectOnError('/settings/oauth', 'settings_oauth');
 
-               $name     = defaults($_POST, 'name'    , '');
-               $key      = defaults($_POST, 'key'     , '');
-               $secret   = defaults($_POST, 'secret'  , '');
-               $redirect = defaults($_POST, 'redirect', '');
-               $icon     = defaults($_POST, 'icon'    , '');
+               $name     = $_POST['name']     ?? '';
+               $key      = $_POST['key']      ?? '';
+               $secret   = $_POST['secret']   ?? '';
+               $redirect = $_POST['redirect'] ?? '';
+               $icon     = $_POST['icon']     ?? '';
 
                if ($name == "" || $key == "" || $secret == "") {
                        notice(L10n::t("Missing some important data!"));
@@ -241,24 +241,21 @@ function settings_post(App $a)
                        PConfig::set(local_user(), 'ostatus', 'default_group', $_POST['group-selection']);
                        PConfig::set(local_user(), 'ostatus', 'legacy_contact', $_POST['legacy_contact']);
                } elseif (!empty($_POST['imap-submit'])) {
-
-                       $mail_server       = defaults($_POST, 'mail_server', '');
-                       $mail_port         = defaults($_POST, 'mail_port', '');
-                       $mail_ssl          = (!empty($_POST['mail_ssl']) ? strtolower(trim($_POST['mail_ssl'])) : '');
-                       $mail_user         = defaults($_POST, 'mail_user', '');
-                       $mail_pass         = (!empty($_POST['mail_pass']) ? trim($_POST['mail_pass']) : '');
-                       $mail_action       = (!empty($_POST['mail_action']) ? trim($_POST['mail_action']) : '');
-                       $mail_movetofolder = (!empty($_POST['mail_movetofolder']) ? trim($_POST['mail_movetofolder']) : '');
-                       $mail_replyto      = defaults($_POST, 'mail_replyto', '');
-                       $mail_pubmail      = defaults($_POST, 'mail_pubmail', '');
-
-
-                       $mail_disabled = ((function_exists('imap_open') && (!Config::get('system', 'imap_disabled'))) ? 0 : 1);
-                       if (Config::get('system', 'dfrn_only')) {
-                               $mail_disabled = 1;
-                       }
-
-                       if (!$mail_disabled) {
+                       $mail_server       =                 $_POST['mail_server']       ?? '';
+                       $mail_port         =                 $_POST['mail_port']         ?? '';
+                       $mail_ssl          = strtolower(trim($_POST['mail_ssl']          ?? ''));
+                       $mail_user         =                 $_POST['mail_user']         ?? '';
+                       $mail_pass         =            trim($_POST['mail_pass']         ?? '');
+                       $mail_action       =            trim($_POST['mail_action']       ?? '');
+                       $mail_movetofolder =            trim($_POST['mail_movetofolder'] ?? '');
+                       $mail_replyto      =                 $_POST['mail_replyto']      ?? '';
+                       $mail_pubmail      =                 $_POST['mail_pubmail']      ?? '';
+
+                       if (
+                               !Config::get('system', 'dfrn_only')
+                               && function_exists('imap_open')
+                               && !Config::get('system', 'imap_disabled')
+                       ) {
                                $failed = false;
                                $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1",
                                        intval(local_user())
index f6f2a9a29ebe99a614e07100ec494c8012a03588..3f091f298ac5ac4e159964cd73abe513c0e77225 100644 (file)
@@ -22,11 +22,11 @@ function tagrm_post(App $a)
        }
 
        $tags = [];
-       foreach (defaults($_POST, 'tag', []) as $tag) {
+       foreach ($_POST['tag'] ?? [] as $tag) {
                $tags[] = hex2bin(Strings::escapeTags(trim($tag)));
        }
 
-       $item_id = defaults($_POST,'item', 0);
+       $item_id = $_POST['item'] ?? 0;
        update_tags($item_id, $tags);
        info(L10n::t('Tag(s) removed') . EOL);
 
index a66c88aefd2d9dcfe993c4d81cef222f11efcbd7..7afd82c98a95b25f3e5e8a9ed3849e3706ec5ee1 100644 (file)
@@ -25,7 +25,7 @@ function unfollow_post(App $a)
        }
 
        $uid = local_user();
-       $url = Strings::escapeTags(trim(defaults($_REQUEST, 'url', '')));
+       $url = Strings::escapeTags(trim($_REQUEST['url'] ?? ''));
 
        $condition = ["`uid` = ? AND (`rel` = ? OR `rel` = ?) AND (`nurl` = ? OR `alias` = ? OR `alias` = ?)",
                $uid, Contact::SHARING, Contact::FRIEND, Strings::normaliseLink($url),
index 48027a603e9450711b8b89d1dea4303740c1f58c..4174c7f48a2fed181d9fac8ed88560f4a319ca0f 100644 (file)
@@ -51,9 +51,9 @@ function videos_init(App $a)
                $vcard_widget = Renderer::replaceMacros($tpl, [
                        '$name' => $profile['name'],
                        '$photo' => $profile['photo'],
-                       '$addr' => defaults($profile, 'addr', ''),
+                       '$addr' => $profile['addr'] ?? '',
                        '$account_type' => $account_type,
-                       '$pdesc' => defaults($profile, 'pdesc', ''),
+                       '$pdesc' => $profile['pdesc'] ?? '',
                ]);
 
                // If not there, create 'aside' empty
index 780230b8c700e479dfc28744b41877ddb9b88f40..ad8ca96675d638b5a3a80651843423af9339c9f3 100644 (file)
@@ -131,8 +131,8 @@ function wallmessage_content(App $a) {
                '$subject'    => L10n::t('Subject:'),
                '$recipname'  => $user['username'],
                '$nickname'   => $user['nickname'],
-               '$subjtxt'    => defaults($_REQUEST, 'subject', ''),
-               '$text'       => defaults($_REQUEST, 'body', ''),
+               '$subjtxt'    => $_REQUEST['subject'] ?? '',
+               '$text'       => $_REQUEST['body'] ?? '',
                '$readonly'   => '',
                '$yourmessage'=> L10n::t('Your message:'),
                '$parent'     => '',
index 1c83700609c180fbee48df3e78cad5bbc4948006..fb8ef0b2a4fbdb001cf22bcb4487dfbd04e0202d 100644 (file)
@@ -102,8 +102,8 @@ $HTTP["scheme"] == "https" {
         # Got the following 'Drupal Clean URL'after Mike suggested trying
         # something along those lines, from http://drupal.org/node/1414950
         url.rewrite-if-not-file = (
-            "^\/([^\?]*)\?(.*)$" => "/index.php?q=$1&$2",
-            "^\/(.*)$" => "/index.php?q=$1"
+            "^\/([^\?]*)\?(.*)$" => "/index.php?pagename=$1&$2",
+            "^\/(.*)$" => "/index.php?pagename=$1"
         )
     }
     else $HTTP["host"] !~ "(friendica.example.com|wordpress.example.com)" {
index 8047186a0762d3dec2cb89893331e0268a93fad2..e65309f6b0ab18dd38bc4ffebd0dcaa266139683 100644 (file)
@@ -70,7 +70,7 @@ class Arguments
 
        /**
         * Returns the value of a argv key
-        * @todo there are a lot of $a->argv usages in combination with defaults() which can be replaced with this method
+        * @todo there are a lot of $a->argv usages in combination with ?? which can be replaced with this method
         *
         * @param int   $position the position of the argument
         * @param mixed $default  the default value if not found
index ad5fd0d4ede3d360b2dd76f5f2c84d8cd95b2155..8d76a0d2d25d9dcaa519dc87a64f88907e2bc046 100644 (file)
@@ -338,12 +338,12 @@ class BaseURL
                /* Relative script path to the web server root
                 * Not all of those $_SERVER properties can be present, so we do by inverse priority order
                 */
-               $relative_script_path = '';
-               $relative_script_path = defaults($this->server, 'REDIRECT_URL', $relative_script_path);
-               $relative_script_path = defaults($this->server, 'REDIRECT_URI', $relative_script_path);
-               $relative_script_path = defaults($this->server, 'REDIRECT_SCRIPT_URL', $relative_script_path);
-               $relative_script_path = defaults($this->server, 'SCRIPT_URL', $relative_script_path);
-               $relative_script_path = defaults($this->server, 'REQUEST_URI', $relative_script_path);
+               $relative_script_path =
+                       ($this->server['REDIRECT_URL']        ?? '') ?:
+                       ($this->server['REDIRECT_URI']        ?? '') ?:
+                       ($this->server['REDIRECT_SCRIPT_URL'] ?? '') ?:
+                       ($this->server['SCRIPT_URL']          ?? '') ?:
+                        $this->server['REQUEST_URI']         ?? '';
 
                /* $relative_script_path gives /relative/path/to/friendica/module/parameter
                 * QUERY_STRING gives pagename=module/parameter
index fcec89bb4228b5f3faae23beb535b7b8aee91c79..996824f4a132b631dddfbad6a6296f6a5f5905fd 100644 (file)
@@ -60,7 +60,7 @@ class BaseObject
                        throw new InternalServerErrorException('DICE isn\'t initialized.');
                }
 
-               if (class_exists($name) || interface_exists($name   )) {
+               if (class_exists($name) || interface_exists($name)) {
                        return self::$dice->create($name);
                } else {
                        throw new InternalServerErrorException('Class \'' . $name . '\' isn\'t valid.');
index c9acb63f236c4c361479a22bdf8af3b918776c67..c12608d45d84bbfb10173486c59978230f943522 100644 (file)
@@ -39,7 +39,7 @@ class Pager
        {
                $this->setQueryString($queryString);
                $this->setItemsPerPage($itemsPerPage);
-               $this->setPage(defaults($_GET, 'page', 1));
+               $this->setPage(($_GET['page'] ?? 0) ?: 1);
        }
 
        /**
index c5f9986f1fb55c0137148473c042f5ea4422fab2..75f5d506e1b60339943db55943c7ae1afc71c96d 100644 (file)
@@ -38,7 +38,7 @@ class BBCode extends BaseObject
         *
         * @param string $body Message body
         * @return array
-        *                     'type' -> Message type ("link", "video", "photo")
+        *                     'type' -> Message type ('link', 'video', 'photo')
         *                     'text' -> Text before the shared message
         *                     'after' -> Text after the shared message
         *                     'image' -> Preview image of the message
@@ -56,19 +56,19 @@ class BBCode extends BaseObject
 
                if (preg_match_all("(\[class=(.*?)\](.*?)\[\/class\])ism", $body, $attached, PREG_SET_ORDER)) {
                        foreach ($attached as $data) {
-                               if (!in_array($data[1], ["type-link", "type-video", "type-photo"])) {
+                               if (!in_array($data[1], ['type-link', 'type-video', 'type-photo'])) {
                                        continue;
                                }
 
-                               $post["type"] = substr($data[1], 5);
+                               $post['type'] = substr($data[1], 5);
 
                                $pos = strpos($body, $data[0]);
                                if ($pos > 0) {
-                                       $post["text"] = trim(substr($body, 0, $pos));
-                                       $post["after"] = trim(substr($body, $pos + strlen($data[0])));
+                                       $post['text'] = trim(substr($body, 0, $pos));
+                                       $post['after'] = trim(substr($body, $pos + strlen($data[0])));
                                } else {
-                                       $post["text"] = trim(str_replace($data[0], "", $body));
-                                       $post["after"] = '';
+                                       $post['text'] = trim(str_replace($data[0], '', $body));
+                                       $post['after'] = '';
                                }
 
                                $attacheddata = $data[2];
@@ -79,25 +79,25 @@ class BBCode extends BaseObject
 
                                        if ($picturedata) {
                                                if (($picturedata[0] >= 500) && ($picturedata[0] >= $picturedata[1])) {
-                                                       $post["image"] = $matches[1];
+                                                       $post['image'] = $matches[1];
                                                } else {
-                                                       $post["preview"] = $matches[1];
+                                                       $post['preview'] = $matches[1];
                                                }
                                        }
                                }
 
                                if (preg_match("/\[bookmark\=(.*?)\](.*?)\[\/bookmark\]/ism", $attacheddata, $matches)) {
-                                       $post["url"] = $matches[1];
-                                       $post["title"] = $matches[2];
+                                       $post['url'] = $matches[1];
+                                       $post['title'] = $matches[2];
                                }
-                               if (!empty($post["url"]) && (in_array($post["type"], ["link", "video"]))
+                               if (!empty($post['url']) && (in_array($post['type'], ['link', 'video']))
                                        && preg_match("/\[url\=(.*?)\](.*?)\[\/url\]/ism", $attacheddata, $matches)) {
-                                       $post["url"] = $matches[1];
+                                       $post['url'] = $matches[1];
                                }
 
                                // Search for description
                                if (preg_match("/\[quote\](.*?)\[\/quote\]/ism", $attacheddata, $matches)) {
-                                       $post["description"] = $matches[1];
+                                       $post['description'] = $matches[1];
                                }
                        }
                }
@@ -109,7 +109,7 @@ class BBCode extends BaseObject
         *
         * @param string $body Message body
         * @return array
-        *                     'type' -> Message type ("link", "video", "photo")
+        *                     'type' -> Message type ('link', 'video', 'photo')
         *                     'text' -> Text before the shared message
         *                     'after' -> Text after the shared message
         *                     'image' -> Preview image of the message
@@ -136,9 +136,9 @@ class BBCode extends BaseObject
 
                $attributes = $match[2];
 
-               $data["text"] = trim($match[1]);
+               $data['text'] = trim($match[1]);
 
-               $type = "";
+               $type = '';
                preg_match("/type='(.*?)'/ism", $attributes, $matches);
                if (!empty($matches[1])) {
                        $type = strtolower($matches[1]);
@@ -149,19 +149,19 @@ class BBCode extends BaseObject
                        $type = strtolower($matches[1]);
                }
 
-               if ($type == "") {
+               if ($type == '') {
                        return [];
                }
 
-               if (!in_array($type, ["link", "audio", "photo", "video"])) {
+               if (!in_array($type, ['link', 'audio', 'photo', 'video'])) {
                        return [];
                }
 
-               if ($type != "") {
-                       $data["type"] = $type;
+               if ($type != '') {
+                       $data['type'] = $type;
                }
 
-               $url = "";
+               $url = '';
                preg_match("/url='(.*?)'/ism", $attributes, $matches);
                if (!empty($matches[1])) {
                        $url = $matches[1];
@@ -172,11 +172,11 @@ class BBCode extends BaseObject
                        $url = $matches[1];
                }
 
-               if ($url != "") {
-                       $data["url"] = html_entity_decode($url, ENT_QUOTES, 'UTF-8');
+               if ($url != '') {
+                       $data['url'] = html_entity_decode($url, ENT_QUOTES, 'UTF-8');
                }
 
-               $title = "";
+               $title = '';
                preg_match("/title='(.*?)'/ism", $attributes, $matches);
                if (!empty($matches[1])) {
                        $title = $matches[1];
@@ -187,14 +187,14 @@ class BBCode extends BaseObject
                        $title = $matches[1];
                }
 
-               if ($title != "") {
+               if ($title != '') {
                        $title = self::convert(html_entity_decode($title, ENT_QUOTES, 'UTF-8'), false, true);
                        $title = html_entity_decode($title, ENT_QUOTES, 'UTF-8');
-                       $title = str_replace(["[", "]"], ["&#91;", "&#93;"], $title);
-                       $data["title"] = $title;
+                       $title = str_replace(['[', ']'], ['&#91;', '&#93;'], $title);
+                       $data['title'] = $title;
                }
 
-               $image = "";
+               $image = '';
                preg_match("/image='(.*?)'/ism", $attributes, $matches);
                if (!empty($matches[1])) {
                        $image = $matches[1];
@@ -205,11 +205,11 @@ class BBCode extends BaseObject
                        $image = $matches[1];
                }
 
-               if ($image != "") {
-                       $data["image"] = html_entity_decode($image, ENT_QUOTES, 'UTF-8');
+               if ($image != '') {
+                       $data['image'] = html_entity_decode($image, ENT_QUOTES, 'UTF-8');
                }
 
-               $preview = "";
+               $preview = '';
                preg_match("/preview='(.*?)'/ism", $attributes, $matches);
                if (!empty($matches[1])) {
                        $preview = $matches[1];
@@ -220,13 +220,13 @@ class BBCode extends BaseObject
                        $preview = $matches[1];
                }
 
-               if ($preview != "") {
-                       $data["preview"] = html_entity_decode($preview, ENT_QUOTES, 'UTF-8');
+               if ($preview != '') {
+                       $data['preview'] = html_entity_decode($preview, ENT_QUOTES, 'UTF-8');
                }
 
-               $data["description"] = trim($match[3]);
+               $data['description'] = trim($match[3]);
 
-               $data["after"] = trim($match[4]);
+               $data['after'] = trim($match[4]);
 
                return $data;
        }
@@ -244,7 +244,7 @@ class BBCode extends BaseObject
                */
 
                $has_title = !empty($item['title']);
-               $plink = defaults($item, 'plink', '');
+               $plink = $item['plink'] ?? '';
                $post = self::getAttachmentData($body);
 
                // Get all linked images with alternative image description
@@ -268,11 +268,11 @@ class BBCode extends BaseObject
                }
 
                // if nothing is found, it maybe having an image.
-               if (!isset($post["type"])) {
+               if (!isset($post['type'])) {
                        // Simplify image codes
                        $body = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '[img]$3[/img]', $body);
                        $body = preg_replace("/\[img\=(.*?)\](.*?)\[\/img\]/ism", '[img]$1[/img]', $body);
-                       $post["text"] = $body;
+                       $post['text'] = $body;
 
                        if (preg_match_all("(\[url=(.*?)\]\s*\[img\](.*?)\[\/img\]\s*\[\/url\])ism", $body, $pictures, PREG_SET_ORDER)) {
                                if ((count($pictures) == 1) && !$has_title) {
@@ -288,75 +288,75 @@ class BBCode extends BaseObject
                                        // Workaround:
                                        // Sometimes photo posts to the own album are not detected at the start.
                                        // So we seem to cannot use the cache for these cases. That's strange.
-                                       if (($data["type"] != "photo") && strstr($pictures[0][1], "/photos/")) {
+                                       if (($data['type'] != 'photo') && strstr($pictures[0][1], "/photos/")) {
                                                $data = ParseUrl::getSiteinfo($pictures[0][1], true);
                                        }
 
-                                       if ($data["type"] == "photo") {
-                                               $post["type"] = "photo";
-                                               if (isset($data["images"][0])) {
-                                                       $post["image"] = $data["images"][0]["src"];
-                                                       $post["url"] = $data["url"];
+                                       if ($data['type'] == 'photo') {
+                                               $post['type'] = 'photo';
+                                               if (isset($data['images'][0])) {
+                                                       $post['image'] = $data['images'][0]['src'];
+                                                       $post['url'] = $data['url'];
                                                } else {
-                                                       $post["image"] = $data["url"];
+                                                       $post['image'] = $data['url'];
                                                }
 
-                                               $post["preview"] = $pictures[0][2];
-                                               $post["text"] = trim(str_replace($pictures[0][0], "", $body));
+                                               $post['preview'] = $pictures[0][2];
+                                               $post['text'] = trim(str_replace($pictures[0][0], '', $body));
                                        } else {
                                                $imgdata = Image::getInfoFromURL($pictures[0][1]);
-                                               if ($imgdata && substr($imgdata["mime"], 0, 6) == "image/") {
-                                                       $post["type"] = "photo";
-                                                       $post["image"] = $pictures[0][1];
-                                                       $post["preview"] = $pictures[0][2];
-                                                       $post["text"] = trim(str_replace($pictures[0][0], "", $body));
+                                               if ($imgdata && substr($imgdata['mime'], 0, 6) == 'image/') {
+                                                       $post['type'] = 'photo';
+                                                       $post['image'] = $pictures[0][1];
+                                                       $post['preview'] = $pictures[0][2];
+                                                       $post['text'] = trim(str_replace($pictures[0][0], '', $body));
                                                }
                                        }
                                } elseif (count($pictures) > 0) {
-                                       $post["type"] = "link";
-                                       $post["url"] = $plink;
-                                       $post["image"] = $pictures[0][2];
-                                       $post["text"] = $body;
+                                       $post['type'] = 'link';
+                                       $post['url'] = $plink;
+                                       $post['image'] = $pictures[0][2];
+                                       $post['text'] = $body;
 
                                        foreach ($pictures as $picture) {
-                                               $post["text"] = trim(str_replace($picture[0], "", $post["text"]));
+                                               $post['text'] = trim(str_replace($picture[0], '', $post['text']));
                                        }
                                }
                        } elseif (preg_match_all("(\[img\](.*?)\[\/img\])ism", $body, $pictures, PREG_SET_ORDER)) {
                                if ((count($pictures) == 1) && !$has_title) {
-                                       $post["type"] = "photo";
-                                       $post["image"] = $pictures[0][1];
-                                       $post["text"] = str_replace($pictures[0][0], "", $body);
+                                       $post['type'] = 'photo';
+                                       $post['image'] = $pictures[0][1];
+                                       $post['text'] = str_replace($pictures[0][0], '', $body);
                                } elseif (count($pictures) > 0) {
-                                       $post["type"] = "link";
-                                       $post["url"] = $plink;
-                                       $post["image"] = $pictures[0][1];
-                                       $post["text"] = $body;
+                                       $post['type'] = 'link';
+                                       $post['url'] = $plink;
+                                       $post['image'] = $pictures[0][1];
+                                       $post['text'] = $body;
 
                                        foreach ($pictures as $picture) {
-                                               $post["text"] = trim(str_replace($picture[0], "", $post["text"]));
+                                               $post['text'] = trim(str_replace($picture[0], '', $post['text']));
                                        }
                                }
                        }
 
                        // Test for the external links
-                       preg_match_all("(\[url\](.*?)\[\/url\])ism", $post["text"], $links1, PREG_SET_ORDER);
-                       preg_match_all("(\[url\=(.*?)\].*?\[\/url\])ism", $post["text"], $links2, PREG_SET_ORDER);
+                       preg_match_all("(\[url\](.*?)\[\/url\])ism", $post['text'], $links1, PREG_SET_ORDER);
+                       preg_match_all("(\[url\=(.*?)\].*?\[\/url\])ism", $post['text'], $links2, PREG_SET_ORDER);
 
                        $links = array_merge($links1, $links2);
 
                        // If there is only a single one, then use it.
                        // This should cover link posts via API.
-                       if ((count($links) == 1) && !isset($post["preview"]) && !$has_title) {
-                               $post["type"] = "link";
-                               $post["url"] = $links[0][1];
+                       if ((count($links) == 1) && !isset($post['preview']) && !$has_title) {
+                               $post['type'] = 'link';
+                               $post['url'] = $links[0][1];
                        }
 
                        // Now count the number of external media links
-                       preg_match_all("(\[vimeo\](.*?)\[\/vimeo\])ism", $post["text"], $links1, PREG_SET_ORDER);
-                       preg_match_all("(\[youtube\\](.*?)\[\/youtube\\])ism", $post["text"], $links2, PREG_SET_ORDER);
-                       preg_match_all("(\[video\\](.*?)\[\/video\\])ism", $post["text"], $links3, PREG_SET_ORDER);
-                       preg_match_all("(\[audio\\](.*?)\[\/audio\\])ism", $post["text"], $links4, PREG_SET_ORDER);
+                       preg_match_all("(\[vimeo\](.*?)\[\/vimeo\])ism", $post['text'], $links1, PREG_SET_ORDER);
+                       preg_match_all("(\[youtube\\](.*?)\[\/youtube\\])ism", $post['text'], $links2, PREG_SET_ORDER);
+                       preg_match_all("(\[video\\](.*?)\[\/video\\])ism", $post['text'], $links3, PREG_SET_ORDER);
+                       preg_match_all("(\[audio\\](.*?)\[\/audio\\])ism", $post['text'], $links4, PREG_SET_ORDER);
 
                        // Add them to the other external links
                        $links = array_merge($links, $links1, $links2, $links3, $links4);
@@ -364,19 +364,19 @@ class BBCode extends BaseObject
                        // Are there more than one?
                        if (count($links) > 1) {
                                // The post will be the type "text", which means a blog post
-                               unset($post["type"]);
-                               $post["url"] = $plink;
+                               unset($post['type']);
+                               $post['url'] = $plink;
                        }
 
-                       if (!isset($post["type"])) {
-                               $post["type"] = "text";
-                               $post["text"] = trim($body);
+                       if (!isset($post['type'])) {
+                               $post['type'] = "text";
+                               $post['text'] = trim($body);
                        }
-               } elseif (isset($post["url"]) && ($post["type"] == "video")) {
-                       $data = ParseUrl::getSiteinfoCached($post["url"], true);
+               } elseif (isset($post['url']) && ($post['type'] == 'video')) {
+                       $data = ParseUrl::getSiteinfoCached($post['url'], true);
 
-                       if (isset($data["images"][0])) {
-                               $post["image"] = $data["images"][0]["src"];
+                       if (isset($data['images'][0])) {
+                               $post['image'] = $data['images'][0]['src'];
                        }
                }
 
@@ -581,27 +581,27 @@ class BBCode extends BaseObject
        private static function convertAttachment($return, $simplehtml = false, $tryoembed = true)
        {
                $data = self::getAttachmentData($return);
-               if (empty($data) || empty($data["url"])) {
+               if (empty($data) || empty($data['url'])) {
                        return $return;
                }
 
-               if (isset($data["title"])) {
-                       $data["title"] = strip_tags($data["title"]);
-                       $data["title"] = str_replace(["http://", "https://"], "", $data["title"]);
+               if (isset($data['title'])) {
+                       $data['title'] = strip_tags($data['title']);
+                       $data['title'] = str_replace(['http://', 'https://'], '', $data['title']);
                } else {
-                       $data["title"] = null;
+                       $data['title'] = null;
                }
 
-               if (((strpos($data["text"], "[img=") !== false) || (strpos($data["text"], "[img]") !== false) || Config::get('system', 'always_show_preview')) && !empty($data["image"])) {
-                       $data["preview"] = $data["image"];
-                       $data["image"] = "";
+               if (((strpos($data['text'], "[img=") !== false) || (strpos($data['text'], "[img]") !== false) || Config::get('system', 'always_show_preview')) && !empty($data['image'])) {
+                       $data['preview'] = $data['image'];
+                       $data['image'] = '';
                }
 
                $return = '';
                if (in_array($simplehtml, [7, 9])) {
-                       $return = self::convertUrlForOStatus($data["url"]);
+                       $return = self::convertUrlForActivityPub($data['url']);
                } elseif (($simplehtml != 4) && ($simplehtml != 0)) {
-                       $return = sprintf('<a href="%s" target="_blank">%s</a><br>', $data["url"], $data["title"]);
+                       $return = sprintf('<a href="%s" target="_blank">%s</a><br>', $data['url'], $data['title']);
                } else {
                        try {
                                if ($tryoembed && OEmbed::isAllowedURL($data['url'])) {
@@ -610,28 +610,28 @@ class BBCode extends BaseObject
                                        throw new Exception('OEmbed is disabled for this attachment.');
                                }
                        } catch (Exception $e) {
-                               $data["title"] = defaults($data, 'title', $data['url']);
+                               $data['title'] = ($data['title'] ?? '') ?: $data['url'];
 
                                if ($simplehtml != 4) {
-                                       $return = sprintf('<div class="type-%s">', $data["type"]);
+                                       $return = sprintf('<div class="type-%s">', $data['type']);
                                }
 
                                if (!empty($data['title']) && !empty($data['url'])) {
-                                       if (!empty($data["image"]) && empty($data["text"]) && ($data["type"] == "photo")) {
-                                               $return .= sprintf('<a href="%s" target="_blank"><img src="%s" alt="" title="%s" class="attachment-image" /></a>', $data["url"], self::proxyUrl($data["image"], $simplehtml), $data["title"]);
+                                       if (!empty($data['image']) && empty($data['text']) && ($data['type'] == 'photo')) {
+                                               $return .= sprintf('<a href="%s" target="_blank"><img src="%s" alt="" title="%s" class="attachment-image" /></a>', $data['url'], self::proxyUrl($data['image'], $simplehtml), $data['title']);
                                        } else {
-                                               if (!empty($data["image"])) {
-                                                       $return .= sprintf('<a href="%s" target="_blank"><img src="%s" alt="" title="%s" class="attachment-image" /></a><br />', $data["url"], self::proxyUrl($data["image"], $simplehtml), $data["title"]);
-                                               } elseif (!empty($data["preview"])) {
-                                                       $return .= sprintf('<a href="%s" target="_blank"><img src="%s" alt="" title="%s" class="attachment-preview" /></a><br />', $data["url"], self::proxyUrl($data["preview"], $simplehtml), $data["title"]);
+                                               if (!empty($data['image'])) {
+                                                       $return .= sprintf('<a href="%s" target="_blank"><img src="%s" alt="" title="%s" class="attachment-image" /></a><br />', $data['url'], self::proxyUrl($data['image'], $simplehtml), $data['title']);
+                                               } elseif (!empty($data['preview'])) {
+                                                       $return .= sprintf('<a href="%s" target="_blank"><img src="%s" alt="" title="%s" class="attachment-preview" /></a><br />', $data['url'], self::proxyUrl($data['preview'], $simplehtml), $data['title']);
                                                }
                                                $return .= sprintf('<h4><a href="%s">%s</a></h4>', $data['url'], $data['title']);
                                        }
                                }
 
-                               if (!empty($data["description"]) && $data["description"] != $data["title"]) {
+                               if (!empty($data['description']) && $data['description'] != $data['title']) {
                                        // Sanitize the HTML by converting it to BBCode
-                                       $bbcode = HTML::toBBCode($data["description"]);
+                                       $bbcode = HTML::toBBCode($data['description']);
                                        $return .= sprintf('<blockquote>%s</blockquote>', trim(self::convert($bbcode)));
                                }
 
@@ -645,7 +645,7 @@ class BBCode extends BaseObject
                        }
                }
 
-               return trim(defaults($data, 'text', '') . ' ' . $return . ' ' . defaults($data, 'after', ''));
+               return trim(($data['text'] ?? '') . ' ' . $return . ' ' . ($data['after'] ?? ''));
        }
 
        public static function removeShareInformation($Text, $plaintext = false, $nolink = false)
@@ -655,36 +655,36 @@ class BBCode extends BaseObject
                if (!$data) {
                        return $Text;
                } elseif ($nolink) {
-                       return $data["text"] . defaults($data, 'after', '');
+                       return $data['text'] . ($data['after'] ?? '');
                }
 
-               $title = htmlentities(defaults($data, 'title', ''), ENT_QUOTES, 'UTF-8', false);
-               $text = htmlentities($data["text"], ENT_QUOTES, 'UTF-8', false);
-               if ($plaintext || (($title != "") && strstr($text, $title))) {
-                       $data["title"] = $data["url"];
-               } elseif (($text != "") && strstr($title, $text)) {
-                       $data["text"] = $data["title"];
-                       $data["title"] = $data["url"];
+               $title = htmlentities($data['title'] ?? '', ENT_QUOTES, 'UTF-8', false);
+               $text = htmlentities($data['text'], ENT_QUOTES, 'UTF-8', false);
+               if ($plaintext || (($title != '') && strstr($text, $title))) {
+                       $data['title'] = $data['url'];
+               } elseif (($text != '') && strstr($title, $text)) {
+                       $data['text'] = $data['title'];
+                       $data['title'] = $data['url'];
                }
 
-               if (empty($data["text"]) && !empty($data["title"]) && empty($data["url"])) {
-                       return $data["title"] . $data["after"];
+               if (empty($data['text']) && !empty($data['title']) && empty($data['url'])) {
+                       return $data['title'] . $data['after'];
                }
 
                // If the link already is included in the post, don't add it again
-               if (!empty($data["url"]) && strpos($data["text"], $data["url"])) {
-                       return $data["text"] . $data["after"];
+               if (!empty($data['url']) && strpos($data['text'], $data['url'])) {
+                       return $data['text'] . $data['after'];
                }
 
-               $text = $data["text"];
+               $text = $data['text'];
 
-               if (!empty($data["url"]) && !empty($data["title"])) {
-                       $text .= "\n[url=" . $data["url"] . "]" . $data["title"] . "[/url]";
-               } elseif (!empty($data["url"])) {
-                       $text .= "\n[url]" . $data["url"] . "[/url]";
+               if (!empty($data['url']) && !empty($data['title'])) {
+                       $text .= "\n[url=" . $data['url'] . ']' . $data['title'] . '[/url]';
+               } elseif (!empty($data['url'])) {
+                       $text .= "\n[url]" . $data['url'] . '[/url]';
                }
 
-               return $text . "\n" . $data["after"];
+               return $text . "\n" . $data['after'];
        }
 
        /**
@@ -694,7 +694,7 @@ class BBCode extends BaseObject
         * @param array $match Array with the matching values
         * @return string reformatted link including HTML codes
         */
-       private static function convertUrlForOStatusCallback($match)
+       private static function convertUrlForActivityPubCallback($match)
        {
                $url = $match[1];
 
@@ -707,15 +707,26 @@ class BBCode extends BaseObject
                        return $match[0];
                }
 
-               return self::convertUrlForOStatus($url);
+               return self::convertUrlForActivityPub($url);
        }
 
        /**
-        * @brief Converts [url] BBCodes in a format that looks fine on OStatus systems.
+        * @brief Converts [url] BBCodes in a format that looks fine on ActivityPub systems.
         * @param string $url URL that is about to be reformatted
         * @return string reformatted link including HTML codes
         */
-       private static function convertUrlForOStatus($url)
+       private static function convertUrlForActivityPub($url)
+       {
+               $html = '<a href="%s" target="_blank">%s</a>';
+               return sprintf($html, $url, self::getStyledURL($url));
+       }
+
+       /**
+        * Converts an URL in a nicer format (without the scheme and possibly shortened)
+        * @param string $url URL that is about to be reformatted
+        * @return string reformatted link
+        */
+       private static function getStyledURL($url)
        {
                $parts = parse_url($url);
                $scheme = $parts['scheme'] . '://';
@@ -725,9 +736,7 @@ class BBCode extends BaseObject
                        $styled_url = substr($styled_url, 0, 30) . "…";
                }
 
-               $html = '<a href="%s" target="_blank">%s</a>';
-
-               return sprintf($html, $url, $styled_url);
+               return $styled_url;
        }
 
        /*
@@ -932,7 +941,7 @@ class BBCode extends BaseObject
                                $attributes = [];
                                foreach(['author', 'profile', 'avatar', 'link', 'posted'] as $field) {
                                        preg_match("/$field=(['\"])(.+?)\\1/ism", $attribute_string, $matches);
-                                       $attributes[$field] = html_entity_decode(defaults($matches, 2, ''), ENT_QUOTES, 'UTF-8');
+                                       $attributes[$field] = html_entity_decode($matches[2] ?? '', ENT_QUOTES, 'UTF-8');
                                }
 
                                // We only call this so that a previously unknown contact can be added.
@@ -951,11 +960,11 @@ class BBCode extends BaseObject
                                Contact::getIdForURL($attributes['profile'], 0, true, $default);
 
                                $author_contact = Contact::getDetailsByURL($attributes['profile']);
-                               $author_contact['addr'] = defaults($author_contact, 'addr' , Protocol::getAddrFromProfileUrl($attributes['profile']));
+                               $author_contact['addr'] = ($author_contact['addr']  ?? '') ?: Protocol::getAddrFromProfileUrl($attributes['profile']);
 
-                               $attributes['author']   = defaults($author_contact, 'name' , $attributes['author']);
-                               $attributes['avatar']   = defaults($author_contact, 'micro', $attributes['avatar']);
-                               $attributes['profile']  = defaults($author_contact, 'url'  , $attributes['profile']);
+                               $attributes['author']   = ($author_contact['name']  ?? '') ?: $attributes['author'];
+                               $attributes['avatar']   = ($author_contact['micro'] ?? '') ?: $attributes['avatar'];
+                               $attributes['profile']  = ($author_contact['url']   ?? '') ?: $attributes['profile'];
 
                                if ($attributes['avatar']) {
                                        $attributes['avatar'] = ProxyUtils::proxifyUrl($attributes['avatar'], false, ProxyUtils::SIZE_THUMB);
@@ -1073,10 +1082,10 @@ class BBCode extends BaseObject
 
                        $a->getProfiler()->saveTimestamp($stamp1, "network", System::callstack());
 
-                       if (substr($curl_info["content_type"], 0, 6) == "image/") {
-                               $text = "[url=" . $match[1] . "]" . $match[1] . "[/url]";
+                       if (substr($curl_info['content_type'], 0, 6) == 'image/') {
+                               $text = "[url=" . $match[1] . ']' . $match[1] . "[/url]";
                        } else {
-                               $text = "[url=" . $match[2] . "]" . $match[2] . "[/url]";
+                               $text = "[url=" . $match[2] . ']' . $match[2] . "[/url]";
 
                                // if its not a picture then look if its a page that contains a picture link
                                $body = Network::fetchUrl($match[1]);
@@ -1094,8 +1103,8 @@ class BBCode extends BaseObject
                                                }
                                        }
 
-                                       if (strtolower($attr["name"]) == "twitter:image") {
-                                               $text = "[url=" . $attr["content"] . "]" . $attr["content"] . "[/url]";
+                                       if (strtolower($attr['name']) == 'twitter:image') {
+                                               $text = '[url=' . $attr['content'] . ']' . $attr['content'] . '[/url]';
                                        }
                                }
                        }
@@ -1107,7 +1116,7 @@ class BBCode extends BaseObject
 
        private static function expandLinksCallback($match)
        {
-               if (($match[3] == "") || ($match[2] == $match[3]) || stristr($match[2], $match[3])) {
+               if (($match[3] == '') || ($match[2] == $match[3]) || stristr($match[2], $match[3])) {
                        return ($match[1] . "[url]" . $match[2] . "[/url]");
                } else {
                        return ($match[1] . $match[3] . " [url]" . $match[2] . "[/url]");
@@ -1122,9 +1131,9 @@ class BBCode extends BaseObject
                $own_photo_url = preg_quote(Strings::normaliseLink($a->getBaseURL()) . '/photos/');
                if (preg_match('|' . $own_photo_url . '.*?/image/|', Strings::normaliseLink($match[1]))) {
                        if (!empty($match[3])) {
-                               $text = "[img=" . str_replace('-1.', '-0.', $match[2]) . "]" . $match[3] . "[/img]";
+                               $text = '[img=' . str_replace('-1.', '-0.', $match[2]) . ']' . $match[3] . '[/img]';
                        } else {
-                               $text = "[img]" . str_replace('-1.', '-0.', $match[2]) . "[/img]";
+                               $text = '[img]' . str_replace('-1.', '-0.', $match[2]) . '[/img]';
                        }
                        return $text;
                }
@@ -1148,13 +1157,13 @@ class BBCode extends BaseObject
                $a->getProfiler()->saveTimestamp($stamp1, "network", System::callstack());
 
                // if its a link to a picture then embed this picture
-               if (substr($curl_info["content_type"], 0, 6) == "image/") {
-                       $text = "[img]" . $match[1] . "[/img]";
+               if (substr($curl_info['content_type'], 0, 6) == 'image/') {
+                       $text = '[img]' . $match[1] . '[/img]';
                } else {
                        if (!empty($match[3])) {
-                               $text = "[img=" . $match[2] . "]" . $match[3] . "[/img]";
+                               $text = '[img=' . $match[2] . ']' . $match[3] . '[/img]';
                        } else {
-                               $text = "[img]" . $match[2] . "[/img]";
+                               $text = '[img]' . $match[2] . '[/img]';
                        }
 
                        // if its not a picture then look if its a page that contains a picture link
@@ -1172,11 +1181,11 @@ class BBCode extends BaseObject
                                        }
                                }
 
-                               if (strtolower($attr["name"]) == "twitter:image") {
+                               if (strtolower($attr['name']) == "twitter:image") {
                                        if (!empty($match[3])) {
-                                               $text = "[img=" . $attr["content"] . "]" . $match[3] . "[/img]";
+                                               $text = "[img=" . $attr['content'] . "]" . $match[3] . "[/img]";
                                        } else {
-                                               $text = "[img]" . $attr["content"] . "[/img]";
+                                               $text = "[img]" . $attr['content'] . "[/img]";
                                        }
                                }
                        }
@@ -1232,7 +1241,7 @@ class BBCode extends BaseObject
                $try_oembed_callback = function ($match)
                {
                        $url = $match[1];
-                       $title = defaults($match, 2, null);
+                       $title = $match[2] ?? null;
 
                        try {
                                $return = OEmbed::getHTML($url, $title);
@@ -1333,7 +1342,7 @@ class BBCode extends BaseObject
                $text = str_replace($search, $replace, $text);
 
                // removing multiplicated newlines
-               if (Config::get("system", "remove_multiplicated_lines")) {
+               if (Config::get('system', 'remove_multiplicated_lines')) {
                        $search = ["\n\n\n", "\n ", " \n", "[/quote]\n\n", "\n[/quote]", "[/li]\n", "\n[li]", "\n[ul]", "[/ul]\n", "\n\n[share ", "[/attachment]\n",
                                        "\n[h1]", "[/h1]\n", "\n[h2]", "[/h2]\n", "\n[h3]", "[/h3]\n", "\n[h4]", "[/h4]\n", "\n[h5]", "[/h5]\n", "\n[h6]", "[/h6]\n"];
                        $replace = ["\n\n", "\n", "\n", "[/quote]\n", "[/quote]", "[/li]", "[li]", "[ul]", "[/ul]", "\n[share ", "[/attachment]",
@@ -1655,8 +1664,8 @@ class BBCode extends BaseObject
 
                if (!$for_plaintext) {
                        if (in_array($simple_html, [7, 9])) {
-                               $text = preg_replace_callback("/\[url\](.*?)\[\/url\]/ism", 'self::convertUrlForOStatusCallback', $text);
-                               $text = preg_replace_callback("/\[url\=(.*?)\](.*?)\[\/url\]/ism", 'self::convertUrlForOStatusCallback', $text);
+                               $text = preg_replace_callback("/\[url\](.*?)\[\/url\]/ism", 'self::convertUrlForActivityPubCallback', $text);
+                               $text = preg_replace_callback("/\[url\=(.*?)\](.*?)\[\/url\]/ism", 'self::convertUrlForActivityPubCallback', $text);
                        }
                } else {
                        $text = preg_replace("(\[url\](.*?)\[\/url\])ism", " $1 ", $text);
@@ -1832,7 +1841,7 @@ class BBCode extends BaseObject
                // Clean up the HTML by loading and saving the HTML with the DOM.
                // Bad structured html can break a whole page.
                // For performance reasons do it only with activated item cache or at export.
-               if (!$try_oembed || (get_itemcachepath() != "")) {
+               if (!$try_oembed || (get_itemcachepath() != '')) {
                        $doc = new DOMDocument();
                        $doc->preserveWhiteSpace = false;
 
@@ -1840,10 +1849,10 @@ class BBCode extends BaseObject
 
                        $doctype = '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">';
                        $encoding = '<?xml encoding="UTF-8">';
-                       @$doc->loadHTML($encoding.$doctype."<html><body>".$text."</body></html>");
+                       @$doc->loadHTML($encoding . $doctype . '<html><body>' . $text . '</body></html>');
                        $doc->encoding = 'UTF-8';
                        $text = $doc->saveHTML();
-                       $text = str_replace(["<html><body>", "</body></html>", $doctype, $encoding], ["", "", "", ""], $text);
+                       $text = str_replace(['<html><body>', '</body></html>', $doctype, $encoding], ['', '', '', ''], $text);
 
                        $text = str_replace('<br></li>', '</li>', $text);
 
@@ -1883,9 +1892,9 @@ class BBCode extends BaseObject
         * @param string $addon The addon for which the abstract is meant for
         * @return string The abstract
         */
-       public static function getAbstract($text, $addon = "")
+       public static function getAbstract($text, $addon = '')
        {
-               $abstract = "";
+               $abstract = '';
                $abstracts = [];
                $addon = strtolower($addon);
 
@@ -1899,7 +1908,7 @@ class BBCode extends BaseObject
                        $abstract = $abstracts[$addon];
                }
 
-               if ($abstract == "" && preg_match("/\[abstract\](.*?)\[\/abstract\]/ism", $text, $result)) {
+               if ($abstract == '' && preg_match("/\[abstract\](.*?)\[\/abstract\]/ism", $text, $result)) {
                        $abstract = $result[1];
                }
 
@@ -1975,7 +1984,7 @@ class BBCode extends BaseObject
 
                        // Add all tags that maybe were removed
                        if (preg_match_all("/#\[url\=([$url_search_string]*)\](.*?)\[\/url\]/ism", $original_text, $tags)) {
-                               $tagline = "";
+                               $tagline = '';
                                foreach ($tags[2] as $tag) {
                                        $tag = html_entity_decode($tag, ENT_QUOTES, 'UTF-8');
                                        if (!strpos(html_entity_decode($text, ENT_QUOTES, 'UTF-8'), '#' . $tag)) {
@@ -1993,7 +2002,7 @@ class BBCode extends BaseObject
 
                // If a link is followed by a quote then there should be a newline before it
                // Maybe we should make this newline at every time before a quote.
-               $text = str_replace(["</a><blockquote>"], ["</a><br><blockquote>"], $text);
+               $text = str_replace(['</a><blockquote>'], ['</a><br><blockquote>'], $text);
 
                $stamp1 = microtime(true);
 
index 549025dec00b4b26c9d6865a5cd133517b206a1d..390a97f0f575dce34a4a4bab3150a467dfede47a 100644 (file)
@@ -872,8 +872,8 @@ class HTML
                        $url = '';
                }
 
-               return Renderer::replaceMacros(Renderer::getMarkupTemplate(($textmode)?'micropro_txt.tpl':'micropro_img.tpl'), [
-                       '$click' => defaults($contact, 'click', ''),
+               return Renderer::replaceMacros(Renderer::getMarkupTemplate($textmode ? 'micropro_txt.tpl' : 'micropro_img.tpl'), [
+                       '$click' => $contact['click'] ?? '',
                        '$class' => $class,
                        '$url' => $url,
                        '$photo' => ProxyUtils::proxifyUrl($contact['thumb'], false, ProxyUtils::SIZE_THUMB),
index 829d267d8fd5ea9ee5668efade3a72cef6fdd936..c78ca21ebe6f4ad286c999c2b493186d0c4026cf 100644 (file)
@@ -57,7 +57,7 @@ class CalendarExport
 
                // $a->data is only available if the profile page is visited. If the visited page is not part
                // of the profile page it should be the personal /events page. So we can use $a->user.
-               $user = defaults($a->data['user'], 'nickname', $a->user['nickname']);
+               $user = ($a->data['user']['nickname'] ?? '') ?: $a->user['nickname'];
 
                $tpl = Renderer::getMarkupTemplate("widget/events.tpl");
                $return = Renderer::replaceMacros($tpl, [
index ef152f900846fbfcaa7061475eb37499a29e94cc..ec78dae9224cff7d789ee68a26e18c42e14e0d68 100644 (file)
@@ -61,7 +61,7 @@ class ContactBlock
 
                if ($total) {
                        // Only show followed for personal accounts, followers for pages
-                       if (defaults($profile, 'account-type', User::ACCOUNT_TYPE_PERSON) == User::ACCOUNT_TYPE_PERSON) {
+                       if ((($profile['account-type'] ?? '') ?: User::ACCOUNT_TYPE_PERSON) == User::ACCOUNT_TYPE_PERSON) {
                                $rel = [Contact::SHARING, Contact::FRIEND];
                        } else {
                                $rel = [Contact::FOLLOWER, Contact::FRIEND];
index fd9bfc6e22e574f23bdfe6f2623b0204d67d7110..df2f86e2b7a296288f41fd6814eba8fb146dd6ce 100644 (file)
@@ -41,12 +41,12 @@ class ACL extends BaseObject
 
                $networks = null;
 
-               $size = defaults($options, 'size', 4);
+               $size = ($options['size'] ?? 0) ?: 4;
                $mutual = !empty($options['mutual_friends']);
                $single = !empty($options['single']) && empty($options['multiple']);
-               $exclude = defaults($options, 'exclude', false);
+               $exclude = $options['exclude'] ?? false;
 
-               switch (defaults($options, 'networks', Protocol::PHANTOM)) {
+               switch (($options['networks'] ?? '') ?: Protocol::PHANTOM) {
                        case 'DFRN_ONLY':
                                $networks = [Protocol::DFRN];
                                break;
@@ -226,13 +226,13 @@ class ACL extends BaseObject
 
                $acl_regex = '/<([0-9]+)>/i';
 
-               preg_match_all($acl_regex, defaults($user, 'allow_cid', ''), $matches);
+               preg_match_all($acl_regex, $user['allow_cid'] ?? '', $matches);
                $allow_cid = $matches[1];
-               preg_match_all($acl_regex, defaults($user, 'allow_gid', ''), $matches);
+               preg_match_all($acl_regex, $user['allow_gid'] ?? '', $matches);
                $allow_gid = $matches[1];
-               preg_match_all($acl_regex, defaults($user, 'deny_cid', ''), $matches);
+               preg_match_all($acl_regex, $user['deny_cid'] ?? '', $matches);
                $deny_cid = $matches[1];
-               preg_match_all($acl_regex, defaults($user, 'deny_gid', ''), $matches);
+               preg_match_all($acl_regex, $user['deny_gid'] ?? '', $matches);
                $deny_gid = $matches[1];
 
                // Reformats the ACL data so that it is accepted by the JS frontend
@@ -301,10 +301,10 @@ class ACL extends BaseObject
                        '$showall' => L10n::t('Visible to everybody'),
                        '$show' => L10n::t('show'),
                        '$hide' => L10n::t('don\'t show'),
-                       '$allowcid' => json_encode(defaults($default_permissions, 'allow_cid', [])), // we need arrays for Javascript since we call .remove() and .push() on this values
-                       '$allowgid' => json_encode(defaults($default_permissions, 'allow_gid', [])),
-                       '$denycid' => json_encode(defaults($default_permissions, 'deny_cid', [])),
-                       '$denygid' => json_encode(defaults($default_permissions, 'deny_gid', [])),
+                       '$allowcid' => json_encode(($default_permissions['allow_cid'] ?? '') ?: []), // We need arrays for
+                       '$allowgid' => json_encode(($default_permissions['allow_gid'] ?? '') ?: []), // Javascript since we
+                       '$denycid'  => json_encode(($default_permissions['deny_cid']  ?? '') ?: []), // call .remove() and
+                       '$denygid'  => json_encode(($default_permissions['deny_gid']  ?? '') ?: []), // .push() on these values
                        '$networks' => $show_jotnets,
                        '$emailcc' => L10n::t('CC: email addresses'),
                        '$emtitle' => L10n::t('Example: bob@example.com, mary@example.com'),
index d67a67bba59ea09c3986b2546411a82716dd30c9..6d017664aa1ec5c5d37a49df3546672bbe206c12 100644 (file)
@@ -49,7 +49,7 @@ class Authentication extends BaseObject
                        $value = json_encode([
                                "uid" => $user["uid"],
                                "hash" => self::getCookieHashForUser($user),
-                               "ip" => defaults($_SERVER, 'REMOTE_ADDR', '0.0.0.0')
+                               "ip" => ($_SERVER['REMOTE_ADDR'] ?? '') ?: '0.0.0.0'
                        ]);
                } else {
                        $value = "";
index f904f369bb81455d888254cbff9e80bb4000ff56..c54fbb27e76a12466621bc7bd2155be1ba80c276 100644 (file)
@@ -7,8 +7,8 @@ use Friendica\Model;
 /**
  * This class is responsible for all system-wide configuration values in Friendica
  * There are two types of storage
- * - The Config-Files    (loaded into the FileCache @see Cache\ConfigCache )
- * - The Config-DB-Table (per Config-DB-model @see Model\Config\Config )
+ * - The Config-Files    (loaded into the FileCache @see Cache\ConfigCache)
+ * - The Config-DB-Table (per Config-DB-model @see Model\Config\Config)
  */
 abstract class Configuration
 {
@@ -59,7 +59,7 @@ abstract class Configuration
         *
         * Get a particular config value from the given category ($cat)
         * and the $key from a cached storage either from the $this->configAdapter
-        * (@see IConfigAdapter ) or from the $this->configCache (@see ConfigCache ).
+        * (@see IConfigAdapter) or from the $this->configCache (@see ConfigCache).
         *
         * @param string  $cat        The category of the configuration value
         * @param string  $key           The configuration key to query
@@ -89,7 +89,7 @@ abstract class Configuration
         * @brief Deletes the given key from the system configuration.
         *
         * Removes the configured value from the stored cache in $this->configCache
-        * (@see ConfigCache ) and removes it from the database (@see IConfigAdapter ).
+        * (@see ConfigCache) and removes it from the database (@see IConfigAdapter).
         *
         * @param string $cat The category of the configuration value
         * @param string $key    The configuration key to delete
index badec9dfca094d5a60057065a919fc07ab9bb89e..c54fc31220361c7d3e1e3696a5f972a1f2635f0e 100644 (file)
@@ -8,7 +8,7 @@ use Friendica\Model;
  * This class is responsible for the user-specific configuration values in Friendica
  * The values are set through the Config-DB-Table (per Config-DB-model @see Model\Config\PConfig)
  *
- * The configuration cache (@see Cache\PConfigCache ) is used for temporary caching of database calls. This will
+ * The configuration cache (@see Cache\PConfigCache) is used for temporary caching of database calls. This will
  * increase the performance.
  */
 abstract class PConfiguration
@@ -52,7 +52,7 @@ abstract class PConfiguration
         * @param string $cat The category of the configuration value
         *
         * @return void
-        * @see PConfigCache )
+        * @see PConfigCache
         *
         */
        abstract public function load(int $uid, string $cat = 'config');
@@ -63,7 +63,7 @@ abstract class PConfiguration
         *
         * Get a particular user's config value from the given category ($cat)
         * and the $key with the $uid from a cached storage either from the $this->configAdapter
-        * (@see IConfigAdapter ) or from the $this->configCache (@see PConfigCache ).
+        * (@see IConfigAdapter) or from the $this->configCache (@see PConfigCache).
         *
         * @param int     $uid           The user_id
         * @param string  $cat           The category of the configuration value
@@ -96,7 +96,7 @@ abstract class PConfiguration
         * Deletes the given key from the users's configuration.
         *
         * Removes the configured value from the stored cache in $this->configCache
-        * (@see ConfigCache ) and removes it from the database (@see IConfigAdapter )
+        * (@see ConfigCache) and removes it from the database (@see IConfigAdapter)
         *  with the given $uid.
         *
         * @param int $uid The user_id
index a6a5c24e013f060944beaa54f50e0612480e18a4..3c8367c91e2938532d0181449804c51bb411a43d 100644 (file)
@@ -137,7 +137,7 @@ class NotificationsManager extends BaseObject
         */
        public function getTabs()
        {
-               $selected = defaults(self::getApp()->argv, 1, '');
+               $selected = self::getApp()->argv[1] ?? '';
 
                $tabs = [
                        [
index fd5e73302512f0d8328690958941d2e356b8415c..d9d913050fe32a34f324e6900640eff1cc853ceb 100644 (file)
@@ -136,7 +136,7 @@ class Renderer extends BaseObject
         */
        public static function getTemplateEngine()
        {
-               $template_engine = defaults(self::$theme, 'template_engine', 'smarty3');
+               $template_engine = (self::$theme['template_engine'] ?? '') ?: 'smarty3';
 
                if (isset(self::$template_engines[$template_engine])) {
                        if (isset(self::$template_engine_instance[$template_engine])) {
index 5792fb1c9e57c3e525474e8389563c9561fd3154..9700c647225882fe308e4be6568babcbc6645778 100644 (file)
@@ -56,21 +56,20 @@ class Search extends BaseObject
                        }
 
                        // Ensure that we do have a contact entry
-                       Contact::getIdForURL(defaults($user_data, 'url', ''));
+                       Contact::getIdForURL($user_data['url'] ?? '');
 
-                       $contactDetails = Contact::getDetailsByURL(defaults($user_data, 'url', ''), local_user());
-                       $itemUrl        = defaults($contactDetails, 'addr', defaults($user_data, 'url', ''));
+                       $contactDetails = Contact::getDetailsByURL($user_data['url'] ?? '', local_user());
 
                        $result = new ContactResult(
-                               defaults($user_data, 'name', ''),
-                               defaults($user_data, 'addr', ''),
-                               $itemUrl,
-                               defaults($user_data, 'url', ''),
-                               defaults($user_data, 'photo', ''),
-                               defaults($user_data, 'network', ''),
-                               defaults($contactDetails, 'id', 0),
+                               $user_data['name'] ?? '',
+                               $user_data['addr'] ?? '',
+                               ($contactDetails['addr'] ?? '') ?: ($user_data['url'] ?? ''),
+                               $user_data['url'] ?? '',
+                               $user_data['photo'] ?? '',
+                               $user_data['network'] ?? '',
+                               $contactDetails['id'] ?? 0,
                                0,
-                               defaults($user_data, 'tags', '')
+                               $user_data['tags'] ?? ''
                        );
 
                        return new ResultList(1, 1, 1, [$result]);
@@ -117,27 +116,28 @@ class Search extends BaseObject
                $results = json_decode($resultJson, true);
 
                $resultList = new ResultList(
-                       defaults($results, 'page', 1),
-                       defaults($results, 'count', 0),
-                       defaults($results, 'itemsperpage', 30)
+                       ($results['page']         ?? 0) ?: 1,
+                        $results['count']        ?? 0,
+                       ($results['itemsperpage'] ?? 0) ?: 30
                );
 
-               $profiles = defaults($results, 'profiles', []);
+               $profiles = $results['profiles'] ?? [];
 
                foreach ($profiles as $profile) {
-                       $contactDetails = Contact::getDetailsByURL(defaults($profile, 'profile_url', ''), local_user());
-                       $itemUrl        = defaults($contactDetails, 'addr', defaults($profile, 'profile_url', ''));
+                       $profile_url = $profile['profile_url'] ?? '';
+                       $contactDetails = Contact::getDetailsByURL($profile_url, local_user());
 
                        $result = new ContactResult(
-                               defaults($profile, 'name', ''),
-                               defaults($profile, 'addr', ''),
-                               $itemUrl,
-                               defaults($profile, 'profile_url', ''),
-                               defaults($profile, 'photo', ''),
+                               $profile['name'] ?? '',
+                               $profile['addr'] ?? '',
+                               ($contactDetails['addr'] ?? '') ?: $profile_url,
+                               $profile_url,
+                               $profile['photo'] ?? '',
                                Protocol::DFRN,
-                               defaults($contactDetails, 'cid', 0),
+                               $contactDetails['cid'] ?? 0,
                                0,
-                               defaults($profile, 'tags', ''));
+                               $profile['tags'] ?? ''
+                       );
 
                        $resultList->addResult($result);
                }
index 3a0da3ab0825ad6261703780ea92dd23e2720434..aaead868a0377cdff2999e7788a63e05c628d292 100644 (file)
@@ -128,7 +128,7 @@ class Session
                        'page_flags'    => $user_record['page-flags'],
                        'my_url'        => $a->getBaseURL() . '/profile/' . $user_record['nickname'],
                        'my_address'    => $user_record['nickname'] . '@' . substr($a->getBaseURL(), strpos($a->getBaseURL(), '://') + 3),
-                       'addr'          => defaults($_SERVER, 'REMOTE_ADDR', '0.0.0.0')
+                       'addr'          => ($_SERVER['REMOTE_ADDR'] ?? '') ?: '0.0.0.0'
                ]);
 
                self::setVisitorsContacts();
index 8cd7d439531824b3b836e086a4cfd0d71db2ca05..832d9819c5c3ea8423b03dac17cbf8af4d7c08ae 100644 (file)
@@ -48,7 +48,7 @@ class StorageManager
        public static function getByName($name)
        {
                self::setup();
-               return defaults(self::$backends, $name, '');
+               return self::$backends[$name] ?? '';
        }
 
        /**
index 72b903e076d6e6e931ff41981848a386b3a7752f..218cab9507c4236329c6205f8363e730590bf2ee 100644 (file)
@@ -421,7 +421,7 @@ class DBStructure
                                }
 
                                if (isset($database[$name]["table_status"]["Comment"])) {
-                                       $structurecomment = defaults($structure, "comment", "");
+                                       $structurecomment = $structure["comment"] ?? '';
                                        if ($database[$name]["table_status"]["Comment"] != $structurecomment) {
                                                $sql2 = "COMMENT = '" . DBA::escape($structurecomment) . "'";
 
@@ -465,7 +465,7 @@ class DBStructure
                                // Compare the field structure field by field
                                foreach ($structure["fields"] AS $fieldname => $parameters) {
                                        // Compare the field definition
-                                       $field_definition = defaults($database[$name]["fields"], $fieldname, ['Collation' => '']);
+                                       $field_definition = ($database[$name]["fields"][$fieldname] ?? '') ?: ['Collation' => ''];
 
                                        // Define the default collation if not given
                                        if (!isset($parameters['Collation']) && !empty($field_definition['Collation'])) {
@@ -717,8 +717,8 @@ class DBStructure
         * @todo You cannot rename a primary key if "auto increment" is set
         *
         * @param string $table            Table name
-        * @param array  $columns          Columns Syntax for Rename: [ $old1 => [ $new1, $type1 ], $old2 => [ $new2, $type2 ], ... ] )
-        *                                 Syntax for Primary Key: [ $col1, $col2, ...] )
+        * @param array  $columns          Columns Syntax for Rename: [ $old1 => [ $new1, $type1 ], $old2 => [ $new2, $type2 ], ... ]
+        *                                 Syntax for Primary Key: [ $col1, $col2, ...]
         * @param int    $type             The type of renaming (Default is Column)
         *
         * @return boolean Was the renaming successful?
index 5ae99552235fae196192adf784edd6eb6873296a..3033bb90b1045e844e8146470f6af3663d6d443c 100644 (file)
@@ -1078,14 +1078,14 @@ class Contact extends BaseObject
                        $profile["micro"] = $profile["thumb"];
                }
 
-               if ((empty($profile["addr"]) || empty($profile["name"])) && (defaults($profile, "gid", 0) != 0)
+               if ((empty($profile["addr"]) || empty($profile["name"])) && !empty($profile["gid"])
                        && in_array($profile["network"], Protocol::FEDERATED)
                ) {
                        Worker::add(PRIORITY_LOW, "UpdateGContact", $url);
                }
 
                // Show contact details of Diaspora contacts only if connected
-               if ((defaults($profile, "cid", 0) == 0) && (defaults($profile, "network", "") == Protocol::DIASPORA)) {
+               if (empty($profile["cid"]) && ($profile["network"] ?? "") == Protocol::DIASPORA) {
                        $profile["location"] = "";
                        $profile["about"] = "";
                        $profile["gender"] = "";
@@ -1504,25 +1504,25 @@ class Contact extends BaseObject
                                'created'   => DateTimeFormat::utcNow(),
                                'url'       => $data['url'],
                                'nurl'      => Strings::normaliseLink($data['url']),
-                               'addr'      => defaults($data, 'addr', ''),
-                               'alias'     => defaults($data, 'alias', ''),
-                               'notify'    => defaults($data, 'notify', ''),
-                               'poll'      => defaults($data, 'poll', ''),
-                               'name'      => defaults($data, 'name', ''),
-                               'nick'      => defaults($data, 'nick', ''),
-                               'photo'     => defaults($data, 'photo', ''),
-                               'keywords'  => defaults($data, 'keywords', ''),
-                               'location'  => defaults($data, 'location', ''),
-                               'about'     => defaults($data, 'about', ''),
+                               'addr'      => $data['addr'] ?? '',
+                               'alias'     => $data['alias'] ?? '',
+                               'notify'    => $data['notify'] ?? '',
+                               'poll'      => $data['poll'] ?? '',
+                               'name'      => $data['name'] ?? '',
+                               'nick'      => $data['nick'] ?? '',
+                               'photo'     => $data['photo'] ?? '',
+                               'keywords'  => $data['keywords'] ?? '',
+                               'location'  => $data['location'] ?? '',
+                               'about'     => $data['about'] ?? '',
                                'network'   => $data['network'],
-                               'pubkey'    => defaults($data, 'pubkey', ''),
+                               'pubkey'    => $data['pubkey'] ?? '',
                                'rel'       => self::SHARING,
-                               'priority'  => defaults($data, 'priority', 0),
-                               'batch'     => defaults($data, 'batch', ''),
-                               'request'   => defaults($data, 'request', ''),
-                               'confirm'   => defaults($data, 'confirm', ''),
-                               'poco'      => defaults($data, 'poco', ''),
-                               'baseurl'   => defaults($data, 'baseurl', ''),
+                               'priority'  => $data['priority'] ?? 0,
+                               'batch'     => $data['batch'] ?? '',
+                               'request'   => $data['request'] ?? '',
+                               'confirm'   => $data['confirm'] ?? '',
+                               'poco'      => $data['poco'] ?? '',
+                               'baseurl'   => $data['baseurl'] ?? '',
                                'name-date' => DateTimeFormat::utcNow(),
                                'uri-date'  => DateTimeFormat::utcNow(),
                                'avatar-date' => DateTimeFormat::utcNow(),
@@ -1589,7 +1589,7 @@ class Contact extends BaseObject
                        $fields = ['addr', 'alias', 'name', 'nick', 'keywords', 'location', 'about', 'baseurl'];
 
                        foreach ($fields as $field) {
-                               $updated[$field] = defaults($data, $field, $contact[$field]);
+                               $updated[$field] = ($data[$field] ?? '') ?: $contact[$field];
                        }
 
                        if (($updated['addr'] != $contact['addr']) || (!empty($data['alias']) && ($data['alias'] != $contact['alias']))) {
@@ -2469,9 +2469,9 @@ class Contact extends BaseObject
                        return false;
                }
 
-               $url = defaults($datarray, 'author-link', $pub_contact['url']);
+               $url = ($datarray['author-link'] ?? '') ?: $pub_contact['url'];
                $name = $pub_contact['name'];
-               $photo = defaults($pub_contact, 'avatar', $pub_contact["photo"]);
+               $photo = ($pub_contact['avatar'] ?? '') ?: $pub_contact["photo"];
                $nick = $pub_contact['nick'];
                $network = $pub_contact['network'];
 
index 06d3ba536d0567544af65558a85dc74d14eb47f3..2ef58636a0c8f0c51eab0a13a8881d42603dcd40 100644 (file)
@@ -39,7 +39,7 @@ class Conversation
         */
        public static function insert(array $arr)
        {
-               if (in_array(defaults($arr, 'network', Protocol::PHANTOM),
+               if (in_array(($arr['network'] ?? '') ?: Protocol::PHANTOM,
                        [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS, Protocol::TWITTER]) && !empty($arr['uri'])) {
                        $conversation = ['item-uri' => $arr['uri'], 'received' => DateTimeFormat::utcNow()];
 
@@ -76,8 +76,13 @@ class Conversation
                                        unset($old_conv['source']);
                                }
                                // Update structure data all the time but the source only when its from a better protocol.
-                               if (empty($conversation['source']) || (!empty($old_conv['source']) &&
-                                       ($old_conv['protocol'] < defaults($conversation, 'protocol', self::PARCEL_UNKNOWN)))) {
+                               if (
+                                       empty($conversation['source'])
+                                       || (
+                                               !empty($old_conv['source'])
+                                               && ($old_conv['protocol'] < (($conversation['protocol'] ?? '') ?: self::PARCEL_UNKNOWN))
+                                       )
+                               ) {
                                        unset($conversation['protocol']);
                                        unset($conversation['source']);
                                }
index 42742f18e0684170db80adfb9969420d39baf6e8..91521808447ad472b8d3935474673685ff65d56c 100644 (file)
@@ -242,30 +242,30 @@ class Event extends BaseObject
        public static function store($arr)
        {
                $event = [];
-               $event['id']        = intval(defaults($arr, 'id'       , 0));
-               $event['uid']       = intval(defaults($arr, 'uid'      , 0));
-               $event['cid']       = intval(defaults($arr, 'cid'      , 0));
-               $event['guid']      =        defaults($arr, 'guid'     , System::createUUID());
-               $event['uri']       =        defaults($arr, 'uri'      , Item::newURI($event['uid'], $event['guid']));
-               $event['type']      =        defaults($arr, 'type'     , 'event');
-               $event['summary']   =        defaults($arr, 'summary'  , '');
-               $event['desc']      =        defaults($arr, 'desc'     , '');
-               $event['location']  =        defaults($arr, 'location' , '');
-               $event['allow_cid'] =        defaults($arr, 'allow_cid', '');
-               $event['allow_gid'] =        defaults($arr, 'allow_gid', '');
-               $event['deny_cid']  =        defaults($arr, 'deny_cid' , '');
-               $event['deny_gid']  =        defaults($arr, 'deny_gid' , '');
-               $event['adjust']    = intval(defaults($arr, 'adjust'   , 0));
-               $event['nofinish']  = intval(defaults($arr, 'nofinish' , !empty($event['start']) && empty($event['finish'])));
-
-               $event['created']   = DateTimeFormat::utc(defaults($arr, 'created'  , 'now'));
-               $event['edited']    = DateTimeFormat::utc(defaults($arr, 'edited'   , 'now'));
-               $event['start']     = DateTimeFormat::utc(defaults($arr, 'start'    , DBA::NULL_DATETIME));
-               $event['finish']    = DateTimeFormat::utc(defaults($arr, 'finish'   , DBA::NULL_DATETIME));
+               $event['id']        = intval($arr['id']        ?? 0);
+               $event['uid']       = intval($arr['uid']       ?? 0);
+               $event['cid']       = intval($arr['cid']       ?? 0);
+               $event['guid']      =       ($arr['guid']      ?? '') ?: System::createUUID();
+               $event['uri']       =       ($arr['uri']       ?? '') ?: Item::newURI($event['uid'], $event['guid']);
+               $event['type']      =       ($arr['type']      ?? '') ?: 'event';
+               $event['summary']   =        $arr['summary']   ?? '';
+               $event['desc']      =        $arr['desc']      ?? '';
+               $event['location']  =        $arr['location']  ?? '';
+               $event['allow_cid'] =        $arr['allow_cid'] ?? '';
+               $event['allow_gid'] =        $arr['allow_gid'] ?? '';
+               $event['deny_cid']  =        $arr['deny_cid']  ?? '';
+               $event['deny_gid']  =        $arr['deny_gid']  ?? '';
+               $event['adjust']    = intval($arr['adjust']    ?? 0);
+               $event['nofinish']  = intval(!empty($arr['nofinish'] || !empty($event['start']) && empty($event['finish'])));
+
+               $event['created']   = DateTimeFormat::utc(($arr['created'] ?? '') ?: 'now');
+               $event['edited']    = DateTimeFormat::utc(($arr['edited']  ?? '') ?: 'now');
+               $event['start']     = DateTimeFormat::utc(($arr['start']   ?? '') ?: DBA::NULL_DATETIME);
+               $event['finish']    = DateTimeFormat::utc(($arr['finish']  ?? '') ?: DBA::NULL_DATETIME);
                if ($event['finish'] < DBA::NULL_DATETIME) {
                        $event['finish'] = DBA::NULL_DATETIME;
                }
-               $private = intval(defaults($arr, 'private', 0));
+               $private = intval($arr['private'] ?? 0);
 
                $conditions = ['uid' => $event['uid']];
                if ($event['cid']) {
@@ -333,7 +333,7 @@ class Event extends BaseObject
                                $item_arr['uri']           = $event['uri'];
                                $item_arr['parent-uri']    = $event['uri'];
                                $item_arr['guid']          = $event['guid'];
-                               $item_arr['plink']         = defaults($arr, 'plink', '');
+                               $item_arr['plink']         = $arr['plink'] ?? '';
                                $item_arr['post-type']     = Item::PT_EVENT;
                                $item_arr['wall']          = $event['cid'] ? 0 : 1;
                                $item_arr['contact-id']    = $contact['id'];
index 4e316de73e4fda6b03110f592f3ddfed3d9d47d1..8c220a57aee45b1ba8b8620b98a61251d0cce2d1 100644 (file)
@@ -256,7 +256,7 @@ class GContact
                        WHERE `glink`.`cid` = %d AND `glink`.`uid` = %d AND
                        ((`gcontact`.`last_contact` >= `gcontact`.`last_failure`) OR
                        (`gcontact`.`updated` >= `gcontact`.`last_failure`))
-                       AND `gcontact`.`nurl` IN (select nurl from contact where uid = %d and self = 0 and blocked = 0 and hidden = 0 and id != %d ) ",
+                       AND `gcontact`.`nurl` IN (select nurl from contact where uid = %d and self = 0 and blocked = 0 and hidden = 0 and id != %d) ",
                        intval($cid),
                        intval($uid),
                        intval($uid),
@@ -282,7 +282,7 @@ class GContact
                        "SELECT count(*) as `total`
                        FROM `glink` INNER JOIN `gcontact` on `glink`.`gcid` = `gcontact`.`id`
                        where `glink`.`zcid` = %d
-                       and `gcontact`.`nurl` in (select nurl from contact where uid = %d and self = 0 and blocked = 0 and hidden = 0 ) ",
+                       and `gcontact`.`nurl` in (select nurl from contact where uid = %d and self = 0 and blocked = 0 and hidden = 0) ",
                        intval($zcid),
                        intval($uid)
                );
@@ -354,7 +354,7 @@ class GContact
                        "SELECT `gcontact`.*
                        FROM `glink` INNER JOIN `gcontact` on `glink`.`gcid` = `gcontact`.`id`
                        where `glink`.`zcid` = %d
-                       and `gcontact`.`nurl` in (select nurl from contact where uid = %d and self = 0 and blocked = 0 and hidden = 0 )
+                       and `gcontact`.`nurl` in (select nurl from contact where uid = %d and self = 0 and blocked = 0 and hidden = 0)
                        $sql_extra limit %d, %d",
                        intval($zcid),
                        intval($uid),
@@ -687,9 +687,9 @@ class GContact
                                $doprobing = (((time() - $last_contact) > (90 * 86400)) && ((time() - $last_failure) > (90 * 86400)));
                        }
                } else {
-                       $contact['location'] = defaults($contact, 'location', '');
-                       $contact['about'] = defaults($contact, 'about', '');
-                       $contact['generation'] = defaults($contact, 'generation', 0);
+                       $contact['location'] = $contact['location'] ?? '';
+                       $contact['about'] = $contact['about'] ?? '';
+                       $contact['generation'] = $contact['generation'] ?? 0;
 
                        q(
                                "INSERT INTO `gcontact` (`name`, `nick`, `addr` , `network`, `url`, `nurl`, `photo`, `created`, `updated`, `location`, `about`, `hide`, `generation`)
index b86b5506cecb52508101df9065f55e204b8ae2c2..d759a24dff88f44adf9a6404cfccce754490866b 100644 (file)
@@ -814,7 +814,7 @@ class GServer
 
                if (!empty($data['version'])) {
                        $serverdata['platform'] = 'mastodon';
-                       $serverdata['version'] = defaults($data, 'version', '');
+                       $serverdata['version'] = $data['version'] ?? '';
                        $serverdata['network'] = Protocol::ACTIVITYPUB;
                }
 
@@ -1010,7 +1010,7 @@ class GServer
                        $serverdata['info'] = trim($data['info']);
                }
 
-               $register_policy = defaults($data, 'register_policy', 'REGISTER_CLOSED');
+               $register_policy = ($data['register_policy'] ?? '') ?: 'REGISTER_CLOSED';
                switch ($register_policy) {
                        case 'REGISTER_OPEN':
                                $serverdata['register_policy'] = Register::OPEN;
@@ -1030,7 +1030,7 @@ class GServer
                                break;
                }
 
-               $serverdata['platform'] = defaults($data, 'platform', '');
+               $serverdata['platform'] = $data['platform'] ?? '';
 
                return $serverdata;
        }
index c73ea99b1bfb3d863207f1827253fb6ad59ec7c4..ff0f46676f0e6d560991a0551505c9fb0a9db599 100644 (file)
@@ -1313,11 +1313,11 @@ class Item extends BaseObject
                                $priority = $notify;
                        }
                } else {
-                       $item['network'] = trim(defaults($item, 'network', Protocol::PHANTOM));
+                       $item['network'] = trim(($item['network'] ?? '') ?: Protocol::PHANTOM);
                }
 
                $item['guid'] = self::guid($item, $notify);
-               $item['uri'] = Strings::escapeTags(trim(defaults($item, 'uri', self::newURI($item['uid'], $item['guid']))));
+               $item['uri'] = Strings::escapeTags(trim(($item['uri'] ?? '') ?: self::newURI($item['uid'], $item['guid'])));
 
                // Store URI data
                $item['uri-id'] = ItemURI::insert(['uri' => $item['uri'], 'guid' => $item['guid']]);
@@ -1419,47 +1419,47 @@ class Item extends BaseObject
                        }
                }
 
-               $item['wall']          = intval(defaults($item, 'wall', 0));
-               $item['extid']         = trim(defaults($item, 'extid', ''));
-               $item['author-name']   = trim(defaults($item, 'author-name', ''));
-               $item['author-link']   = trim(defaults($item, 'author-link', ''));
-               $item['author-avatar'] = trim(defaults($item, 'author-avatar', ''));
-               $item['owner-name']    = trim(defaults($item, 'owner-name', ''));
-               $item['owner-link']    = trim(defaults($item, 'owner-link', ''));
-               $item['owner-avatar']  = trim(defaults($item, 'owner-avatar', ''));
+               $item['wall']          = intval($item['wall'] ?? 0);
+               $item['extid']         = trim($item['extid'] ?? '');
+               $item['author-name']   = trim($item['author-name'] ?? '');
+               $item['author-link']   = trim($item['author-link'] ?? '');
+               $item['author-avatar'] = trim($item['author-avatar'] ?? '');
+               $item['owner-name']    = trim($item['owner-name'] ?? '');
+               $item['owner-link']    = trim($item['owner-link'] ?? '');
+               $item['owner-avatar']  = trim($item['owner-avatar'] ?? '');
                $item['received']      = (isset($item['received'])  ? DateTimeFormat::utc($item['received'])  : DateTimeFormat::utcNow());
                $item['created']       = (isset($item['created'])   ? DateTimeFormat::utc($item['created'])   : $item['received']);
                $item['edited']        = (isset($item['edited'])    ? DateTimeFormat::utc($item['edited'])    : $item['created']);
                $item['changed']       = (isset($item['changed'])   ? DateTimeFormat::utc($item['changed'])   : $item['created']);
                $item['commented']     = (isset($item['commented']) ? DateTimeFormat::utc($item['commented']) : $item['created']);
-               $item['title']         = trim(defaults($item, 'title', ''));
-               $item['location']      = trim(defaults($item, 'location', ''));
-               $item['coord']         = trim(defaults($item, 'coord', ''));
+               $item['title']         = trim($item['title'] ?? '');
+               $item['location']      = trim($item['location'] ?? '');
+               $item['coord']         = trim($item['coord'] ?? '');
                $item['visible']       = (isset($item['visible']) ? intval($item['visible']) : 1);
                $item['deleted']       = 0;
-               $item['parent-uri']    = trim(defaults($item, 'parent-uri', $item['uri']));
-               $item['post-type']     = defaults($item, 'post-type', self::PT_ARTICLE);
-               $item['verb']          = trim(defaults($item, 'verb', ''));
-               $item['object-type']   = trim(defaults($item, 'object-type', ''));
-               $item['object']        = trim(defaults($item, 'object', ''));
-               $item['target-type']   = trim(defaults($item, 'target-type', ''));
-               $item['target']        = trim(defaults($item, 'target', ''));
-               $item['plink']         = trim(defaults($item, 'plink', ''));
-               $item['allow_cid']     = trim(defaults($item, 'allow_cid', ''));
-               $item['allow_gid']     = trim(defaults($item, 'allow_gid', ''));
-               $item['deny_cid']      = trim(defaults($item, 'deny_cid', ''));
-               $item['deny_gid']      = trim(defaults($item, 'deny_gid', ''));
-               $item['private']       = intval(defaults($item, 'private', 0));
-               $item['body']          = trim(defaults($item, 'body', ''));
-               $item['tag']           = trim(defaults($item, 'tag', ''));
-               $item['attach']        = trim(defaults($item, 'attach', ''));
-               $item['app']           = trim(defaults($item, 'app', ''));
-               $item['origin']        = intval(defaults($item, 'origin', 0));
-               $item['postopts']      = trim(defaults($item, 'postopts', ''));
-               $item['resource-id']   = trim(defaults($item, 'resource-id', ''));
-               $item['event-id']      = intval(defaults($item, 'event-id', 0));
-               $item['inform']        = trim(defaults($item, 'inform', ''));
-               $item['file']          = trim(defaults($item, 'file', ''));
+               $item['parent-uri']    = trim(($item['parent-uri'] ?? '') ?: $item['uri']);
+               $item['post-type']     = ($item['post-type'] ?? '') ?: self::PT_ARTICLE;
+               $item['verb']          = trim($item['verb'] ?? '');
+               $item['object-type']   = trim($item['object-type'] ?? '');
+               $item['object']        = trim($item['object'] ?? '');
+               $item['target-type']   = trim($item['target-type'] ?? '');
+               $item['target']        = trim($item['target'] ?? '');
+               $item['plink']         = trim($item['plink'] ?? '');
+               $item['allow_cid']     = trim($item['allow_cid'] ?? '');
+               $item['allow_gid']     = trim($item['allow_gid'] ?? '');
+               $item['deny_cid']      = trim($item['deny_cid'] ?? '');
+               $item['deny_gid']      = trim($item['deny_gid'] ?? '');
+               $item['private']       = intval($item['private'] ?? 0);
+               $item['body']          = trim($item['body'] ?? '');
+               $item['tag']           = trim($item['tag'] ?? '');
+               $item['attach']        = trim($item['attach'] ?? '');
+               $item['app']           = trim($item['app'] ?? '');
+               $item['origin']        = intval($item['origin'] ?? 0);
+               $item['postopts']      = trim($item['postopts'] ?? '');
+               $item['resource-id']   = trim($item['resource-id'] ?? '');
+               $item['event-id']      = intval($item['event-id'] ?? 0);
+               $item['inform']        = trim($item['inform'] ?? '');
+               $item['file']          = trim($item['file'] ?? '');
 
                // When there is no content then we don't post it
                if ($item['body'].$item['title'] == '') {
@@ -1479,12 +1479,12 @@ class Item extends BaseObject
                        $item['edited'] = DateTimeFormat::utcNow();
                }
 
-               $item['plink'] = defaults($item, 'plink', System::baseUrl() . '/display/' . urlencode($item['guid']));
+               $item['plink'] = ($item['plink'] ?? '') ?: System::baseUrl() . '/display/' . urlencode($item['guid']);
 
                $default = ['url' => $item['author-link'], 'name' => $item['author-name'],
                        'photo' => $item['author-avatar'], 'network' => $item['network']];
 
-               $item['author-id'] = defaults($item, 'author-id', Contact::getIdForURL($item['author-link'], 0, false, $default));
+               $item['author-id'] = ($item['author-id'] ?? 0) ?: Contact::getIdForURL($item['author-link'], 0, false, $default);
 
                if (Contact::isBlocked($item['author-id'])) {
                        Logger::notice('Author is blocked node-wide', ['author-link' => $item['author-link'], 'item-uri' => $item['uri']]);
@@ -1504,7 +1504,7 @@ class Item extends BaseObject
                $default = ['url' => $item['owner-link'], 'name' => $item['owner-name'],
                        'photo' => $item['owner-avatar'], 'network' => $item['network']];
 
-               $item['owner-id'] = defaults($item, 'owner-id', Contact::getIdForURL($item['owner-link'], 0, false, $default));
+               $item['owner-id'] = ($item['owner-id'] ?? 0) ?: Contact::getIdForURL($item['owner-link'], 0, false, $default);
 
                if (Contact::isBlocked($item['owner-id'])) {
                        Logger::notice('Owner is blocked node-wide', ['owner-link' => $item['owner-link'], 'item-uri' => $item['uri']]);
@@ -2453,7 +2453,7 @@ class Item extends BaseObject
                        Contact::unmarkForArchival($contact);
                }
 
-               $update = (!$arr['private'] && ((defaults($arr, 'author-link', '') === defaults($arr, 'owner-link', '')) || ($arr["parent-uri"] === $arr["uri"])));
+               $update = (!$arr['private'] && ((($arr['author-link'] ?? '') === ($arr['owner-link'] ?? '')) || ($arr["parent-uri"] === $arr["uri"])));
 
                // Is it a forum? Then we don't care about the rules from above
                if (!$update && in_array($arr["network"], [Protocol::ACTIVITYPUB, Protocol::DFRN]) && ($arr["parent-uri"] === $arr["uri"])) {
@@ -3334,8 +3334,8 @@ class Item extends BaseObject
        {
                $body = $item["body"];
 
-               $rendered_hash = defaults($item, 'rendered-hash', '');
-               $rendered_html = defaults($item, 'rendered-html', '');
+               $rendered_hash = $item['rendered-hash'] ?? '';
+               $rendered_html = $item['rendered-html'] ?? '';
 
                if ($rendered_hash == ''
                        || $rendered_html == ""
@@ -3491,7 +3491,7 @@ class Item extends BaseObject
                                $filesubtype = 'unkn';
                        }
 
-                       $title = Strings::escapeHtml(trim(defaults($mtch, 4, $mtch[1])));
+                       $title = Strings::escapeHtml(trim(($mtch[4] ?? '') ?: $mtch[1]));
                        $title .= ' ' . $mtch[2] . ' ' . L10n::t('bytes');
 
                        $icon = '<div class="attachtype icon s22 type-' . $filetype . ' subtype-' . $filesubtype . '"></div>';
index 6d03ae3253b28c8e51ae6de236b9b5803756c248..68b42af92857b42b6de41af5703f76c729637fab 100644 (file)
@@ -90,7 +90,7 @@ class ItemContent extends BaseObject
                        }
                }
 
-               $html = Text\BBCode::convert($post['text'] . defaults($post, 'after', ''), false, $htmlmode);
+               $html = Text\BBCode::convert($post['text'] . ($post['after'] ?? ''), false, $htmlmode);
                $msg = Text\HTML::toPlaintext($html, 0, true);
                $msg = trim(html_entity_decode($msg, ENT_QUOTES, 'UTF-8'));
 
@@ -99,7 +99,7 @@ class ItemContent extends BaseObject
                        if ($post['type'] == 'link') {
                                $link = $post['url'];
                        } elseif ($post['type'] == 'text') {
-                               $link = defaults($post, 'url', '');
+                               $link = $post['url'] ?? '';
                        } elseif ($post['type'] == 'video') {
                                $link = $post['url'];
                        } elseif ($post['type'] == 'photo') {
index 90448806d8bd1e8cc62022bf33117dc1e0662310..c9a0697ebc9800ee3a42eadfed7e0648174dc542 100644 (file)
@@ -22,10 +22,10 @@ class PermissionSet extends BaseObject
        public static function fetchIDForPost(&$postarray)
        {
                $condition = ['uid' => $postarray['uid'],
-                       'allow_cid' => self::sortPermissions(defaults($postarray, 'allow_cid', '')),
-                       'allow_gid' => self::sortPermissions(defaults($postarray, 'allow_gid', '')),
-                       'deny_cid' => self::sortPermissions(defaults($postarray, 'deny_cid', '')),
-                       'deny_gid' => self::sortPermissions(defaults($postarray, 'deny_gid', ''))];
+                       'allow_cid' => self::sortPermissions($postarray['allow_cid'] ?? ''),
+                       'allow_gid' => self::sortPermissions($postarray['allow_gid'] ?? ''),
+                       'deny_cid'  => self::sortPermissions($postarray['deny_cid']  ?? ''),
+                       'deny_gid'  => self::sortPermissions($postarray['deny_gid']  ?? '')];
 
                $set = DBA::selectFirst('permissionset', ['id'], $condition);
 
index 67c6a0eb68cd3ccdfe3f525248df802c4a55d58a..b69860edfff73038d4f6438f4ab2e865be765c2c 100644 (file)
@@ -90,7 +90,7 @@ class Profile
                        $location .= $profile['locality'];
                }
 
-               if (!empty($profile['region']) && (defaults($profile, 'locality', '') != $profile['region'])) {
+               if (!empty($profile['region']) && (($profile['locality'] ?? '') != $profile['region'])) {
                        if ($location) {
                                $location .= ', ';
                        }
@@ -322,7 +322,7 @@ class Profile
                        return $o;
                }
 
-               $profile['picdate'] = urlencode(defaults($profile, 'picdate', ''));
+               $profile['picdate'] = urlencode($profile['picdate'] ?? '');
 
                if (($profile['network'] != '') && ($profile['network'] != Protocol::DFRN)) {
                        $profile['network_link'] = Strings::formatNetworkName($profile['network'], $profile['url']);
@@ -384,7 +384,7 @@ class Profile
 
                        if (Contact::canReceivePrivateMessages($profile)) {
                                if ($visitor_is_followed || $visitor_is_following) {
-                                       $wallmessage_link = $visitor_base_path . '/message/new/' . base64_encode(defaults($profile, 'addr', ''));
+                                       $wallmessage_link = $visitor_base_path . '/message/new/' . base64_encode($profile['addr'] ?? '');
                                } elseif ($visitor_is_authenticated && !empty($profile['unkmail'])) {
                                        $wallmessage_link = 'wallmessage/' . $profile['nickname'];
                                }
@@ -460,14 +460,14 @@ class Profile
                        $diaspora = [
                                'guid' => $profile['guid'],
                                'podloc' => System::baseUrl(),
-                               'searchable' => (($profile['publish'] && $profile['net-publish']) ? 'true' : 'false' ),
+                               'searchable' => (($profile['publish'] && $profile['net-publish']) ? 'true' : 'false'),
                                'nickname' => $profile['nickname'],
                                'fullname' => $profile['name'],
                                'firstname' => $firstname,
                                'lastname' => $lastname,
-                               'photo300' => defaults($profile, 'contact_photo', ''),
-                               'photo100' => defaults($profile, 'contact_thumb', ''),
-                               'photo50' => defaults($profile, 'contact_micro', ''),
+                               'photo300' => $profile['contact_photo'] ?? '',
+                               'photo100' => $profile['contact_thumb'] ?? '',
+                               'photo50' => $profile['contact_micro'] ?? '',
                        ];
                } else {
                        $diaspora = false;
@@ -530,7 +530,7 @@ class Profile
                        $p['photo'] = ProxyUtils::proxifyUrl($p['photo'], false, ProxyUtils::SIZE_SMALL);
                }
 
-               $p['url'] = Contact::magicLink(defaults($p, 'url', $profile_url));
+               $p['url'] = Contact::magicLink(($p['url'] ?? '') ?: $profile_url);
 
                $tpl = Renderer::getMarkupTemplate('profile_vcard.tpl');
                $o .= Renderer::replaceMacros($tpl, [
index 82e638158c57933125ee435e820246bb0e60a692..ff7c59444e363cfe4f85fa732607b2044dcb4f82 100644 (file)
@@ -132,7 +132,7 @@ class Filesystem implements IStorage
        
        public static function saveOptions($data)
        {
-               $storagepath = defaults($data, 'storagepath', '');
+               $storagepath = $data['storagepath'] ?? '';
                if ($storagepath === '' || !is_dir($storagepath)) {
                        return [
                                'storagepath' => L10n::t('Enter a valid existing folder')
index 1de93fb05b64faffd1d174456923fb4bd27dd562..01169c52265b0f235d4a41ebab8bbbb4d4a7af83 100644 (file)
@@ -210,7 +210,7 @@ class Term
        {
                $profile_base = System::baseUrl();
                $profile_data = parse_url($profile_base);
-               $profile_path = defaults($profile_data, 'path', '');
+               $profile_path = $profile_data['path'] ?? '';
                $profile_base_friendica = $profile_data['host'] . $profile_path . '/profile/';
                $profile_base_diaspora = $profile_data['host'] . $profile_path . '/u/';
 
index 692e905914472081306002f19ef6ac74fb258b06..1c2500a224e6cc6dd0e2fcffa0200650cb8c5694 100644 (file)
@@ -13,10 +13,10 @@ class Acctlink extends BaseModule
 {
        public static function content()
        {
-               $addr = defaults($_GET, 'addr', false);
+               $addr = trim($_GET['addr'] ?? '');
 
                if ($addr) {
-                       $url = defaults(Probe::uri(trim($addr)), 'url', false);
+                       $url = Probe::uri($addr)['url'] ?? '';
 
                        if ($url) {
                                System::externalRedirect($url);
index 1fadf6768bbdf670062215c96df925cc87c18e22..1965102f03ef5fe4d8abac2420baf47a96d5d0c8 100644 (file)
@@ -53,7 +53,7 @@ class Details extends BaseAdminModule
                                $a->internalRedirect('admin/addons');
                        }
 
-                       if (defaults($_GET, 'action', '') == 'toggle') {
+                       if (($_GET['action'] ?? '') == 'toggle') {
                                parent::checkFormSecurityTokenRedirectOnError('/admin/addons', 'admin_themes', 't');
 
                                // Toggle addon status
index 2fa39d8e406da598dca8141a80791bdcf95ea16c..eed47defb4a973fc43581f080de1930040072848 100644 (file)
@@ -26,7 +26,7 @@ class Index extends BaseAdminModule
                                        break;
 
                                case 'toggle' :
-                                       $addon = defaults($_GET, 'addon', '');
+                                       $addon = $_GET['addon'] ?? '';
                                        if (Addon::isEnabled($addon)) {
                                                Addon::uninstall($addon);
                                                info(L10n::t('Addon %s disabled.', $addon));
index de3c717e37d06e93ba5d00ea81087a00729521ed..bf1c7bc081d86cfec1dacb12a2c681dbbeb130bb 100644 (file)
@@ -15,9 +15,9 @@ class Contact extends BaseAdminModule
        {
                parent::post();
 
-               $contact_url  = defaults($_POST, 'contact_url', '');
-               $block_reason = defaults($_POST, 'contact_block_reason', '');
-               $contacts     = defaults($_POST, 'contacts', []);
+               $contact_url  = $_POST['contact_url'] ?? '';
+               $block_reason = $_POST['contact_block_reason'] ?? '';
+               $contacts     = $_POST['contacts'] ?? [];
 
                parent::checkFormSecurityTokenRedirectOnError('/admin/blocklist/contact', 'admin_contactblock');
 
index b9a5e3832d87b3d3dd6027a0c9cb1442a1eb723d..be060e05359baf2012ffa540e62ef1a41ad918fe 100644 (file)
@@ -20,7 +20,7 @@ class Settings extends BaseAdminModule
 
                        $logfile   = (!empty($_POST['logfile']) ? Strings::escapeTags(trim($_POST['logfile'])) : '');
                        $debugging = !empty($_POST['debugging']);
-                       $loglevel  = defaults($_POST, 'loglevel', LogLevel::ERROR);
+                       $loglevel  = ($_POST['loglevel'] ?? '') ?: LogLevel::ERROR;
 
                        if (is_file($logfile) &&
                        !is_writeable($logfile)) {
index dff869df20ae2a7912c25ea611bc60a64fe2cd44..18a1cbf2a835f5d214e1731a478945c52672e492 100644 (file)
@@ -200,7 +200,7 @@ class Site extends BaseAdminModule
                /**
                 * @var $storagebackend \Friendica\Model\Storage\IStorage
                 */
-               $storagebackend    = Strings::escapeTags(trim(defaults($_POST, 'storagebackend', '')));
+               $storagebackend    = Strings::escapeTags(trim($_POST['storagebackend'] ?? ''));
 
                // save storage backend form
                if (!is_null($storagebackend) && $storagebackend != "") {
@@ -216,7 +216,7 @@ class Site extends BaseAdminModule
                                                        $value = !empty($_POST[$fieldname]);
                                                        break;
                                                default:
-                                                       $value = defaults($_POST, $fieldname, '');
+                                                       $value = $_POST[$fieldname] ?? '';
                                        }
                                        $storage_opts_data[$name] = $value;
                                }
index d29b4c33caea64b438d477887dc7ccb198fda47b..af2d1f28e11e0ae91e6b90ab79d2afaf93251c8c 100644 (file)
@@ -36,7 +36,7 @@ class Index extends BaseAdminModule
                                        break;
 
                                case 'toggle' :
-                                       $theme = defaults($_GET, 'addon', '');
+                                       $theme = $_GET['addon'] ?? '';
                                        if ($theme) {
                                                $theme = Strings::sanitizeFilePathItem($theme);
                                                if (!is_dir("view/theme/$theme")) {
index 92dddd9f73b3e323ea6138af8ecd1c227ab8c69f..a949c9331b51c37df41e8196850dcce11f115767 100644 (file)
@@ -21,11 +21,11 @@ class Users extends BaseAdminModule
 
                $a = self::getApp();
 
-               $pending     = defaults($_POST, 'pending'          , []);
-               $users       = defaults($_POST, 'user'             , []);
-               $nu_name     = defaults($_POST, 'new_user_name'    , '');
-               $nu_nickname = defaults($_POST, 'new_user_nickname', '');
-               $nu_email    = defaults($_POST, 'new_user_email'   , '');
+               $pending     = $_POST['pending']           ?? [];
+               $users       = $_POST['user']              ?? [];
+               $nu_name     = $_POST['new_user_name']     ?? '';
+               $nu_nickname = $_POST['new_user_nickname'] ?? '';
+               $nu_email    = $_POST['new_user_email']    ?? '';
                $nu_language = Config::get('system', 'language');
 
                parent::checkFormSecurityTokenRedirectOnError('/admin/users', 'admin_users');
index b0e6ea1490bcf00bc519be5061ef80a39a73631c..e5fbe697128d576374fd6fed2d9b2e75da3ee3ab 100644 (file)
@@ -78,7 +78,7 @@ class AllFriends extends BaseModule
 
                        $entry = [
                                'url'          => Model\Contact::magicLinkbyId($friend['id'], $friend['url']),
-                               'itemurl'      => defaults($contactDetails, 'addr', $friend['url']),
+                               'itemurl'      => ($contactDetails['addr'] ?? '') ?: $friend['url'],
                                'name'         => $contactDetails['name'],
                                'thumb'        => ProxyUtils::proxifyUrl($contactDetails['thumb'], false, ProxyUtils::SIZE_THUMB),
                                'img_hover'    => $contactDetails['name'],
index 283ab0117b40437838c89a0b90d8ea7b30557393..92130eeff1510d7adc5c5707db9525aaf2379c54 100644 (file)
@@ -27,7 +27,7 @@ class Bookmarklet extends BaseModule
                        return $output;
                }
 
-               $referer = Strings::normaliseLink(defaults($_SERVER, 'HTTP_REFERER', ''));
+               $referer = Strings::normaliseLink($_SERVER['HTTP_REFERER'] ?? '');
                $page = Strings::normaliseLink($app->getBaseURL() . "/bookmarklet");
 
                if (!strstr($referer, $page)) {
@@ -48,7 +48,7 @@ class Bookmarklet extends BaseModule
                                'bang'             => '',
                                'visitor'          => 'block',
                                'profile_uid'      => local_user(),
-                               'title'            => trim(defaults($_REQUEST, 'title', ''), '*'),
+                               'title'            => trim($_REQUEST['title'] ?? '', '*'),
                                'content'          => $content
                        ];
                        $output = status_editor($app, $x, 0, false);
index 0b27f0e4a37d1a20a3d222174778743fbd5f3897..c8bbbfe2e69a1d45b9467670375fd235d14e682e 100644 (file)
@@ -103,7 +103,7 @@ class Contact extends BaseModule
 
                Hook::callAll('contact_edit_post', $_POST);
 
-               $profile_id = intval(defaults($_POST, 'profile-assign', 0));
+               $profile_id = intval($_POST['profile-assign'] ?? 0);
                if ($profile_id) {
                        if (!DBA::exists('profile', ['id' => $profile_id, 'uid' => local_user()])) {
                                notice(L10n::t('Could not locate selected profile.') . EOL);
@@ -115,16 +115,16 @@ class Contact extends BaseModule
 
                $notify = !empty($_POST['notify']);
 
-               $fetch_further_information = intval(defaults($_POST, 'fetch_further_information', 0));
+               $fetch_further_information = intval($_POST['fetch_further_information'] ?? 0);
 
-               $ffi_keyword_blacklist = Strings::escapeHtml(trim(defaults($_POST, 'ffi_keyword_blacklist', '')));
+               $ffi_keyword_blacklist = Strings::escapeHtml(trim($_POST['ffi_keyword_blacklist'] ?? ''));
 
-               $priority = intval(defaults($_POST, 'poll', 0));
+               $priority = intval($_POST['poll'] ?? 0);
                if ($priority > 5 || $priority < 0) {
                        $priority = 0;
                }
 
-               $info = Strings::escapeHtml(trim(defaults($_POST, 'info', '')));
+               $info = Strings::escapeHtml(trim($_POST['info'] ?? ''));
 
                $r = DBA::update('contact', [
                        'profile-id' => $profile_id,
@@ -188,21 +188,42 @@ class Contact extends BaseModule
                Model\GContact::updateFromProbe($contact['url']);
        }
 
+       /**
+        * Toggles the blocked status of a contact identified by id.
+        *
+        * @param $contact_id
+        * @throws \Exception
+        */
        private static function blockContact($contact_id)
        {
                $blocked = !Model\Contact::isBlockedByUser($contact_id, local_user());
                Model\Contact::setBlockedForUser($contact_id, local_user(), $blocked);
        }
 
+       /**
+        * Toggles the ignored status of a contact identified by id.
+        *
+        * @param $contact_id
+        * @throws \Exception
+        */
        private static function ignoreContact($contact_id)
        {
                $ignored = !Model\Contact::isIgnoredByUser($contact_id, local_user());
                Model\Contact::setIgnoredForUser($contact_id, local_user(), $ignored);
        }
 
+       /**
+        * Toggles the archived status of a contact identified by id.
+        * If the current status isn't provided, this will always archive the contact.
+        *
+        * @param $contact_id
+        * @param $orig_record
+        * @return bool
+        * @throws \Exception
+        */
        private static function archiveContact($contact_id, $orig_record)
        {
-               $archived = (defaults($orig_record, 'archive', '') ? 0 : 1);
+               $archived = empty($orig_record['archive']);
                $r = DBA::update('contact', ['archive' => $archived], ['id' => $contact_id, 'uid' => local_user()]);
 
                return DBA::isResult($r);
@@ -227,8 +248,8 @@ class Contact extends BaseModule
 
                $a = self::getApp();
 
-               $nets = defaults($_GET, 'nets', '');
-               $rel  = defaults($_GET, 'rel' , '');
+               $nets = $_GET['nets'] ?? '';
+               $rel  = $_GET['rel']  ?? '';
 
                if (empty($a->page['aside'])) {
                        $a->page['aside'] = '';
@@ -290,7 +311,7 @@ class Contact extends BaseModule
                                '$name'         => $contact['name'],
                                '$photo'        => $contact['photo'],
                                '$url'          => Model\Contact::magicLinkByContact($contact, $contact['url']),
-                               '$addr'         => defaults($contact, 'addr', ''),
+                               '$addr'         => $contact['addr'] ?? '',
                                '$network_link' => $network_link,
                                '$network'      => L10n::t('Network:'),
                                '$account_type' => Model\Contact::getAccountType($contact),
@@ -626,7 +647,7 @@ class Contact extends BaseModule
                }
 
                // @TODO: Replace with parameter from router
-               $type = defaults($a->argv, 1, '');
+               $type = $a->argv[1] ?? '';
 
                switch ($type) {
                        case 'blocked':
@@ -651,9 +672,9 @@ class Contact extends BaseModule
 
                $sql_extra .= sprintf(" AND `network` != '%s' ", Protocol::PHANTOM);
 
-               $search = Strings::escapeTags(trim(defaults($_GET, 'search', '')));
-               $nets   = Strings::escapeTags(trim(defaults($_GET, 'nets'  , '')));
-               $rel    = Strings::escapeTags(trim(defaults($_GET, 'rel'   , '')));
+               $search = Strings::escapeTags(trim($_GET['search'] ?? ''));
+               $nets   = Strings::escapeTags(trim($_GET['nets']   ?? ''));
+               $rel    = Strings::escapeTags(trim($_GET['rel']    ?? ''));
 
                $tabs = [
                        [
@@ -1016,7 +1037,7 @@ class Contact extends BaseModule
                        'username'  => $rr['name'],
                        'account_type' => Model\Contact::getAccountType($rr),
                        'sparkle'   => $sparkle,
-                       'itemurl'   => defaults($rr, 'addr', $rr['url']),
+                       'itemurl'   => ($rr['addr'] ?? '') ?: $rr['url'],
                        'url'       => $url,
                        'network'   => ContactSelector::networkToName($rr['network'], $rr['url']),
                        'nick'      => $rr['nick'],
index 19e3ec2131282248455f0676c5d7ae2b8bfb1f3c..cf1f869552e6116b0c3bb097c97120bdafdb5851 100644 (file)
@@ -25,7 +25,7 @@ class Babel extends BaseModule
 
                $results = [];
                if (!empty($_REQUEST['text'])) {
-                       switch (defaults($_REQUEST, 'type', 'bbcode')) {
+                       switch (($_REQUEST['type'] ?? '') ?: 'bbcode') {
                                case 'bbcode':
                                        $bbcode = trim($_REQUEST['text']);
                                        $results[] = [
@@ -176,10 +176,10 @@ class Babel extends BaseModule
 
                $tpl = Renderer::getMarkupTemplate('babel.tpl');
                $o = Renderer::replaceMacros($tpl, [
-                       '$text'          => ['text', L10n::t('Source text'), defaults($_REQUEST, 'text', ''), ''],
-                       '$type_bbcode'   => ['type', L10n::t('BBCode'), 'bbcode', '', defaults($_REQUEST, 'type', 'bbcode') == 'bbcode'],
-                       '$type_markdown' => ['type', L10n::t('Markdown'), 'markdown', '', defaults($_REQUEST, 'type', 'bbcode') == 'markdown'],
-                       '$type_html'     => ['type', L10n::t('HTML'), 'html', '', defaults($_REQUEST, 'type', 'bbcode') == 'html'],
+                       '$text'          => ['text', L10n::t('Source text'), $_REQUEST['text'] ?? '', ''],
+                       '$type_bbcode'   => ['type', L10n::t('BBCode'), 'bbcode', '', (($_REQUEST['type'] ?? '') ?: 'bbcode') == 'bbcode'],
+                       '$type_markdown' => ['type', L10n::t('Markdown'), 'markdown', '', (($_REQUEST['type'] ?? '') ?: 'bbcode') == 'markdown'],
+                       '$type_html'     => ['type', L10n::t('HTML'), 'html', '', (($_REQUEST['type'] ?? '') ?: 'bbcode') == 'html'],
                        '$results'       => $results
                ]);
 
index a11df59b79f32ecfd07bdce37911a567845b1f1c..cc0be643b3030b858230b3248d8c9ed1af9f7e1a 100644 (file)
@@ -46,7 +46,7 @@ class Feed extends BaseModule
 
                $tpl = Renderer::getMarkupTemplate('feedtest.tpl');
                return Renderer::replaceMacros($tpl, [
-                       '$url'    => ['url', L10n::t('Source URL'), defaults($_REQUEST, 'url', ''), ''],
+                       '$url'    => ['url', L10n::t('Source URL'), $_REQUEST['url'] ?? '', ''],
                        '$result' => $result
                ]);
        }
index 7af9cb8dad2d56970cc96cd0990b433b4c72f9d1..197149837ae5f161f2e4d6caaf1b271b669b3921 100644 (file)
@@ -12,7 +12,7 @@ class Localtime extends BaseModule
 {
        public static function post()
        {
-               $time = defaults($_REQUEST, 'time', 'now');
+               $time = ($_REQUEST['time'] ?? '') ?: 'now';
 
                $bd_format = L10n::t('l F d, Y \@ g:i A');
 
@@ -25,7 +25,7 @@ class Localtime extends BaseModule
        {
                $app = self::getApp();
 
-               $time = defaults($_REQUEST, 'time', 'now');
+               $time = ($_REQUEST['time'] ?? '') ?: 'now';
 
                $output  = '<h3>' . L10n::t('Time Conversion') . '</h3>';
                $output .= '<p>' . L10n::t('Friendica provides this service for sharing events with other networks and friends in unknown timezones.') . '</p>';
@@ -41,7 +41,7 @@ class Localtime extends BaseModule
 
                $output .= '<form action ="' . $app->getBaseURL() . '/localtime?time=' . $time . '" method="post" >';
                $output .= '<p>' . L10n::t('Please select your timezone:') . '</p>';
-               $output .= Temporal::getTimezoneSelect(defaults($_REQUEST, 'timezone', Installer::DEFAULT_TZ));
+               $output .= Temporal::getTimezoneSelect(($_REQUEST['timezone'] ?? '') ?: Installer::DEFAULT_TZ);
                $output .= '<input type="submit" name="submit" value="' . L10n::t('Submit') . '" /></form>';
 
                return $output;
index f29f3b3bb79fe5ad24ffd1c72aed4f7c700dcadd..6762c5b82c99bc87bba154da10d283338ad5334e 100644 (file)
@@ -21,7 +21,7 @@ class Probe extends BaseModule
                        throw $e;
                }
 
-               $addr = defaults($_GET, 'addr', '');
+               $addr = $_GET['addr'] ?? '';
                $res  = '';
 
                if (!empty($addr)) {
index 2b0b9c53b494c54335627dcbad770b1f0cf11598..18cf4bb2a7386cbc86df382b8265a5097bf80d09 100644 (file)
@@ -20,7 +20,7 @@ class WebFinger extends BaseModule
                        throw $e;
                }
 
-               $addr = defaults($_GET, 'addr', '');
+               $addr = $_GET['addr'] ?? '';
                $res  = '';
 
                if (!empty($addr)) {
index 15b2026e2c246559668a4e30df495e8a811280d0..49ecfed96c166cd6d6676f77816ec1a100e77e43 100644 (file)
@@ -27,7 +27,7 @@ class Feed extends BaseModule
        {
                $a = self::getApp();
 
-               $last_update = defaults($_GET, 'last_update', '');
+               $last_update = $_GET['last_update'] ?? '';
                $nocache     = !empty($_GET['nocache']) && local_user();
 
                // @TODO: Replace with parameter from router
index 7e88b2e72eece491bc57e4ee2c1772f778727216..1dcc2e41e20a0f3a2a2b67bcc4d54c0e1f64bcb2 100644 (file)
@@ -23,8 +23,8 @@ class RemoveTag extends BaseModule
 
                $item_id = (($app->argc > 1) ? intval($app->argv[1]) : 0);
 
-               $term = XML::unescape(trim(defaults($_GET, 'term', '')));
-               $cat = XML::unescape(trim(defaults($_GET, 'cat', '')));
+               $term = XML::unescape(trim($_GET['term'] ?? ''));
+               $cat = XML::unescape(trim($_GET['cat'] ?? ''));
 
                $category = (($cat) ? true : false);
 
index 08ff1a32d04545c763f060aaef8f495e118b19f4..e8e311268149575843312fe9ed6e6bd88d22e386 100644 (file)
@@ -27,7 +27,7 @@ class SaveTag extends BaseModule
                $a = self::getApp();
                $logger = $a->getLogger();
 
-               $term = XML::unescape(trim(defaults($_GET, 'term', '')));
+               $term = XML::unescape(trim($_GET['term'] ?? ''));
                // @TODO: Replace with parameter from router
                $item_id = (($a->argc > 1) ? intval($a->argv[1]) : 0);
 
index 1921e748a8161dddb51ff33edb702935506ff5f8..f4f2a877c4f55fb1833f443ead4ebf0b304b3f44 100644 (file)
@@ -28,10 +28,10 @@ class FollowConfirm extends BaseModule
                        return;
                }
 
-               $intro_id = intval(defaults($_POST, 'intro_id'  , 0));
-               $duplex   = intval(defaults($_POST, 'duplex'    , 0));
-               $cid      = intval(defaults($_POST, 'contact_id', 0));
-               $hidden   = intval(defaults($_POST, 'hidden'    , 0));
+               $intro_id = intval($_POST['intro_id']   ?? 0);
+               $duplex   = intval($_POST['duplex']     ?? 0);
+               $cid      = intval($_POST['contact_id'] ?? 0);
+               $hidden   = intval($_POST['hidden']     ?? 0);
 
                if (empty($cid)) {
                        notice(L10n::t('No given contact.') . EOL);
index 79f34021b13243ebc883b01106cbf31b92d46a1c..5bd3fe0ce2ef238b165fa52999c491400ecf4bc8 100644 (file)
@@ -29,7 +29,7 @@ class Followers extends BaseModule
                        throw new \Friendica\Network\HTTPException\NotFoundException();
                }
 
-               $page = defaults($_REQUEST, 'page', null);
+               $page = $_REQUEST['page'] ?? null;
 
                $followers = ActivityPub\Transmitter::getFollowers($owner, $page);
 
index 3a68e7e0afbd9bb21852e878e2decbd718e6e0ad..5b5f4dc986d491d5c086f1f459ffef8bf5645e1e 100644 (file)
@@ -29,7 +29,7 @@ class Following extends BaseModule
                        throw new \Friendica\Network\HTTPException\NotFoundException();
                }
 
-               $page = defaults($_REQUEST, 'page', null);
+               $page = $_REQUEST['page'] ?? null;
 
                $Following = ActivityPub\Transmitter::getFollowing($owner, $page);
 
index 7ba40396659927f15df9f6b28b3759c33c2d4e13..39d6a062afd438cb47437da531660251e4117f14 100644 (file)
@@ -73,7 +73,7 @@ class Install extends BaseModule
                // so we may not have a css at all. Here we set a static css file for the install procedure pages
                Renderer::$theme['stylesheet'] = $a->getBaseURL() . '/view/install/style.css';
 
-               self::$currentWizardStep = defaults($_POST, 'pass', self::SYSTEM_CHECK);
+               self::$currentWizardStep = ($_POST['pass'] ?? '') ?: self::SYSTEM_CHECK;
        }
 
        public static function post()
@@ -345,8 +345,8 @@ class Install extends BaseModule
        {
                $configCache->set($cat, $key,
                        Strings::escapeTags(
-                               trim(defaults($post, sprintf('%s-%s', $cat, $key),
-                                               (!isset($default) ? $configCache->get($cat, $key) : $default))
+                               trim(($post[sprintf('%s-%s', $cat, $key)] ?? '') ?:
+                                               ($default ?? $configCache->get($cat, $key))
                                )
                        )
                );
index a43e38045c8c611213a81ba7b240ebd2a98603c9..cc450dd9d0d381e2f7c2df211eb04ff1cc727135 100644 (file)
@@ -36,7 +36,7 @@ class Like extends BaseModule
 
                // Decide how to return. If we were called with a 'return' argument,
                // then redirect back to the calling page. If not, just quietly end
-               $returnPath = defaults($_REQUEST, 'return', '');
+               $returnPath = $_REQUEST['return'] ?? '';
 
                if (!empty($returnPath)) {
                        $rand = '_=' . time();
index 8affd77557a3e9fe557024801be30330ee798d91..b67f48fb95daca5be645f7f3104ef6a12c0b277e 100644 (file)
@@ -53,7 +53,7 @@ class Login extends BaseModule
                        && (!empty($_POST['openid_url'])
                                || !empty($_POST['username']))
                ) {
-                       $openid_url = trim(defaults($_POST, 'openid_url', $_POST['username']));
+                       $openid_url = trim(($_POST['openid_url'] ?? '') ?: $_POST['username']);
 
                        self::openIdAuthentication($openid_url, !empty($_POST['remember']));
                }
index 4cb3dc7328052df1f9fe89da9cb603b24c753267..b04ea80c04bdd73f84ae90a4b515fa7f02c05dd5 100644 (file)
@@ -28,8 +28,8 @@ class Magic extends BaseModule
 
                Logger::log('args: ' . print_r($_REQUEST, true), Logger::DATA);
 
-               $addr = defaults($_REQUEST, 'addr', '');
-               $dest = defaults($_REQUEST, 'dest', '');
+               $addr = $_REQUEST['addr'] ?? '';
+               $dest = $_REQUEST['dest'] ?? '';
                $test = (!empty($_REQUEST['test']) ? intval($_REQUEST['test']) : 0);
                $owa  = (!empty($_REQUEST['owa'])  ? intval($_REQUEST['owa'])  : 0);
                $cid  = 0;
index 14825677910919e92a50833d6866bbeb1b16f5c9..4fc05076310ad2593fb6dff4d469b9c243eb6da1 100644 (file)
@@ -28,7 +28,7 @@ class Outbox extends BaseModule
                        throw new \Friendica\Network\HTTPException\NotFoundException();
                }
 
-               $page = defaults($_REQUEST, 'page', null);
+               $page = $_REQUEST['page'] ?? null;
 
                /// @todo Add Authentication to enable fetching of non public content
                // $requester = HTTPSignature::getSigner('', $_SERVER);
index cb710b10ba97bee752cc13cd3dcf7aab7156603c..ed37540753582fea049838a2139b5f285f0c88ad 100644 (file)
@@ -102,7 +102,7 @@ class Profile extends BaseModule
 
                        // site block
                        if (!$blocked && !$userblock) {
-                               $keywords = str_replace(['#', ',', ' ', ',,'], ['', ' ', ',', ','], defaults($a->profile, 'pub_keywords', ''));
+                               $keywords = str_replace(['#', ',', ' ', ',,'], ['', ' ', ',', ','], $a->profile['pub_keywords'] ?? '');
                                if (strlen($keywords)) {
                                        $a->page['htmlhead'] .= '<meta name="keywords" content="' . $keywords . '" />' . "\n";
                                }
@@ -146,10 +146,10 @@ class Profile extends BaseModule
                }
 
                if (empty($category)) {
-                       $category = defaults($_GET, 'category', '');
+                       $category = $_GET['category'] ?? '';
                }
 
-               $hashtags = defaults($_GET, 'tag', '');
+               $hashtags = $_GET['tag'] ?? '';
 
                if (Config::get('system', 'block_public') && !local_user() && !Session::getRemoteContactID($a->profile['profile_uid'])) {
                        return Login::form();
@@ -174,7 +174,7 @@ class Profile extends BaseModule
                }
 
                if (!$update) {
-            $tab = Strings::escapeTags(trim(defaults($_GET, 'tab', '')));
+            $tab = Strings::escapeTags(trim($_GET['tab'] ?? ''));
 
                        $o .= ProfileModel::getTabs($a, $tab, $is_owner, $a->profile['nickname']);
 
index ed41f421b12a8dec7c81de7d4458bbd08e9e5f04..1bf88d7c5b820b7da0741f0674d7d5740cc057e7 100644 (file)
@@ -28,7 +28,7 @@ class Contacts extends BaseModule
 
                //@TODO: Get value from router parameters
                $nickname = $a->argv[1];
-               $type = defaults($a->argv, 3, 'all');
+               $type = ($a->argv[3] ?? '') ?: 'all';
 
                Nav::setSelected('home');
 
index 38a9b17e014b631b718f0d29a7db4a5f30a931c4..2b8ad01ddadfd9cd89346ceec962350850845ff5 100644 (file)
@@ -210,7 +210,7 @@ class Proxy extends BaseModule
                        $url = base64_decode(strtr($url, '-_', '+/'), true);
 
                } else {
-                       $url = defaults($_REQUEST, 'url', '');
+                       $url = $_REQUEST['url'] ?? '';
                }
 
                return [
index 367eeb5adee31f84fa039afe5e65efb8055719d8..03f9dbb69871dd44fb666b778fabede9aa6a2cfd 100644 (file)
@@ -62,12 +62,12 @@ class Register extends BaseModule
                        }
                }
 
-               $username   = defaults($_REQUEST, 'username'  , '');
-               $email      = defaults($_REQUEST, 'email'     , '');
-               $openid_url = defaults($_REQUEST, 'openid_url', '');
-               $nickname   = defaults($_REQUEST, 'nickname'  , '');
-               $photo      = defaults($_REQUEST, 'photo'     , '');
-               $invite_id  = defaults($_REQUEST, 'invite_id' , '');
+               $username   = $_REQUEST['username']   ?? '';
+               $email      = $_REQUEST['email']      ?? '';
+               $openid_url = $_REQUEST['openid_url'] ?? '';
+               $nickname   = $_REQUEST['nickname']   ?? '';
+               $photo      = $_REQUEST['photo']      ?? '';
+               $invite_id  = $_REQUEST['invite_id']  ?? '';
 
                if (Config::get('system', 'no_openid')) {
                        $fillwith = '';
@@ -290,7 +290,7 @@ class Register extends BaseModule
                                        'source_photo' => $base_url . '/photo/avatar/' . $user['uid'] . '.jpg',
                                        'to_email'     => $admin['email'],
                                        'uid'          => $admin['uid'],
-                                       'language'     => defaults($admin, 'language', 'en'),
+                                       'language'     => ($admin['language'] ?? '') ?: 'en',
                                        'show_in_notification_page' => false
                                ]);
                        }
index 95ebd1cf74025c1bb31c75f617baa59b49fc2959..1016756008973291dca02bba042ac73454f950fe 100644 (file)
@@ -275,8 +275,8 @@ class Acl extends BaseModule
                                        'id'      => intval($g['id']),
                                        'network' => $g['network'],
                                        'link'    => $g['url'],
-                                       'nick'    => htmlentities(defaults($g, 'attag', $g['nick'])),
-                                       'addr'    => htmlentities(defaults($g, 'addr', $g['url'])),
+                                       'nick'    => htmlentities(($g['attag'] ?? '') ?: $g['nick']),
+                                       'addr'    => htmlentities(($g['addr'] ?? '') ?: $g['url']),
                                        'forum'   => !empty($g['forum']) || !empty($g['prv']) ? 1 : 0,
                                ];
                                if ($entry['forum']) {
@@ -336,8 +336,8 @@ class Acl extends BaseModule
                                                'id'      => intval($contact['cid']),
                                                'network' => $contact['network'],
                                                'link'    => $contact['url'],
-                                               'nick'    => htmlentities(defaults($contact, 'nick', $contact['addr'])),
-                                               'addr'    => htmlentities(defaults($contact, 'addr', $contact['url'])),
+                                               'nick'    => htmlentities(($contact['nick'] ?? '') ?: $contact['addr']),
+                                               'addr'    => htmlentities(($contact['addr'] ?? '') ?: $contact['url']),
                                                'forum'   => $contact['forum']
                                        ];
                                }
index 79b92f159291c2e94d3d434aaf5a33009fa460c2..e7694225c43f9bb3ef607e42bc7bf50d838c1a80 100644 (file)
@@ -26,12 +26,12 @@ class Index extends BaseSettingsModule
                self::checkFormSecurityTokenRedirectOnError('settings/2fa', 'settings_2fa');
 
                try {
-                       User::getIdFromPasswordAuthentication(local_user(), defaults($_POST, 'password', ''));
+                       User::getIdFromPasswordAuthentication(local_user(), $_POST['password'] ?? '');
 
                        $has_secret = (bool) PConfig::get(local_user(), '2fa', 'secret');
                        $verified = PConfig::get(local_user(), '2fa', 'verified');
 
-                       switch (defaults($_POST, 'action', '')) {
+                       switch ($_POST['action'] ?? '') {
                                case 'enable':
                                        if (!$has_secret && !$verified) {
                                                $Google2FA = new Google2FA();
index caed464ecea8200fd10cd3a9c2642961190f3b52..b9205852d835199170a6ac79c2a14d2c5d91ebcd 100644 (file)
@@ -49,12 +49,12 @@ class Verify extends BaseSettingsModule
                        return;
                }
 
-               if (defaults($_POST, 'action', null) == 'verify') {
+               if (($_POST['action'] ?? '') == 'verify') {
                        self::checkFormSecurityTokenRedirectOnError('settings/2fa/verify', 'settings_2fa_verify');
 
                        $google2fa = new Google2FA();
 
-                       $valid = $google2fa->verifyKey(PConfig::get(local_user(), '2fa', 'secret'), defaults($_POST, 'verify_code', ''));
+                       $valid = $google2fa->verifyKey(PConfig::get(local_user(), '2fa', 'secret'), $_POST['verify_code'] ?? '');
 
                        if ($valid) {
                                PConfig::set(local_user(), '2fa', 'verified', true);
index 422f37d3e54bbb40df037546c347a954120d60a5..ded58768fe347cf7f6913eb4a00c3c8e66637abf 100644 (file)
@@ -29,7 +29,7 @@ class Smilies extends BaseModule
        public static function content()
        {
                $smilies = Content\Smilies::getList();
-               $count = count(defaults($smilies, 'texts', []));
+               $count = count($smilies['texts'] ?? []);
 
                $tpl = Renderer::getMarkupTemplate('smilies.tpl');
                return Renderer::replaceMacros($tpl, [
index 6446ec38cb3bc764cbba57504204e787dd3a1486..36c770fba78d356493cdd809f2f4230d02c8c1c4 100644 (file)
@@ -36,7 +36,7 @@ class HTTPException
                        500 => L10n::t('Internal Server Error'),
                        503 => L10n::t('Service Unavailable'),
                ];
-               $title = defaults($titles, $e->getCode(), 'Error ' . $e->getCode());
+               $title = ($titles[$e->getCode()] ?? '') ?: 'Error ' . $e->getCode();
 
                if (empty($message)) {
                        // Explanations are taken from https://en.wikipedia.org/wiki/List_of_HTTP_status_codes
@@ -49,7 +49,7 @@ class HTTPException
                                503 => L10n::t('The server is currently unavailable (because it is overloaded or down for maintenance). Please try again later.'),
                        ];
 
-                       $message = defaults($explanation, $e->getCode(), '');
+                       $message = $explanation[$e->getCode()] ?? '';
                }
 
                return ['$title' => $title, '$message' => $message, '$back' => L10n::t('Go back')];
index df7da40992ddd88ee6bc989a1590a308298d922c..70cd3973518a81584604b2ef68439701a5fcfb7e 100644 (file)
@@ -41,7 +41,7 @@ class Starred extends BaseModule
                Item::update(['starred' => $starred], ['id' => $itemId]);
 
                // See if we've been passed a return path to redirect to
-               $returnPath = defaults($_REQUEST, 'return', '');
+               $returnPath = $_REQUEST['return'] ?? '';
                if ($returnPath) {
                        $rand = '_=' . time();
                        if (strpos($returnPath, '?')) {
index 7b53d1cfde928f89cbf9fa92b536af59d455db7b..9a2e913bcad00e7cd58144b226eb65ddbcc95f89 100644 (file)
@@ -17,9 +17,9 @@ class ThemeDetails extends BaseModule
                        $info = Theme::getInfo($theme);
 
                        // Unfortunately there will be no translation for this string
-                       $description = defaults($info, 'description', '');
-                       $version     = defaults($info, 'version'    , '');
-                       $credits     = defaults($info, 'credits'    , '');
+                       $description = $info['description'] ?? '';
+                       $version     = $info['version']     ?? '';
+                       $credits     = $info['credits']     ?? '';
 
                        echo json_encode([
                                'img'     => Theme::getScreenshot($theme),
index 60f443c35ffe88bc54cf0658c52625c8b394f40d..7c17fdace028893003c69bfd61057522b810d38e 100644 (file)
@@ -28,12 +28,12 @@ class Recovery extends BaseModule
                        return;
                }
 
-               if (defaults($_POST, 'action', null) == 'recover') {
+               if (($_POST['action'] ?? '') == 'recover') {
                        self::checkFormSecurityTokenRedirectOnError('2fa', 'twofactor_recovery');
 
                        $a = self::getApp();
 
-                       $recovery_code = defaults($_POST, 'recovery_code', '');
+                       $recovery_code = $_POST['recovery_code'] ?? '';
 
                        if (RecoveryCode::existsForUser(local_user(), $recovery_code)) {
                                RecoveryCode::markUsedForUser(local_user(), $recovery_code);
index ae020d35546add6ee2b72c823960c76dbea50b56..5e108c3b53bbd3ead765995e3ab6c5afcf2297e0 100644 (file)
@@ -28,7 +28,7 @@ class Xrd extends BaseModule
                        }
 
                        $uri = urldecode(Strings::escapeTags(trim($_GET['uri'])));
-                       if (defaults($_SERVER, 'HTTP_ACCEPT', '') == 'application/jrd+json') {
+                       if (($_SERVER['HTTP_ACCEPT'] ?? '') == 'application/jrd+json') {
                                $mode = 'json';
                        } else {
                                $mode = 'xml';
@@ -39,7 +39,7 @@ class Xrd extends BaseModule
                        }
 
                        $uri = urldecode(Strings::escapeTags(trim($_GET['resource'])));
-                       if (defaults($_SERVER, 'HTTP_ACCEPT', '') == 'application/xrd+xml') {
+                       if (($_SERVER['HTTP_ACCEPT'] ?? '') == 'application/xrd+xml') {
                                $mode = 'xml';
                        } else {
                                $mode = 'json';
index c12bb28266a35d09d9afe92244ed6c9d18cecf13..5b77c3963c7e69e7593107f0c69f8d6d5f2d7877 100644 (file)
@@ -167,7 +167,7 @@ class CurlResult
                }
 
                if ($this->returnCode == 301 || $this->returnCode == 302 || $this->returnCode == 303 || $this->returnCode== 307) {
-                       $redirect_parts = parse_url(defaults($this->info, 'redirect_url', ''));
+                       $redirect_parts = parse_url($this->info['redirect_url'] ?? '');
                        if (empty($redirect_parts)) {
                                $redirect_parts = [];
                        }
@@ -179,7 +179,7 @@ class CurlResult
                                }
                        }
 
-                       $parts = parse_url(defaults($this->info, 'url', ''));
+                       $parts = parse_url($this->info['url'] ?? '');
                        if (empty($parts)) {
                                $parts = [];
                        }
index 3f10895c3c5c8874054066735ef4b259061da1ab..d6ea766312a226ad2ea7679330da3b726322a0e3 100644 (file)
@@ -348,7 +348,7 @@ class Probe
                if (!self::$istimeout) {
                        $ap_profile = ActivityPub::probeProfile($uri);
 
-                       if (empty($data) || (!empty($ap_profile) && empty($network) && (defaults($data, 'network', '') != Protocol::DFRN))) {
+                       if (empty($data) || (!empty($ap_profile) && empty($network) && (($data['network'] ?? '') == Protocol::DFRN))) {
                                $data = $ap_profile;
                        } elseif (!empty($ap_profile)) {
                                $ap_profile['batch'] = '';
@@ -363,7 +363,7 @@ class Probe
                }
 
                if (!empty($data['photo'])) {
-                       $data['baseurl'] = Network::getUrlMatch(Strings::normaliseLink(defaults($data, 'baseurl', '')), Strings::normaliseLink($data['photo']));
+                       $data['baseurl'] = Network::getUrlMatch(Strings::normaliseLink($data['baseurl'] ?? ''), Strings::normaliseLink($data['photo']));
                } else {
                        $data['photo'] = System::baseUrl() . '/images/person-300.jpg';
                }
@@ -424,7 +424,7 @@ class Probe
                }
 
                // If the file is too large then exit
-               if (defaults($curlResult->getInfo(), 'download_content_length', 0) > 1000000) {
+               if (($curlResult->getInfo()['download_content_length'] ?? 0) > 1000000) {
                        return false;
                }
 
@@ -547,7 +547,7 @@ class Probe
                                return [];
                        }
 
-                       $path_parts = explode("/", trim(defaults($parts, 'path', ''), "/"));
+                       $path_parts = explode("/", trim($parts['path'] ?? '', "/"));
 
                        while (!$lrdd && (sizeof($path_parts) > 1)) {
                                $host .= "/".array_shift($path_parts);
@@ -921,19 +921,19 @@ class Probe
 
                if (empty($data["addr"]) || empty($data["nick"])) {
                        $probe_data = self::uri($profile_link);
-                       $data["addr"] = defaults($data, "addr", $probe_data["addr"]);
-                       $data["nick"] = defaults($data, "nick", $probe_data["nick"]);
+                       $data["addr"] = ($data["addr"] ?? '') ?: $probe_data["addr"];
+                       $data["nick"] = ($data["nick"] ?? '') ?: $probe_data["nick"];
                }
 
                $prof_data["addr"]         = $data["addr"];
                $prof_data["nick"]         = $data["nick"];
-               $prof_data["dfrn-request"] = defaults($data, 'request', null);
-               $prof_data["dfrn-confirm"] = defaults($data, 'confirm', null);
-               $prof_data["dfrn-notify"]  = defaults($data, 'notify' , null);
-               $prof_data["dfrn-poll"]    = defaults($data, 'poll'   , null);
-               $prof_data["photo"]        = defaults($data, 'photo'  , null);
-               $prof_data["fn"]           = defaults($data, 'name'   , null);
-               $prof_data["key"]          = defaults($data, 'pubkey' , null);
+               $prof_data["dfrn-request"] = $data['request'] ?? null;
+               $prof_data["dfrn-confirm"] = $data['confirm'] ?? null;
+               $prof_data["dfrn-notify"]  = $data['notify']  ?? null;
+               $prof_data["dfrn-poll"]    = $data['poll']    ?? null;
+               $prof_data["photo"]        = $data['photo']   ?? null;
+               $prof_data["fn"]           = $data['name']    ?? null;
+               $prof_data["key"]          = $data['pubkey']  ?? null;
 
                Logger::log("Result for profile ".$profile_link.": ".print_r($prof_data, true), Logger::DEBUG);
 
@@ -959,7 +959,7 @@ class Probe
                                $data["network"] = Protocol::DFRN;
                        } elseif (($link["rel"] == NAMESPACE_FEED) && !empty($link["href"])) {
                                $data["poll"] = $link["href"];
-                       } elseif (($link["rel"] == "http://webfinger.net/rel/profile-page") && (defaults($link, "type", "") == "text/html") && !empty($link["href"])) {
+                       } elseif (($link["rel"] == "http://webfinger.net/rel/profile-page") && (($link["type"] ?? "") == "text/html") && !empty($link["href"])) {
                                $data["url"] = $link["href"];
                        } elseif (($link["rel"] == "http://microformats.org/profile/hcard") && !empty($link["href"])) {
                                $hcard_url = $link["href"];
@@ -1169,7 +1169,7 @@ class Probe
                                $data["baseurl"] = trim($link["href"], '/');
                        } elseif (($link["rel"] == "http://joindiaspora.com/guid") && !empty($link["href"])) {
                                $data["guid"] = $link["href"];
-                       } elseif (($link["rel"] == "http://webfinger.net/rel/profile-page") && (defaults($link, "type", "") == "text/html") && !empty($link["href"])) {
+                       } elseif (($link["rel"] == "http://webfinger.net/rel/profile-page") && (($link["type"] ?? "") == "text/html") && !empty($link["href"])) {
                                $data["url"] = $link["href"];
                        } elseif (($link["rel"] == NAMESPACE_FEED) && !empty($link["href"])) {
                                $data["poll"] = $link["href"];
@@ -1267,7 +1267,7 @@ class Probe
                        // See: https://tools.ietf.org/html/rfc7033#section-4.4.4
                        foreach (array_reverse($webfinger["links"]) as $link) {
                                if (($link["rel"] == "http://webfinger.net/rel/profile-page")
-                                       && (defaults($link, "type", "") == "text/html")
+                                       && (($link["type"] ?? "") == "text/html")
                                        && ($link["href"] != "")
                                ) {
                                        $data["url"] = $link["href"];
@@ -1436,7 +1436,7 @@ class Probe
                // See: https://tools.ietf.org/html/rfc7033#section-4.4.4
                foreach (array_reverse($webfinger["links"]) as $link) {
                        if (($link["rel"] == "http://webfinger.net/rel/profile-page")
-                               && (defaults($link, "type", "") == "text/html")
+                               && (($link["type"] ?? "") == "text/html")
                                && ($link["href"] != "")
                        ) {
                                $data["url"] = $link["href"];
index 2ef53d075ce1c467770539a3a145a569ced16803..04775bbd0e2f964c3a3a3b6202e7c4d85e85b467 100644 (file)
@@ -805,7 +805,7 @@ class Post extends BaseObject
                $terms = Term::tagArrayFromItemId($this->getId(), [Term::MENTION, Term::IMPLICIT_MENTION]);
                foreach ($terms as $term) {
                        $profile = Contact::getDetailsByURL($term['url']);
-                       if (!empty($profile['addr']) && (defaults($profile, 'contact-type', Contact::TYPE_UNKNOWN) != Contact::TYPE_COMMUNITY) &&
+                       if (!empty($profile['addr']) && ((($profile['contact-type'] ?? '') ?: Contact::TYPE_UNKNOWN) != Contact::TYPE_COMMUNITY) &&
                                ($profile['addr'] != $owner['addr']) && !strstr($text, $profile['addr'])) {
                                $text .= '@' . $profile['addr'] . ' ';
                        }
index 3a8a5e5b12ab82c7552b86d72eb1fd4b0aed1816..522fee97eff2706023993de7261570cdad2b09e3 100644 (file)
@@ -57,8 +57,8 @@ class ActivityPub
         */
        public static function isRequest()
        {
-               return stristr(defaults($_SERVER, 'HTTP_ACCEPT', ''), 'application/activity+json') ||
-                       stristr(defaults($_SERVER, 'HTTP_ACCEPT', ''), 'application/ld+json');
+               return stristr($_SERVER['HTTP_ACCEPT'] ?? '', 'application/activity+json') ||
+                       stristr($_SERVER['HTTP_ACCEPT'] ?? '', 'application/ld+json');
        }
 
        /**
index 7639d0f2a325d97ee6dc3ea6a9f2fb48a4f0d6b4..50e8dd91e8f5ec6726750d263c4ca99b341a2812 100644 (file)
@@ -75,7 +75,7 @@ class Processor
 
                $tag_text = '';
                foreach ($tags as $tag) {
-                       if (in_array(defaults($tag, 'type', ''), ['Mention', 'Hashtag'])) {
+                       if (in_array($tag['type'] ?? '', ['Mention', 'Hashtag'])) {
                                if (!empty($tag_text)) {
                                        $tag_text .= ',';
                                }
@@ -125,7 +125,7 @@ class Processor
                                if (!isset($attach['length'])) {
                                        $attach['length'] = "0";
                                }
-                               $item["attach"] .= '[attach]href="'.$attach['url'].'" length="'.$attach['length'].'" type="'.$attach['mediaType'].'" title="'.defaults($attach, 'name', '').'"[/attach]';
+                               $item["attach"] .= '[attach]href="'.$attach['url'].'" length="'.$attach['length'].'" type="'.$attach['mediaType'].'" title="'.($attach['name'] ?? '') .'"[/attach]';
                        }
                }
 
@@ -183,7 +183,7 @@ class Processor
                        self::fetchMissingActivity($activity['reply-to-id'], $activity);
                }
 
-               $item['diaspora_signed_text'] = defaults($activity, 'diaspora:comment', '');
+               $item['diaspora_signed_text'] = $activity['diaspora:comment'] ?? '';
 
                self::postItem($activity, $item);
        }
@@ -256,7 +256,7 @@ class Processor
                $item['gravity'] = GRAVITY_ACTIVITY;
                $item['object-type'] = ACTIVITY_OBJ_NOTE;
 
-               $item['diaspora_signed_text'] = defaults($activity, 'diaspora:like', '');
+               $item['diaspora_signed_text'] = $activity['diaspora:like'] ?? '';
 
                self::postItem($activity, $item);
        }
@@ -404,7 +404,7 @@ class Processor
                        return;
                }
 
-               $item['plink'] = defaults($activity, 'alternate-url', $item['uri']);
+               $item['plink'] = $activity['alternate-url'] ?? $item['uri'];
 
                $item = self::constructAttachList($activity['attachments'], $item, !empty($activity['source']));
 
@@ -583,8 +583,8 @@ class Processor
                $activity['@context'] = $object['@context'];
                unset($object['@context']);
                $activity['id'] = $object['id'];
-               $activity['to'] = defaults($object, 'to', []);
-               $activity['cc'] = defaults($object, 'cc', []);
+               $activity['to'] = $object['to'] ?? [];
+               $activity['cc'] = $object['cc'] ?? [];
                $activity['actor'] = $actor;
                $activity['object'] = $object;
                $activity['published'] = $published;
@@ -628,7 +628,7 @@ class Processor
                $item = ['author-id' => Contact::getIdForURL($activity['actor']),
                        'author-link' => $activity['actor']];
 
-               $note = Strings::escapeTags(trim(defaults($activity, 'content', '')));
+               $note = Strings::escapeTags(trim($activity['content'] ?? ''));
 
                // Ensure that the contact has got the right network type
                self::switchContact($item['author-id']);
@@ -893,7 +893,7 @@ class Processor
 
                // Extract one prepended mention at a time from the body
                while(preg_match('#^(@\[url=([^\]]+)].*?\[\/url]\s)(.*)#is', $body, $matches)) {
-                       if (!in_array($matches[2], $potential_mentions) ) {
+                       if (!in_array($matches[2], $potential_mentions)) {
                                $kept_mentions[] = $matches[1];
                        }
 
index 058d210a24072d484d799a9ff2f4933e2c29cce3..f23269615e566836ace45a78425d5474c7ba7c73 100644 (file)
@@ -46,8 +46,8 @@ class Receiver
         */
        public static function isRequest()
        {
-               return stristr(defaults($_SERVER, 'HTTP_ACCEPT', ''), 'application/activity+json') ||
-                       stristr(defaults($_SERVER, 'HTTP_ACCEPT', ''), 'application/ld+json');
+               return stristr($_SERVER['HTTP_ACCEPT'] ?? '', 'application/activity+json') ||
+                       stristr($_SERVER['HTTP_ACCEPT'] ?? '', 'application/ld+json');
        }
 
        /**
@@ -260,7 +260,7 @@ class Receiver
                $object_data['type'] = $type;
                $object_data['actor'] = $actor;
                $object_data['item_receiver'] = $receivers;
-               $object_data['receiver'] = array_merge(defaults($object_data, 'receiver', []), $receivers);
+               $object_data['receiver'] = array_merge($object_data['receiver'] ?? [], $receivers);
 
                Logger::log('Processing ' . $object_data['type'] . ' ' . $object_data['object_type'] . ' ' . $object_data['id'], Logger::DEBUG);
 
@@ -301,9 +301,9 @@ class Receiver
                $conversation = [
                        'protocol' => Conversation::PARCEL_ACTIVITYPUB,
                        'item-uri' => $activity['id'],
-                       'reply-to-uri' => defaults($activity, 'reply-to-id', ''),
-                       'conversation-href' => defaults($activity, 'context', ''),
-                       'conversation-uri' => defaults($activity, 'conversation', ''),
+                       'reply-to-uri' => $activity['reply-to-id'] ?? '',
+                       'conversation-href' => $activity['context'] ?? '',
+                       'conversation-uri' => $activity['conversation'] ?? '',
                        'source' => $body,
                        'received' => DateTimeFormat::utcNow()];
 
@@ -508,7 +508,7 @@ class Receiver
 
                if (!empty($actor)) {
                        $profile = APContact::getByURL($actor);
-                       $followers = defaults($profile, 'followers', '');
+                       $followers = $profile['followers'] ?? '';
 
                        Logger::log('Actor: ' . $actor . ' - Followers: ' . $followers, Logger::DEBUG);
                } else {
index 19c0cc28ed9257b072761de746d545ed83a14ba6..d2581ff3f45e9f929692b399e59f1dce222b12b1 100644 (file)
@@ -71,6 +71,7 @@ class Transmitter
                if (empty($page)) {
                        $data['first'] = System::baseUrl() . '/followers/' . $owner['nickname'] . '?page=1';
                } else {
+                       $data['type'] = 'OrderedCollectionPage';
                        $list = [];
 
                        $contacts = DBA::select('contact', ['url'], $condition, ['limit' => [($page - 1) * 100, 100]]);
@@ -119,6 +120,7 @@ class Transmitter
                if (empty($page)) {
                        $data['first'] = System::baseUrl() . '/following/' . $owner['nickname'] . '?page=1';
                } else {
+                       $data['type'] = 'OrderedCollectionPage';
                        $list = [];
 
                        $contacts = DBA::select('contact', ['url'], $condition, ['limit' => [($page - 1) * 100, 100]]);
@@ -165,6 +167,7 @@ class Transmitter
                if (empty($page)) {
                        $data['first'] = System::baseUrl() . '/outbox/' . $owner['nickname'] . '?page=1';
                } else {
+                       $data['type'] = 'OrderedCollectionPage';
                        $list = [];
 
                        $condition['parent-network'] = Protocol::NATIVE_SUPPORT;
index 7dee12b56ca498d0bdb61f9c177a0f774b59859c..d557af0692fb761db121bb815a59f93bf024aa8b 100644 (file)
@@ -119,8 +119,8 @@ class DFRN
                foreach ($items as $item) {
                        // These values aren't sent when sending from the queue.
                        /// @todo Check if we can set these values from the queue or if they are needed at all.
-                       $item["entry:comment-allow"] = defaults($item, "entry:comment-allow", true);
-                       $item["entry:cid"] = defaults($item, "entry:cid", 0);
+                       $item["entry:comment-allow"] = ($item["entry:comment-allow"] ?? '') ?: true;
+                       $item["entry:cid"] = $item["entry:cid"] ?? 0;
 
                        $entry = self::entry($doc, "text", $item, $owner, $item["entry:comment-allow"], $item["entry:cid"]);
                        if (isset($entry)) {
@@ -1259,7 +1259,7 @@ class DFRN
                $sent_dfrn_id = hex2bin((string) $res->dfrn_id);
                $challenge    = hex2bin((string) $res->challenge);
                $perm         = (($res->perm) ? $res->perm : null);
-               $dfrn_version = (float) (($res->dfrn_version) ? $res->dfrn_version : 2.0);
+               $dfrn_version = floatval($res->dfrn_version ?: 2.0);
                $rino_remote_version = intval($res->rino);
                $page         = (($owner['page-flags'] == User::PAGE_FLAGS_COMMUNITY) ? 1 : 0);
 
@@ -2019,8 +2019,8 @@ class DFRN
                                return false;
                        }
 
-                       $fields = ['title' => defaults($item, 'title', ''), 'body' => defaults($item, 'body', ''),
-                                       'tag' => defaults($item, 'tag', ''), 'changed' => DateTimeFormat::utcNow(),
+                       $fields = ['title' => $item['title'] ?? '', 'body' => $item['body'] ?? '',
+                                       'tag' => $item['tag'] ?? '', 'changed' => DateTimeFormat::utcNow(),
                                        'edited' => DateTimeFormat::utc($item["edited"])];
 
                        $condition = ["`uri` = ? AND `uid` IN (0, ?)", $item["uri"], $importer["importer_uid"]];
index a6090ce91f6a75dd9101bec6927bf394749ec87a..06cf8612502ae65679019ef197acbfafa96f6570 100644 (file)
@@ -544,7 +544,7 @@ class Email
                        }
 
                        $quotelevel = 0;
-                       $nextline = trim(defaults($arrbody, $i + 1, ''));
+                       $nextline = trim($arrbody[$i + 1] ?? '');
                        while ((strlen($nextline)>0) && ((substr($nextline, 0, 1) == '>')
                                || (substr($nextline, 0, 1) == ' '))) {
                                if (substr($nextline, 0, 1) == '>') {
index 054eaf51b2812939153424fa80058c9485ee18d9..afd406f972f27cc154771e0d3cf3e78c5d99e02d 100644 (file)
@@ -74,7 +74,7 @@ class OStatus
                }
                $author["author-id"] = Contact::getIdForURL($author["author-link"]);
 
-               $author['contact-id'] = defaults($contact, 'id', $author['author-id']);
+               $author['contact-id'] = ($contact['id'] ?? 0) ?: $author['author-id'];
 
                $contact = [];
 
@@ -1131,7 +1131,7 @@ class OStatus
                                                        if (!isset($attribute['length'])) {
                                                                $attribute['length'] = "0";
                                                        }
-                                                       $item["attach"] .= '[attach]href="'.$attribute['href'].'" length="'.$attribute['length'].'" type="'.$attribute['type'].'" title="'.defaults($attribute, 'title', '').'"[/attach]';
+                                                       $item["attach"] .= '[attach]href="'.$attribute['href'].'" length="'.$attribute['length'].'" type="'.$attribute['type'].'" title="'.($attribute['title'] ?? '') .'"[/attach]';
                                                }
                                                break;
                                        case "related":
@@ -1403,7 +1403,8 @@ class OStatus
                                                "href" => $siteinfo["url"],
                                                "type" => "text/html; charset=UTF-8",
                                                "length" => "",
-                                               "title" => defaults($siteinfo, "title", $siteinfo["url"])];
+                                               "title" => ($siteinfo["title"] ?? '') ?: $siteinfo["url"],
+                               ];
                                XML::addElement($doc, $root, "link", "", $attributes);
                                break;
                        default:
index 4310046c234411b1f6fd6907f8613a4075ebc7c3..d7ca234a98da82d7287f344f9bfd4929ba61044d 100644 (file)
@@ -57,7 +57,7 @@ class Emailer
                                .rand(10000, 99999);
 
                // generate a multipart/alternative message header
-               $messageHeader = defaults($params, 'additionalMailHeader', '') .
+               $messageHeader = ($params['additionalMailHeader'] ?? '') .
                                                "From: $fromName <{$params['fromEmail']}>\n" .
                                                "Reply-To: $fromName <{$params['replyTo']}>\n" .
                                                "MIME-Version: 1.0\n" .
index 83c3fc3ce57e8707ebc4891fb7e564fba199eb65..7ef4f6b27a81b3b66d81b9cf74db873fcf4761fb 100644 (file)
@@ -111,7 +111,7 @@ class SyslogLogger extends AbstractLogger
        }
 
        /**
-        * Maps the LogLevel (@see LogLevel ) to a SysLog priority (@see http://php.net/manual/en/function.syslog.php#refsect1-function.syslog-parameters )
+        * Maps the LogLevel (@see LogLevel) to a SysLog priority (@see http://php.net/manual/en/function.syslog.php#refsect1-function.syslog-parameters)
         *
         * @param string $level A LogLevel
         *
index cd66abe0b2864b019341bd15139fc3dd68f198d4..f222dc22df0b735af42158d5f4e0350dcfe95da1 100644 (file)
@@ -104,7 +104,7 @@ class Network
 
                $parts2 = [];
                $parts = parse_url($url);
-               $path_parts = explode('/', defaults($parts, 'path', ''));
+               $path_parts = explode('/', $parts['path'] ?? '');
                foreach ($path_parts as $part) {
                        if (strlen($part) <> mb_strlen($part)) {
                                $parts2[] = rawurlencode($part);
@@ -285,16 +285,6 @@ class Network
                        curl_setopt($ch, CURLOPT_TIMEOUT, intval($curl_time));
                }
 
-               if (defined('LIGHTTPD')) {
-                       if (empty($headers)) {
-                               $headers = ['Expect:'];
-                       } else {
-                               if (!in_array('Expect:', $headers)) {
-                                       array_push($headers, 'Expect:');
-                               }
-                       }
-               }
-
                if (!empty($headers)) {
                        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
                }
@@ -337,6 +327,21 @@ class Network
 
                $a->getProfiler()->saveTimestamp($stamp1, 'network', System::callstack());
 
+               // Very old versions of Lighttpd don't like the "Expect" header, so we remove it when needed
+               if ($curlResponse->getReturnCode() == 417) {
+                       $redirects++;
+
+                       if (empty($headers)) {
+                               $headers = ['Expect:'];
+                       } else {
+                               if (!in_array('Expect:', $headers)) {
+                                       array_push($headers, 'Expect:');
+                               }
+                       }
+                       Logger::info('Server responds with 417, applying workaround', ['url' => $url]);
+                       return self::post($url, $params, $headers, $redirects, $timeout);
+               }
+
                Logger::log('post_url: end ' . $url, Logger::DATA);
 
                return $curlResponse;
@@ -380,7 +385,7 @@ class Network
                /// @TODO Really suppress function outcomes? Why not find them + debug them?
                $h = @parse_url($url);
 
-               if (!empty($h['host']) && (@dns_get_record($h['host'], DNS_A + DNS_CNAME) || filter_var($h['host'], FILTER_VALIDATE_IP) )) {
+               if (!empty($h['host']) && (@dns_get_record($h['host'], DNS_A + DNS_CNAME) || filter_var($h['host'], FILTER_VALIDATE_IP))) {
                        return $url;
                }
 
@@ -406,7 +411,7 @@ class Network
                $h = substr($addr, strpos($addr, '@') + 1);
 
                // Concerning the @ see here: https://stackoverflow.com/questions/36280957/dns-get-record-a-temporary-server-error-occurred
-               if ($h && (@dns_get_record($h, DNS_A + DNS_MX) || filter_var($h, FILTER_VALIDATE_IP) )) {
+               if ($h && (@dns_get_record($h, DNS_A + DNS_MX) || filter_var($h, FILTER_VALIDATE_IP))) {
                        return true;
                }
                if ($h && @dns_get_record($h, DNS_CNAME + DNS_MX)) {
@@ -801,8 +806,8 @@ class Network
                $i = 0;
                $path = "";
                do {
-                       $path1 = defaults($pathparts1, $i, '');
-                       $path2 = defaults($pathparts2, $i, '');
+                       $path1 = $pathparts1[$i] ?? '';
+                       $path2 = $pathparts2[$i] ?? '';
 
                        if ($path1 == $path2) {
                                $path .= $path1."/";
index 9a3de88cf2ac789d5866edf28d41e35bdf6c412e..4590f39a99cfa83aa813199619ce0323eff8d47f 100644 (file)
@@ -141,7 +141,7 @@ class ParseUrl
                }
 
                // If the file is too large then exit
-               if (defaults($curlResult->getInfo(), 'download_content_length', 0) > 1000000) {
+               if (($curlResult->getInfo()['download_content_length'] ?? 0) > 1000000) {
                        return $siteinfo;
                }
 
index dc140469c671e945e42408a1b41ff5bd67fd14f9..e745a8bbdf001e528cb5735a411698b8b43e0436 100644 (file)
@@ -13,7 +13,7 @@ use Psr\Log\LoggerInterface;
  * A class to store profiling data
  * It can handle different logging data for specific functions or global performance measures
  *
- * It stores the data as log entries (@see LoggerInterface )
+ * It stores the data as log entries (@see LoggerInterface)
  */
 class Profiler implements ContainerInterface
 {
@@ -79,7 +79,7 @@ class Profiler implements ContainerInterface
                        return;
                }
 
-               $duration = (float) (microtime(true) - $timestamp);
+               $duration = floatval(microtime(true) - $timestamp);
 
                if (!isset($this->performance[$value])) {
                        // Prevent ugly E_NOTICE
index 8652885630d5693543933d4a9a2427d8e6a81827..fbc8fb8b25a21013c1447e33fc040a7e4d3ae9d4 100644 (file)
@@ -250,7 +250,7 @@ class Delivery extends BaseObject
         */
        private static function deliverDFRN($cmd, $contact, $owner, $items, $target_item, $public_message, $top_level, $followup)
        {
-               Logger::log('Deliver ' . defaults($target_item, 'guid', $target_item['id']) . ' via DFRN to ' . (empty($contact['addr']) ? $contact['url'] : $contact['addr']));
+               Logger::info('Deliver ' . (($target_item['guid'] ?? '') ?: $target_item['id']) . ' via DFRN to ' . (($contact['addr'] ?? '') ?: $contact['url']));
 
                if ($cmd == self::MAIL) {
                        $item = $target_item;
@@ -278,7 +278,7 @@ class Delivery extends BaseObject
                        $atom = DFRN::entries($msgitems, $owner);
                }
 
-               Logger::log('Notifier entry: ' . $contact["url"] . ' ' . defaults($target_item, 'guid', $target_item['id']) . ' entry: ' . $atom, Logger::DATA);
+               Logger::debug('Notifier entry: ' . $contact["url"] . ' ' . (($target_item['guid'] ?? '') ?: $target_item['id']) . ' entry: ' . $atom);
 
                $basepath =  implode('/', array_slice(explode('/', $contact['url']), 0, 3));
 
@@ -329,7 +329,7 @@ class Delivery extends BaseObject
 
                        // We never spool failed relay deliveries
                        if ($public_dfrn) {
-                               Logger::log('Relay delivery to ' . $contact["url"] . ' with guid ' . $target_item["guid"] . ' returns ' . $deliver_status);
+                               Logger::info('Relay delivery to ' . $contact["url"] . ' with guid ' . $target_item["guid"] . ' returns ' . $deliver_status);
 
                                if (in_array($cmd, [Delivery::POST, Delivery::POKE])) {
                                        if (($deliver_status >= 200) && ($deliver_status <= 299)) {
@@ -359,7 +359,7 @@ class Delivery extends BaseObject
                        $protocol = Model\ItemDeliveryData::LEGACY_DFRN;
                }
 
-               Logger::info('DFRN Delivery', ['cmd' => $cmd, 'url' => $contact['url'], 'guid' => defaults($target_item, 'guid', $target_item['id']), 'return' => $deliver_status]);
+               Logger::info('DFRN Delivery', ['cmd' => $cmd, 'url' => $contact['url'], 'guid' => ($target_item['guid'] ?? '') ?: $target_item['id'], 'return' => $deliver_status]);
 
                if (($deliver_status >= 200) && ($deliver_status <= 299)) {
                        // We successfully delivered a message, the contact is alive
@@ -372,7 +372,7 @@ class Delivery extends BaseObject
                        // The message could not be delivered. We mark the contact as "dead"
                        Model\Contact::markForArchival($contact);
 
-                       Logger::info('Delivery failed: defer message', ['id' => defaults($target_item, 'guid', $target_item['id'])]);
+                       Logger::info('Delivery failed: defer message', ['id' => ($target_item['guid'] ?? '') ?: $target_item['id']]);
                        if (!Worker::defer() && in_array($cmd, [Delivery::POST, Delivery::POKE])) {
                                Model\ItemDeliveryData::incrementQueueFailed($target_item['id']);
                        }
@@ -463,7 +463,7 @@ class Delivery extends BaseObject
                        }
 
                        if (empty($contact['contact-type']) || ($contact['contact-type'] != Model\Contact::TYPE_RELAY)) {
-                               Logger::info('Delivery failed: defer message', ['id' => defaults($target_item, 'guid', $target_item['id'])]);
+                               Logger::info('Delivery failed: defer message', ['id' => ($target_item['guid'] ?? '') ?: $target_item['id']]);
                                // defer message for redelivery
                                if (!Worker::defer() && in_array($cmd, [Delivery::POST, Delivery::POKE])) {
                                        Model\ItemDeliveryData::incrementQueueFailed($target_item['id']);
index 3c71363470a6d8b18b4c57ad41f024186e4ec527..415c8f3ae23077157e8822eda840855efa9df51b 100644 (file)
@@ -35,7 +35,7 @@ class GProbe {
                        $result = Cache::get("gprobe:".$urlparts["host"]);
                        if (!is_null($result)) {
                                if (in_array($result["network"], [Protocol::FEED, Protocol::PHANTOM])) {
-                                       Logger::log("DDoS attempt detected for ".$urlparts["host"]." by ".defaults($_SERVER, "REMOTE_ADDR", '').". server data: ".print_r($_SERVER, true), Logger::DEBUG);
+                                       Logger::debug("DDoS attempt detected for " . $urlparts["host"] . " by " . ($_SERVER["REMOTE_ADDR"] ?? ''), ['$_SERVER' => $_SERVER]);
                                        return;
                                }
                        }
index c01856384888418080f483d7faa54f56de1462ca..09493eebad3d1e4066e40358bd66390c214e42b4 100644 (file)
@@ -52,7 +52,6 @@
                        <div class="clear"></div>\
                        <hr class="previewseparator">';
                var text;
-               var urlRegex = /^(?:https?\:\/\/|\s)[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})(?:\/+[a-z0-9_.\:\;-]*)*(?:\?[\&\%\|\+a-z0-9_=,\.\:\;-]*)?(?:[\&\%\|\+&a-z0-9_=,\:\;\.-]*)(?:[\!\#\/\&\%\|\+a-z0-9_=,\:\;\.-]*)}*$/i;
                var binurl;
                var block = false;
                var blockTitle = false;
index e2cee43d54464c12b0d07707c208d3ff5a293437..47e7b968d08637d09c459fedd1d048f92f297711 100644 (file)
@@ -86,6 +86,8 @@ var last_popup_menu = null;
 var last_popup_button = null;
 var lockLoadContent = false;
 
+const urlRegex = /^(?:https?:\/\/|\s)[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})(?:\/+[a-z0-9_.:;-]*)*(?:\?[&%|+a-z0-9_=,.:;-]*)?(?:[&%|+&a-z0-9_=,:;.-]*)(?:[!#\/&%|+a-z0-9_=,:;.-]*)}*$/i;
+
 $(function() {
        $.ajaxSetup({cache: false});
 
@@ -404,6 +406,61 @@ $(function() {
        }
 });
 
+/**
+ * Inserts a BBCode tag in the comment textarea identified by id
+ *
+ * @param {string} BBCode
+ * @param {int} id
+ * @returns {boolean}
+ */
+function insertFormatting(BBCode, id) {
+       let textarea = document.getElementById('comment-edit-text-' + id);
+
+       if (textarea.value === '') {
+               $(textarea)
+                       .addClass("comment-edit-text-full")
+                       .removeClass("comment-edit-text-empty");
+               closeMenu("comment-fake-form-" + id);
+               openMenu("item-comments-" + id);
+       }
+
+       insertBBCodeInTextarea(BBCode, textarea);
+
+       return true;
+}
+
+/**
+ * Inserts a BBCode tag in the provided textarea element, wrapping the currently selected text.
+ * For URL BBCode, it discriminates between link text and non-link text to determine where to insert the selected text.
+ *
+ * @param {string} BBCode
+ * @param {HTMLTextAreaElement} textarea
+ */
+function insertBBCodeInTextarea(BBCode, textarea) {
+       let selectionStart = textarea.selectionStart;
+       let selectionEnd = textarea.selectionEnd;
+       let selectedText = textarea.value.substring(selectionStart, selectionEnd);
+       let openingTag = '[' + BBCode + ']';
+       let closingTag = '[/' + BBCode + ']';
+       let cursorPosition = selectionStart + openingTag.length + selectedText.length;
+
+       if (BBCode === 'url') {
+               if (urlRegex.test(selectedText)) {
+                       openingTag = '[' + BBCode + '=' + selectedText + ']';
+                       selectedText = '';
+                       cursorPosition = selectionStart + openingTag.length;
+               } else {
+                       openingTag = '[' + BBCode + '=]';
+                       cursorPosition = selectionStart + openingTag.length - 1;
+               }
+       }
+
+       textarea.value = textarea.value.substring(0, selectionStart) + openingTag + selectedText + closingTag + textarea.value.substring(selectionEnd, textarea.value.length);
+       textarea.setSelectionRange(cursorPosition, cursorPosition);
+       textarea.dispatchEvent(new Event('change'));
+       textarea.focus();
+}
+
 function NavUpdate() {
        if (!stopped) {
                var pingCmd = 'ping?format=json' + ((localUser != 0) ? '&f=&uid=' + localUser : '');
index a5810f2dc131cb06237fbe253b645c8867d970c1..2758ada41451a0f18817f769542566f9f2ca32b3 100644 (file)
@@ -10,7 +10,7 @@ if (file_exists("$THEMEPATH/style.css")) {
        echo file_get_contents("$THEMEPATH/style.css");
 }
 
-$uid = defaults($_REQUEST, 'puid', 0);
+$uid = $_REQUEST['puid'] ?? 0;
 
 $s_colorset = Config::get('duepuntozero', 'colorset');
 $colorset = PConfig::get($uid, 'duepuntozero', 'colorset');
index 015e8090fc7c655dc182590c7e0ef0028988f632..363f6dc487d7fc883776f5e37b967cb31f6a2a72 100644 (file)
@@ -28,28 +28,6 @@ Renderer::setActiveTemplateEngine('smarty3');
     }
 $a->page['htmlhead'] .= <<< EOT
 <script>
-function insertFormatting(BBcode, id) {
-       var tmpStr = $("#comment-edit-text-" + id).val();
-       if (tmpStr == "") {
-               $("#comment-edit-text-" + id).addClass("comment-edit-text-full");
-               $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
-               openMenu("comment-edit-submit-wrapper-" + id);
-       }
-
-       textarea = document.getElementById("comment-edit-text-" +id);
-       if (document.selection) {
-               textarea.focus();
-               selected = document.selection.createRange();
-               selected.text = "["+BBcode+"]" + selected.text + "[/"+BBcode+"]";
-       } else if (textarea.selectionStart || textarea.selectionStart == "0") {
-               var start = textarea.selectionStart;
-               var end = textarea.selectionEnd;
-               textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
-       }
-
-       return true;
-}
-
 function cmtBbOpen(comment, id) {
        if ($(comment).hasClass('comment-edit-text-full')) {
                $(".comment-edit-bb-" + id).show();
index df0f65a6b873e8cd4b301beea015c1e7d5d48333..125081235c8515ab89c0729507c3dc00ab689001 100644 (file)
@@ -132,7 +132,7 @@ function frio_form($arr)
                '$nav_icon_color'   => array_key_exists('nav_icon_color', $disable) ? '' : ['frio_nav_icon_color', L10n::t('Navigation bar icon color '), $arr['nav_icon_color'], '', false],
                '$link_color'       => array_key_exists('link_color', $disable) ? '' : ['frio_link_color', L10n::t('Link color'), $arr['link_color'], '', false],
                '$background_color' => array_key_exists('background_color', $disable) ? '' : ['frio_background_color', L10n::t('Set the background color'), $arr['background_color'], '', false],
-               '$contentbg_transp' => array_key_exists('contentbg_transp', $disable) ? '' : ['frio_contentbg_transp', L10n::t('Content background opacity'), defaults($arr, 'contentbg_transp', 100), ''],
+               '$contentbg_transp' => array_key_exists('contentbg_transp', $disable) ? '' : ['frio_contentbg_transp', L10n::t('Content background opacity'), ($arr['contentbg_transp'] ?? 0) ?: 100, ''],
                '$background_image' => array_key_exists('background_image', $disable) ? '' : ['frio_background_image', L10n::t('Set the background image'), $arr['background_image'], $background_image_help, false],
                '$bg_image_options_title' => L10n::t('Background image style'),
                '$bg_image_options' => Image::get_options($arr),
index 93d7fe8cee5c0a3e81eb10246e7513ab0aea2d64..7ba6a5c0335232dd03b89334cc9febc26e69169a 100644 (file)
@@ -76,45 +76,10 @@ function commentLinkDropper(event) {
        }
 }
 
-
-function insertFormatting(BBcode, id) {
-       var tmpStr = $("#comment-edit-text-" + id).val();
-       if (tmpStr == '') {
-               $("#comment-edit-text-" + id).addClass("comment-edit-text-full");
-               $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
-               closeMenu("comment-fake-form-" + id);
-               openMenu("item-comments-" + id);
-       }
-
-       textarea = document.getElementById("comment-edit-text-" + id);
-       if (document.selection) {
-               textarea.focus();
-               selected = document.selection.createRange();
-               selected.text = "[" + BBcode + "]" + selected.text + "[/" + BBcode + "]";
-       } else if (textarea.selectionStart || textarea.selectionStart == "0") {
-               var start = textarea.selectionStart;
-               var end = textarea.selectionEnd;
-               textarea.value = textarea.value.substring(0, start) + "[" + BBcode + "]" + textarea.value.substring(start, end) + "[/" + BBcode + "]" + textarea.value.substring(end, textarea.value.length);
-       }
-
-       $(textarea).trigger('change');
-
-       return true;
-}
-
-function insertFormattingToPost(BBcode) {
+function insertFormattingToPost(BBCode) {
        textarea = document.getElementById("profile-jot-text");
-       if (document.selection) {
-               textarea.focus();
-               selected = document.selection.createRange();
-               selected.text = "[" + BBcode + "]" + selected.text + "[/" + BBcode + "]";
-       } else if (textarea.selectionStart || textarea.selectionStart == "0") {
-               var start = textarea.selectionStart;
-               var end = textarea.selectionEnd;
-               textarea.value = textarea.value.substring(0, start) + "[" + BBcode + "]" + textarea.value.substring(start, end) + "[/" + BBcode + "]" + textarea.value.substring(end, textarea.value.length);
-       }
 
-       $(textarea).trigger('change');
+       insertBBCodeInTextarea(BBCode, textarea);
 
        return true;
 }
index 22bb995804a474cd032d74f1bb479351fdf7577a..6b39e68acbe078fd47d7186dd24bf93795faa800 100644 (file)
@@ -28,7 +28,7 @@ $is_singleuser_class = $is_singleuser ? "is-singleuser" : "is-not-singleuser";
 <html>
        <head>
                <title><?php if (!empty($page['title'])) echo $page['title'] ?></title>
-               <meta request="<?php echo htmlspecialchars(defaults($_REQUEST, 'pagename', '')) ?>">
+               <meta request="<?php echo htmlspecialchars($_REQUEST['pagename'] ?? '') ?>">
                <script  type="text/javascript">var baseurl = "<?php echo System::baseUrl(); ?>";</script>
                <script type="text/javascript">var frio = "<?php echo 'view/theme/frio'; ?>";</script>
 <?php
@@ -141,7 +141,7 @@ $is_singleuser_class = $is_singleuser ? "is-singleuser" : "is-not-singleuser";
                </main>
 
                <footer>
-                       <?php echo defaults($page, 'footer', ''); ?>
+                       <?php echo $page['footer'] ?? ''; ?>
                </footer>
 <?php } ?> <!-- End of condition if $minimal else the rest -->
        </body>
index dcb87b6d27f160687dfd5f268f9a8c69ab0ee8f6..7ec81a3565785fa34ef7ba0a7dcba971ff8c13b2 100644 (file)
@@ -22,7 +22,7 @@ function load_page(App $a)
                require 'view/theme/frio/none.php';
        } else {
                $template = 'view/theme/' . $a->getCurrentTheme() . '/'
-                       . defaults($a->page, 'template', 'default' ) . '.php';
+                       . (($a->page['template'] ?? '') ?: 'default' ) . '.php';
                if (file_exists($template)) {
                        require_once $template;
                } else {
index e8486653aeb0030c339c38988f7a3d274fd81544..1ab45bd39bacec99eb23683de69706ea2ff8272f 100644 (file)
                <div id="page-footer"></div>\r
        </section>\r
        <!-- Modal  -->\r
-       <div id="modal" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">\r
+       <div id="modal" class="modal fade" tabindex="-1" role="dialog">\r
                <div class="modal-dialog modal-full-screen">\r
                        <div class="modal-content">\r
                                <div id="modal-header" class="modal-header">\r
-                                       <button id="modal-cloase" type="button" class="close" data-dismiss="modal" aria-hidden="true">\r
+                                       <button id="modal-cloase" type="button" class="close" data-dismiss="modal">\r
                                                &times;\r
                                        </button>\r
                                        <h4 id="modal-title" class="modal-title"></h4>\r
index 71b5028a453b209549f4b1a74847611a8778542d..1dc4e94a4a8139c2bf6d3a6536ec459670277007 100644 (file)
@@ -106,11 +106,11 @@ $("nav").bind('nav-update', function(e,data)
 <script src="<?=$frio?>/frameworks/justifiedGallery/jquery.justifiedGallery.min.js"></script>
 
 <!-- Modal  -->
-<div id="modal" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
+<div id="modal" class="modal fade" tabindex="-1" role="dialog">
        <div class="modal-dialog modal-full-screen">
                <div class="modal-content">
                        <div id="modal-header" class="modal-header">
-                               <button id="modal-cloase" type="button" class="close" data-dismiss="modal" aria-hidden="true">
+                               <button id="modal-cloase" type="button" class="close" data-dismiss="modal">
                                        &times;
                                </button>
                                <h4 id="modal-title" class="modal-title"></h4>
index 5dc8916666021eb740aafcaea7eab5c6d037c8be..d687665e99de7dacc2bb3a3d5713680218bf37e2 100644 (file)
@@ -1,7 +1,7 @@
 
        <div class="field checkbox" id="div_id_{{$field.0}}">
                        <input type="hidden" name="{{$field.0}}" value="0">
-                       <input type="checkbox" name="{{$field.0}}" id="id_{{$field.0}}" value="1" {{if $field.2}}checked="checked"{{/if}} aria-checked="{{if $field.2}}true{{else}}false{{/if}}" aria-describedby="{{$field.0}}_tip" {{if $field.4}}{{$field.4}}{{/if}}>
+                       <input type="checkbox" name="{{$field.0}}" id="id_{{$field.0}}" value="1" {{if $field.2}}checked="checked"{{/if}} aria-checked="{{if $field.2}}true{{else}}false{{/if}}" {{if $field.3}}aria-describedby="{{$field.0}}_tip"{{/if}} {{if $field.4}}{{$field.4}}{{/if}}>
                        <label for="id_{{$field.0}}">
                                {{$field.1}}
                                {{if $field.3}}
index 4d58ff888c4df896cc35955503992e4a752846a3..378a568ba735696c349d0c0aee01dbf3ad1d7cca 100644 (file)
@@ -1,9 +1,9 @@
                        <!-- Modal  -->
-                       <div id="modal" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
+                       <div id="modal" class="modal fade" tabindex="-1" role="dialog">
                                <div class="modal-dialog modal-full-screen">
                                        <div class="modal-content">
                                                <div id="modal-header" class="modal-header">
-                                                       <button id="modal-cloase" type="button" class="close" data-dismiss="modal" aria-hidden="true">
+                                                       <button id="modal-cloase" type="button" class="close" data-dismiss="modal">
                                                                &times;
                                                        </button>
                                                        <h4 id="modal-title" class="modal-title"></h4>
index 06b43f6b1584dd4f3c0e8f012517528ac003cd4c..4b515efcd1872de00b4305cb8ecd99905c59799e 100644 (file)
@@ -70,7 +70,7 @@
                                        {{* The notifications dropdown *}}
                                        {{if $nav.notifications}}
                                                <li id="nav-notification" class="nav-segment" role="presentation">
-                                                       <a href="{{$nav.notifications.0}}" rel="#nav-notifications-menu" data-toggle="tooltip" aria-label="{{$nav.notifications.1}}" title="{{$nav.notifications.1}}" role="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
+                                                       <a href="{{$nav.notifications.0}}" rel="#nav-notifications-menu" data-toggle="tooltip" aria-label="{{$nav.notifications.1}}" title="{{$nav.notifications.1}}" role="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" aria-controls="nav-notifications-menu">
                                                                <i class="fa fa-bell fa-lg" aria-hidden="true"></i>
                                                                <span role="menuitem" class="sr-only">{{$nav.notifications.1}}</span>
                                                                <span id="notify-update" class="nav-notify-badge badge nav-notify dropdown" data-toggle="dropdown"></span>
                                                                {{if $nav.remote}}<span class="trunctate">{{$nav.remote}}</span>{{/if}}
                                                        </div>
 
-                                                       <img  id="avatar" src="{{$nav.userinfo.icon}}" alt="{{$nav.userinfo.name}}">
+                                                       <img id="avatar" src="{{$nav.userinfo.icon}}" alt="{{$nav.userinfo.name}}">
                                                        <span class="caret"></span>
                                                </button>
 
index 5a5390737ffbed4df0cc62a210e58d8f0f348b94..89407569b7f985888eb414b02329c0c6442118a4 100644 (file)
@@ -60,28 +60,6 @@ $(document).ready(function(){
        });
 });
 
-function insertFormatting(BBcode, id) {
-       var tmpStr = $("#comment-edit-text-" + id).val();
-       if (tmpStr == "") {
-               $("#comment-edit-text-" + id).addClass("comment-edit-text-full");
-               $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
-               openMenu("comment-edit-submit-wrapper-" + id);
-       }
-
-       textarea = document.getElementById("comment-edit-text-" +id);
-       if (document.selection) {
-               textarea.focus();
-               selected = document.selection.createRange();
-               selected.text = "["+BBcode+"]" + selected.text + "[/"+BBcode+"]";
-       } else if (textarea.selectionStart || textarea.selectionStart == "0") {
-               var start = textarea.selectionStart;
-               var end = textarea.selectionEnd;
-               textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
-       }
-
-       return true;
-}
-
 function showThread(id) {
        $("#collapsed-comments-" + id).show()
        $("#collapsed-comments-" + id + " .collapsed-comments").show()
index cca458a254ff4529b84d7bc3ca0c9cf646fe38f5..84fa0b97368459b46278489900ee31071d4af5c6 100644 (file)
@@ -6,7 +6,7 @@ use Friendica\Core\Config;
 use Friendica\Core\PConfig;
 use Friendica\Model\Profile;
 
-$uid = defaults($_REQUEST, 'puid', 0);
+$uid = $_REQUEST['puid'] ?? 0;
 
 $color = false;
 $quattro_align = false;
index 3b38eecb56156818bb5aa91bb5635fd3cc75c184..a5c13e0bf434be7b21b1fa6d31514e21ae3492b8 100644 (file)
@@ -1,41 +1,7 @@
 
 <script type="text/javascript" src="{{$baseurl}}/view/theme/smoothly/js/jquery.autogrow.textarea.js"></script>
 <script type="text/javascript">
-$(document).ready(function() {
-
-});
 function tautogrow(id) {
        $("textarea#comment-edit-text-" + id).autogrow();
-};
-
-function insertFormatting(BBcode, id) {
-       var tmpStr = $("#comment-edit-text-" + id).val();
-       if (tmpStr == "") {
-               $("#comment-edit-text-" + id).addClass("comment-edit-text-full");
-               $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
-               openMenu("comment-edit-submit-wrapper-" + id);
-       }
-
-       textarea = document.getElementById("comment-edit-text-" + id);
-       if (document.selection) {
-               textarea.focus();
-               selected = document.selection.createRange();
-               selected.text = "["+BBcode+"]" + selected.text + "[/"+BBcode+"]";
-       } else if (textarea.selectionStart || textarea.selectionStart == "0") {
-               var start = textarea.selectionStart;
-               var end = textarea.selectionEnd;
-               textarea.value = textarea.value.substring(0, start)
-                       + "["+BBcode+"]" + textarea.value.substring(start, end) + "[/"+BBcode+"]"
-                       + textarea.value.substring(end, textarea.value.length);
-       }
-
-       return true;
-}
-
-function cmtBbOpen(id) {
-       $(".comment-edit-bb-" + id).show();
-}
-function cmtBbClose(id) {
-    $(".comment-edit-bb-" + id).hide();
 }
 </script>
index 9dd958fff40166b8edd94d014923b650e84d09bc..e2289c87be41502af49e07c44ea6b3d24d707c21 100644 (file)
@@ -23,28 +23,6 @@ function smoothly_init(App $a) {
        $a->page['htmlhead'] .= <<< EOT
 
 <script>
-function insertFormatting(BBcode, id) {
-       var tmpStr = $("#comment-edit-text-" + id).val();
-       if (tmpStr == "") {
-               $("#comment-edit-text-" + id).addClass("comment-edit-text-full");
-               $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
-               openMenu("comment-edit-submit-wrapper-" + id);
-       }
-
-       textarea = document.getElementById("comment-edit-text-" +id);
-       if (document.selection) {
-               textarea.focus();
-               selected = document.selection.createRange();
-               selected.text = "["+BBcode+"]" + selected.text + "[/"+BBcode+"]";
-       } else if (textarea.selectionStart || textarea.selectionStart == "0") {
-               var start = textarea.selectionStart;
-               var end = textarea.selectionEnd;
-               textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
-       }
-
-       return true;
-}
-
 function cmtBbOpen(id) {
        $(".comment-edit-bb-" + id).show();
 }
index 69bfc78d88abfff0347a98c99db71df7b4f4b921..8a7c2f67d11d610499b43d536871a963f49d66ec 100644 (file)
@@ -7,7 +7,7 @@ use Friendica\Core\Config;
 use Friendica\Core\PConfig;
 use Friendica\Model\Profile;
 
-$uid = defaults($_REQUEST, 'puid', 0);
+$uid = $_REQUEST['puid'] ?? 0;
 
 $style = PConfig::get($uid, 'vier', 'style');
 
index 771f84a7bb61d32a1950f2e3811369d1c67609da..e5d71bdf578545b13157a9f926f8c79de81b6a06 100644 (file)
@@ -29,7 +29,7 @@ function vier_init(App $a)
 
        Renderer::setActiveTemplateEngine('smarty3');
 
-       if (!empty($a->argv[0]) && $a->argv[0] . defaults($a->argv, 1, '') === "profile".$a->user['nickname'] || $a->argv[0] === "network" && local_user()) {
+       if (!empty($a->argv[0]) && ($a->argv[0] . ($a->argv[1] ?? '')) === ('profile' . $a->user['nickname']) || $a->argv[0] === 'network' && local_user()) {
                vier_community_info();
 
                $a->page['htmlhead'] .= "<link rel='stylesheet' type='text/css' href='view/theme/vier/wide.css' media='screen and (min-width: 1300px)'/>\n";
@@ -45,29 +45,6 @@ function vier_init(App $a)
        $a->page['htmlhead'] .= <<< EOT
 <link rel='stylesheet' type='text/css' href='view/theme/vier/narrow.css' media='screen and (max-width: 1100px)' />
 <script type="text/javascript">
-
-function insertFormatting(BBcode, id) {
-       var tmpStr = $("#comment-edit-text-" + id).val();
-       if (tmpStr == "") {
-               $("#comment-edit-text-" + id).addClass("comment-edit-text-full");
-               $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
-               openMenu("comment-edit-submit-wrapper-" + id);
-       }
-
-       textarea = document.getElementById("comment-edit-text-" +id);
-       if (document.selection) {
-               textarea.focus();
-               selected = document.selection.createRange();
-               selected.text = "["+BBcode+"]" + selected.text + "[/"+BBcode+"]";
-       } else if (textarea.selectionStart || textarea.selectionStart == "0") {
-               var start = textarea.selectionStart;
-               var end = textarea.selectionEnd;
-               textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
-       }
-
-       return true;
-}
-
 function showThread(id) {
        $("#collapsed-comments-" + id).show()
        $("#collapsed-comments-" + id + " .collapsed-comments").show()
@@ -214,7 +191,7 @@ function vier_community_info()
 
        //Community_Pages at right_aside
        if ($show_pages && local_user()) {
-               $cid = defaults($_GET, 'cid', null);
+               $cid = $_GET['cid'] ?? null;
 
                //sort by last updated item
                $lastitem = true;