mirror of
https://github.com/friendica/friendica
synced 2025-04-26 17:10:10 +00:00
Replace deprecated calls to defaults() by ?? and ?: in src/
This commit is contained in:
parent
c0b78a9720
commit
146646c4d4
41 changed files with 239 additions and 233 deletions
|
@ -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');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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']);
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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"]];
|
||||
|
|
|
@ -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) == '>') {
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue