Replace deprecated defaults() calls by ?? and ?: operators in src/Module/

This commit is contained in:
Hypolite Petovan 2019-10-15 09:20:32 -04:00
parent 8998926e5b
commit f59ea2af55
40 changed files with 115 additions and 94 deletions

View file

@ -13,10 +13,10 @@ class Acctlink extends BaseModule
{ {
public static function content() public static function content()
{ {
$addr = defaults($_GET, 'addr', false); $addr = trim($_GET['addr'] ?? '');
if ($addr) { if ($addr) {
$url = defaults(Probe::uri(trim($addr)), 'url', false); $url = Probe::uri($addr)['url'] ?? '';
if ($url) { if ($url) {
System::externalRedirect($url); System::externalRedirect($url);

View file

@ -53,7 +53,7 @@ class Details extends BaseAdminModule
$a->internalRedirect('admin/addons'); $a->internalRedirect('admin/addons');
} }
if (defaults($_GET, 'action', '') == 'toggle') { if (($_GET['action'] ?? '') == 'toggle') {
parent::checkFormSecurityTokenRedirectOnError('/admin/addons', 'admin_themes', 't'); parent::checkFormSecurityTokenRedirectOnError('/admin/addons', 'admin_themes', 't');
// Toggle addon status // Toggle addon status

View file

@ -26,7 +26,7 @@ class Index extends BaseAdminModule
break; break;
case 'toggle' : case 'toggle' :
$addon = defaults($_GET, 'addon', ''); $addon = $_GET['addon'] ?? '';
if (Addon::isEnabled($addon)) { if (Addon::isEnabled($addon)) {
Addon::uninstall($addon); Addon::uninstall($addon);
info(L10n::t('Addon %s disabled.', $addon)); info(L10n::t('Addon %s disabled.', $addon));

View file

@ -15,9 +15,9 @@ class Contact extends BaseAdminModule
{ {
parent::post(); parent::post();
$contact_url = defaults($_POST, 'contact_url', ''); $contact_url = $_POST['contact_url'] ?? '';
$block_reason = defaults($_POST, 'contact_block_reason', ''); $block_reason = $_POST['contact_block_reason'] ?? '';
$contacts = defaults($_POST, 'contacts', []); $contacts = $_POST['contacts'] ?? [];
parent::checkFormSecurityTokenRedirectOnError('/admin/blocklist/contact', 'admin_contactblock'); parent::checkFormSecurityTokenRedirectOnError('/admin/blocklist/contact', 'admin_contactblock');

View file

@ -20,7 +20,7 @@ class Settings extends BaseAdminModule
$logfile = (!empty($_POST['logfile']) ? Strings::escapeTags(trim($_POST['logfile'])) : ''); $logfile = (!empty($_POST['logfile']) ? Strings::escapeTags(trim($_POST['logfile'])) : '');
$debugging = !empty($_POST['debugging']); $debugging = !empty($_POST['debugging']);
$loglevel = defaults($_POST, 'loglevel', LogLevel::ERROR); $loglevel = ($_POST['loglevel'] ?? '') ?: LogLevel::ERROR;
if (is_file($logfile) && if (is_file($logfile) &&
!is_writeable($logfile)) { !is_writeable($logfile)) {

View file

@ -200,7 +200,7 @@ class Site extends BaseAdminModule
/** /**
* @var $storagebackend \Friendica\Model\Storage\IStorage * @var $storagebackend \Friendica\Model\Storage\IStorage
*/ */
$storagebackend = Strings::escapeTags(trim(defaults($_POST, 'storagebackend', ''))); $storagebackend = Strings::escapeTags(trim($_POST['storagebackend'] ?? ''));
// save storage backend form // save storage backend form
if (!is_null($storagebackend) && $storagebackend != "") { if (!is_null($storagebackend) && $storagebackend != "") {
@ -216,7 +216,7 @@ class Site extends BaseAdminModule
$value = !empty($_POST[$fieldname]); $value = !empty($_POST[$fieldname]);
break; break;
default: default:
$value = defaults($_POST, $fieldname, ''); $value = $_POST[$fieldname] ?? '';
} }
$storage_opts_data[$name] = $value; $storage_opts_data[$name] = $value;
} }

View file

@ -36,7 +36,7 @@ class Index extends BaseAdminModule
break; break;
case 'toggle' : case 'toggle' :
$theme = defaults($_GET, 'addon', ''); $theme = $_GET['addon'] ?? '';
if ($theme) { if ($theme) {
$theme = Strings::sanitizeFilePathItem($theme); $theme = Strings::sanitizeFilePathItem($theme);
if (!is_dir("view/theme/$theme")) { if (!is_dir("view/theme/$theme")) {

View file

@ -21,11 +21,11 @@ class Users extends BaseAdminModule
$a = self::getApp(); $a = self::getApp();
$pending = defaults($_POST, 'pending' , []); $pending = $_POST['pending'] ?? [];
$users = defaults($_POST, 'user' , []); $users = $_POST['user'] ?? [];
$nu_name = defaults($_POST, 'new_user_name' , ''); $nu_name = $_POST['new_user_name'] ?? '';
$nu_nickname = defaults($_POST, 'new_user_nickname', ''); $nu_nickname = $_POST['new_user_nickname'] ?? '';
$nu_email = defaults($_POST, 'new_user_email' , ''); $nu_email = $_POST['new_user_email'] ?? '';
$nu_language = Config::get('system', 'language'); $nu_language = Config::get('system', 'language');
parent::checkFormSecurityTokenRedirectOnError('/admin/users', 'admin_users'); parent::checkFormSecurityTokenRedirectOnError('/admin/users', 'admin_users');

View file

@ -78,7 +78,7 @@ class AllFriends extends BaseModule
$entry = [ $entry = [
'url' => Model\Contact::magicLinkbyId($friend['id'], $friend['url']), 'url' => Model\Contact::magicLinkbyId($friend['id'], $friend['url']),
'itemurl' => defaults($contactDetails, 'addr', $friend['url']), 'itemurl' => ($contactDetails['addr'] ?? '') ?: $friend['url'],
'name' => $contactDetails['name'], 'name' => $contactDetails['name'],
'thumb' => ProxyUtils::proxifyUrl($contactDetails['thumb'], false, ProxyUtils::SIZE_THUMB), 'thumb' => ProxyUtils::proxifyUrl($contactDetails['thumb'], false, ProxyUtils::SIZE_THUMB),
'img_hover' => $contactDetails['name'], 'img_hover' => $contactDetails['name'],

View file

@ -27,7 +27,7 @@ class Bookmarklet extends BaseModule
return $output; return $output;
} }
$referer = Strings::normaliseLink(defaults($_SERVER, 'HTTP_REFERER', '')); $referer = Strings::normaliseLink($_SERVER['HTTP_REFERER'] ?? '');
$page = Strings::normaliseLink($app->getBaseURL() . "/bookmarklet"); $page = Strings::normaliseLink($app->getBaseURL() . "/bookmarklet");
if (!strstr($referer, $page)) { if (!strstr($referer, $page)) {
@ -48,7 +48,7 @@ class Bookmarklet extends BaseModule
'bang' => '', 'bang' => '',
'visitor' => 'block', 'visitor' => 'block',
'profile_uid' => local_user(), 'profile_uid' => local_user(),
'title' => trim(defaults($_REQUEST, 'title', ''), '*'), 'title' => trim($_REQUEST['title'] ?? '', '*'),
'content' => $content 'content' => $content
]; ];
$output = status_editor($app, $x, 0, false); $output = status_editor($app, $x, 0, false);

View file

@ -103,7 +103,7 @@ class Contact extends BaseModule
Hook::callAll('contact_edit_post', $_POST); 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 ($profile_id) {
if (!DBA::exists('profile', ['id' => $profile_id, 'uid' => local_user()])) { if (!DBA::exists('profile', ['id' => $profile_id, 'uid' => local_user()])) {
notice(L10n::t('Could not locate selected profile.') . EOL); notice(L10n::t('Could not locate selected profile.') . EOL);
@ -115,16 +115,16 @@ class Contact extends BaseModule
$notify = !empty($_POST['notify']); $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) { if ($priority > 5 || $priority < 0) {
$priority = 0; $priority = 0;
} }
$info = Strings::escapeHtml(trim(defaults($_POST, 'info', ''))); $info = Strings::escapeHtml(trim($_POST['info'] ?? ''));
$r = DBA::update('contact', [ $r = DBA::update('contact', [
'profile-id' => $profile_id, 'profile-id' => $profile_id,
@ -188,21 +188,42 @@ class Contact extends BaseModule
Model\GContact::updateFromProbe($contact['url']); 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) private static function blockContact($contact_id)
{ {
$blocked = !Model\Contact::isBlockedByUser($contact_id, local_user()); $blocked = !Model\Contact::isBlockedByUser($contact_id, local_user());
Model\Contact::setBlockedForUser($contact_id, local_user(), $blocked); 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) private static function ignoreContact($contact_id)
{ {
$ignored = !Model\Contact::isIgnoredByUser($contact_id, local_user()); $ignored = !Model\Contact::isIgnoredByUser($contact_id, local_user());
Model\Contact::setIgnoredForUser($contact_id, local_user(), $ignored); 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) 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()]); $r = DBA::update('contact', ['archive' => $archived], ['id' => $contact_id, 'uid' => local_user()]);
return DBA::isResult($r); return DBA::isResult($r);
@ -227,8 +248,8 @@ class Contact extends BaseModule
$a = self::getApp(); $a = self::getApp();
$nets = defaults($_GET, 'nets', ''); $nets = $_GET['nets'] ?? '';
$rel = defaults($_GET, 'rel' , ''); $rel = $_GET['rel'] ?? '';
if (empty($a->page['aside'])) { if (empty($a->page['aside'])) {
$a->page['aside'] = ''; $a->page['aside'] = '';
@ -290,7 +311,7 @@ class Contact extends BaseModule
'$name' => $contact['name'], '$name' => $contact['name'],
'$photo' => $contact['photo'], '$photo' => $contact['photo'],
'$url' => Model\Contact::magicLinkByContact($contact, $contact['url']), '$url' => Model\Contact::magicLinkByContact($contact, $contact['url']),
'$addr' => defaults($contact, 'addr', ''), '$addr' => $contact['addr'] ?? '',
'$network_link' => $network_link, '$network_link' => $network_link,
'$network' => L10n::t('Network:'), '$network' => L10n::t('Network:'),
'$account_type' => Model\Contact::getAccountType($contact), '$account_type' => Model\Contact::getAccountType($contact),
@ -626,7 +647,7 @@ class Contact extends BaseModule
} }
// @TODO: Replace with parameter from router // @TODO: Replace with parameter from router
$type = defaults($a->argv, 1, ''); $type = $a->argv[1] ?? '';
switch ($type) { switch ($type) {
case 'blocked': case 'blocked':
@ -651,9 +672,9 @@ class Contact extends BaseModule
$sql_extra .= sprintf(" AND `network` != '%s' ", Protocol::PHANTOM); $sql_extra .= sprintf(" AND `network` != '%s' ", Protocol::PHANTOM);
$search = Strings::escapeTags(trim(defaults($_GET, 'search', ''))); $search = Strings::escapeTags(trim($_GET['search'] ?? ''));
$nets = Strings::escapeTags(trim(defaults($_GET, 'nets' , ''))); $nets = Strings::escapeTags(trim($_GET['nets'] ?? ''));
$rel = Strings::escapeTags(trim(defaults($_GET, 'rel' , ''))); $rel = Strings::escapeTags(trim($_GET['rel'] ?? ''));
$tabs = [ $tabs = [
[ [
@ -1016,7 +1037,7 @@ class Contact extends BaseModule
'username' => $rr['name'], 'username' => $rr['name'],
'account_type' => Model\Contact::getAccountType($rr), 'account_type' => Model\Contact::getAccountType($rr),
'sparkle' => $sparkle, 'sparkle' => $sparkle,
'itemurl' => defaults($rr, 'addr', $rr['url']), 'itemurl' => ($rr['addr'] ?? '') ?: $rr['url'],
'url' => $url, 'url' => $url,
'network' => ContactSelector::networkToName($rr['network'], $rr['url']), 'network' => ContactSelector::networkToName($rr['network'], $rr['url']),
'nick' => $rr['nick'], 'nick' => $rr['nick'],

View file

@ -25,7 +25,7 @@ class Babel extends BaseModule
$results = []; $results = [];
if (!empty($_REQUEST['text'])) { if (!empty($_REQUEST['text'])) {
switch (defaults($_REQUEST, 'type', 'bbcode')) { switch (($_REQUEST['type'] ?? '') ?: 'bbcode') {
case 'bbcode': case 'bbcode':
$bbcode = trim($_REQUEST['text']); $bbcode = trim($_REQUEST['text']);
$results[] = [ $results[] = [
@ -176,10 +176,10 @@ class Babel extends BaseModule
$tpl = Renderer::getMarkupTemplate('babel.tpl'); $tpl = Renderer::getMarkupTemplate('babel.tpl');
$o = Renderer::replaceMacros($tpl, [ $o = Renderer::replaceMacros($tpl, [
'$text' => ['text', L10n::t('Source text'), defaults($_REQUEST, 'text', ''), ''], '$text' => ['text', L10n::t('Source text'), $_REQUEST['text'] ?? '', ''],
'$type_bbcode' => ['type', L10n::t('BBCode'), 'bbcode', '', defaults($_REQUEST, 'type', 'bbcode') == 'bbcode'], '$type_bbcode' => ['type', L10n::t('BBCode'), 'bbcode', '', (($_REQUEST['type'] ?? '') ?: 'bbcode') == 'bbcode'],
'$type_markdown' => ['type', L10n::t('Markdown'), 'markdown', '', defaults($_REQUEST, 'type', 'bbcode') == 'markdown'], '$type_markdown' => ['type', L10n::t('Markdown'), 'markdown', '', (($_REQUEST['type'] ?? '') ?: 'bbcode') == 'markdown'],
'$type_html' => ['type', L10n::t('HTML'), 'html', '', defaults($_REQUEST, 'type', 'bbcode') == 'html'], '$type_html' => ['type', L10n::t('HTML'), 'html', '', (($_REQUEST['type'] ?? '') ?: 'bbcode') == 'html'],
'$results' => $results '$results' => $results
]); ]);

View file

@ -46,7 +46,7 @@ class Feed extends BaseModule
$tpl = Renderer::getMarkupTemplate('feedtest.tpl'); $tpl = Renderer::getMarkupTemplate('feedtest.tpl');
return Renderer::replaceMacros($tpl, [ return Renderer::replaceMacros($tpl, [
'$url' => ['url', L10n::t('Source URL'), defaults($_REQUEST, 'url', ''), ''], '$url' => ['url', L10n::t('Source URL'), $_REQUEST['url'] ?? '', ''],
'$result' => $result '$result' => $result
]); ]);
} }

View file

@ -12,7 +12,7 @@ class Localtime extends BaseModule
{ {
public static function post() public static function post()
{ {
$time = defaults($_REQUEST, 'time', 'now'); $time = ($_REQUEST['time'] ?? '') ?: 'now';
$bd_format = L10n::t('l F d, Y \@ g:i A'); $bd_format = L10n::t('l F d, Y \@ g:i A');
@ -25,7 +25,7 @@ class Localtime extends BaseModule
{ {
$app = self::getApp(); $app = self::getApp();
$time = defaults($_REQUEST, 'time', 'now'); $time = ($_REQUEST['time'] ?? '') ?: 'now';
$output = '<h3>' . L10n::t('Time Conversion') . '</h3>'; $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>'; $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 .= '<form action ="' . $app->getBaseURL() . '/localtime?time=' . $time . '" method="post" >';
$output .= '<p>' . L10n::t('Please select your timezone:') . '</p>'; $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>'; $output .= '<input type="submit" name="submit" value="' . L10n::t('Submit') . '" /></form>';
return $output; return $output;

View file

@ -21,7 +21,7 @@ class Probe extends BaseModule
throw $e; throw $e;
} }
$addr = defaults($_GET, 'addr', ''); $addr = $_GET['addr'] ?? '';
$res = ''; $res = '';
if (!empty($addr)) { if (!empty($addr)) {

View file

@ -20,7 +20,7 @@ class WebFinger extends BaseModule
throw $e; throw $e;
} }
$addr = defaults($_GET, 'addr', ''); $addr = $_GET['addr'] ?? '';
$res = ''; $res = '';
if (!empty($addr)) { if (!empty($addr)) {

View file

@ -27,7 +27,7 @@ class Feed extends BaseModule
{ {
$a = self::getApp(); $a = self::getApp();
$last_update = defaults($_GET, 'last_update', ''); $last_update = $_GET['last_update'] ?? '';
$nocache = !empty($_GET['nocache']) && local_user(); $nocache = !empty($_GET['nocache']) && local_user();
// @TODO: Replace with parameter from router // @TODO: Replace with parameter from router

View file

@ -23,8 +23,8 @@ class RemoveTag extends BaseModule
$item_id = (($app->argc > 1) ? intval($app->argv[1]) : 0); $item_id = (($app->argc > 1) ? intval($app->argv[1]) : 0);
$term = XML::unescape(trim(defaults($_GET, 'term', ''))); $term = XML::unescape(trim($_GET['term'] ?? ''));
$cat = XML::unescape(trim(defaults($_GET, 'cat', ''))); $cat = XML::unescape(trim($_GET['cat'] ?? ''));
$category = (($cat) ? true : false); $category = (($cat) ? true : false);

View file

@ -27,7 +27,7 @@ class SaveTag extends BaseModule
$a = self::getApp(); $a = self::getApp();
$logger = $a->getLogger(); $logger = $a->getLogger();
$term = XML::unescape(trim(defaults($_GET, 'term', ''))); $term = XML::unescape(trim($_GET['term'] ?? ''));
// @TODO: Replace with parameter from router // @TODO: Replace with parameter from router
$item_id = (($a->argc > 1) ? intval($a->argv[1]) : 0); $item_id = (($a->argc > 1) ? intval($a->argv[1]) : 0);

View file

@ -28,10 +28,10 @@ class FollowConfirm extends BaseModule
return; return;
} }
$intro_id = intval(defaults($_POST, 'intro_id' , 0)); $intro_id = intval($_POST['intro_id'] ?? 0);
$duplex = intval(defaults($_POST, 'duplex' , 0)); $duplex = intval($_POST['duplex'] ?? 0);
$cid = intval(defaults($_POST, 'contact_id', 0)); $cid = intval($_POST['contact_id'] ?? 0);
$hidden = intval(defaults($_POST, 'hidden' , 0)); $hidden = intval($_POST['hidden'] ?? 0);
if (empty($cid)) { if (empty($cid)) {
notice(L10n::t('No given contact.') . EOL); notice(L10n::t('No given contact.') . EOL);

View file

@ -29,7 +29,7 @@ class Followers extends BaseModule
throw new \Friendica\Network\HTTPException\NotFoundException(); throw new \Friendica\Network\HTTPException\NotFoundException();
} }
$page = defaults($_REQUEST, 'page', null); $page = $_REQUEST['page'] ?? null;
$followers = ActivityPub\Transmitter::getFollowers($owner, $page); $followers = ActivityPub\Transmitter::getFollowers($owner, $page);

View file

@ -29,7 +29,7 @@ class Following extends BaseModule
throw new \Friendica\Network\HTTPException\NotFoundException(); throw new \Friendica\Network\HTTPException\NotFoundException();
} }
$page = defaults($_REQUEST, 'page', null); $page = $_REQUEST['page'] ?? null;
$Following = ActivityPub\Transmitter::getFollowing($owner, $page); $Following = ActivityPub\Transmitter::getFollowing($owner, $page);

View 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 // 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'; 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() public static function post()
@ -345,8 +345,8 @@ class Install extends BaseModule
{ {
$configCache->set($cat, $key, $configCache->set($cat, $key,
Strings::escapeTags( Strings::escapeTags(
trim(defaults($post, sprintf('%s-%s', $cat, $key), trim(($post[sprintf('%s-%s', $cat, $key)] ?? '') ?:
(!isset($default) ? $configCache->get($cat, $key) : $default)) ($default ?? $configCache->get($cat, $key))
) )
) )
); );

View file

@ -36,7 +36,7 @@ class Like extends BaseModule
// Decide how to return. If we were called with a 'return' argument, // Decide how to return. If we were called with a 'return' argument,
// then redirect back to the calling page. If not, just quietly end // then redirect back to the calling page. If not, just quietly end
$returnPath = defaults($_REQUEST, 'return', ''); $returnPath = $_REQUEST['return'] ?? '';
if (!empty($returnPath)) { if (!empty($returnPath)) {
$rand = '_=' . time(); $rand = '_=' . time();

View file

@ -53,7 +53,7 @@ class Login extends BaseModule
&& (!empty($_POST['openid_url']) && (!empty($_POST['openid_url'])
|| !empty($_POST['username'])) || !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'])); self::openIdAuthentication($openid_url, !empty($_POST['remember']));
} }

View file

@ -28,8 +28,8 @@ class Magic extends BaseModule
Logger::log('args: ' . print_r($_REQUEST, true), Logger::DATA); Logger::log('args: ' . print_r($_REQUEST, true), Logger::DATA);
$addr = defaults($_REQUEST, 'addr', ''); $addr = $_REQUEST['addr'] ?? '';
$dest = defaults($_REQUEST, 'dest', ''); $dest = $_REQUEST['dest'] ?? '';
$test = (!empty($_REQUEST['test']) ? intval($_REQUEST['test']) : 0); $test = (!empty($_REQUEST['test']) ? intval($_REQUEST['test']) : 0);
$owa = (!empty($_REQUEST['owa']) ? intval($_REQUEST['owa']) : 0); $owa = (!empty($_REQUEST['owa']) ? intval($_REQUEST['owa']) : 0);
$cid = 0; $cid = 0;

View file

@ -28,7 +28,7 @@ class Outbox extends BaseModule
throw new \Friendica\Network\HTTPException\NotFoundException(); 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 /// @todo Add Authentication to enable fetching of non public content
// $requester = HTTPSignature::getSigner('', $_SERVER); // $requester = HTTPSignature::getSigner('', $_SERVER);

View file

@ -102,7 +102,7 @@ class Profile extends BaseModule
// site block // site block
if (!$blocked && !$userblock) { if (!$blocked && !$userblock) {
$keywords = str_replace(['#', ',', ' ', ',,'], ['', ' ', ',', ','], defaults($a->profile, 'pub_keywords', '')); $keywords = str_replace(['#', ',', ' ', ',,'], ['', ' ', ',', ','], $a->profile['pub_keywords'] ?? '');
if (strlen($keywords)) { if (strlen($keywords)) {
$a->page['htmlhead'] .= '<meta name="keywords" content="' . $keywords . '" />' . "\n"; $a->page['htmlhead'] .= '<meta name="keywords" content="' . $keywords . '" />' . "\n";
} }
@ -146,10 +146,10 @@ class Profile extends BaseModule
} }
if (empty($category)) { 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'])) { if (Config::get('system', 'block_public') && !local_user() && !Session::getRemoteContactID($a->profile['profile_uid'])) {
return Login::form(); return Login::form();
@ -174,7 +174,7 @@ class Profile extends BaseModule
} }
if (!$update) { 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']); $o .= ProfileModel::getTabs($a, $tab, $is_owner, $a->profile['nickname']);

View file

@ -28,7 +28,7 @@ class Contacts extends BaseModule
//@TODO: Get value from router parameters //@TODO: Get value from router parameters
$nickname = $a->argv[1]; $nickname = $a->argv[1];
$type = defaults($a->argv, 3, 'all'); $type = ($a->argv[3] ?? '') ?: 'all';
Nav::setSelected('home'); Nav::setSelected('home');

View file

@ -210,7 +210,7 @@ class Proxy extends BaseModule
$url = base64_decode(strtr($url, '-_', '+/'), true); $url = base64_decode(strtr($url, '-_', '+/'), true);
} else { } else {
$url = defaults($_REQUEST, 'url', ''); $url = $_REQUEST['url'] ?? '';
} }
return [ return [

View file

@ -62,12 +62,12 @@ class Register extends BaseModule
} }
} }
$username = defaults($_REQUEST, 'username' , ''); $username = $_REQUEST['username'] ?? '';
$email = defaults($_REQUEST, 'email' , ''); $email = $_REQUEST['email'] ?? '';
$openid_url = defaults($_REQUEST, 'openid_url', ''); $openid_url = $_REQUEST['openid_url'] ?? '';
$nickname = defaults($_REQUEST, 'nickname' , ''); $nickname = $_REQUEST['nickname'] ?? '';
$photo = defaults($_REQUEST, 'photo' , ''); $photo = $_REQUEST['photo'] ?? '';
$invite_id = defaults($_REQUEST, 'invite_id' , ''); $invite_id = $_REQUEST['invite_id'] ?? '';
if (Config::get('system', 'no_openid')) { if (Config::get('system', 'no_openid')) {
$fillwith = ''; $fillwith = '';
@ -290,7 +290,7 @@ class Register extends BaseModule
'source_photo' => $base_url . '/photo/avatar/' . $user['uid'] . '.jpg', 'source_photo' => $base_url . '/photo/avatar/' . $user['uid'] . '.jpg',
'to_email' => $admin['email'], 'to_email' => $admin['email'],
'uid' => $admin['uid'], 'uid' => $admin['uid'],
'language' => defaults($admin, 'language', 'en'), 'language' => ($admin['language'] ?? '') ?: 'en',
'show_in_notification_page' => false 'show_in_notification_page' => false
]); ]);
} }

View file

@ -275,8 +275,8 @@ class Acl extends BaseModule
'id' => intval($g['id']), 'id' => intval($g['id']),
'network' => $g['network'], 'network' => $g['network'],
'link' => $g['url'], 'link' => $g['url'],
'nick' => htmlentities(defaults($g, 'attag', $g['nick'])), 'nick' => htmlentities(($g['attag'] ?? '') ?: $g['nick']),
'addr' => htmlentities(defaults($g, 'addr', $g['url'])), 'addr' => htmlentities(($g['addr'] ?? '') ?: $g['url']),
'forum' => !empty($g['forum']) || !empty($g['prv']) ? 1 : 0, 'forum' => !empty($g['forum']) || !empty($g['prv']) ? 1 : 0,
]; ];
if ($entry['forum']) { if ($entry['forum']) {
@ -336,8 +336,8 @@ class Acl extends BaseModule
'id' => intval($contact['cid']), 'id' => intval($contact['cid']),
'network' => $contact['network'], 'network' => $contact['network'],
'link' => $contact['url'], 'link' => $contact['url'],
'nick' => htmlentities(defaults($contact, 'nick', $contact['addr'])), 'nick' => htmlentities(($contact['nick'] ?? '') ?: $contact['addr']),
'addr' => htmlentities(defaults($contact, 'addr', $contact['url'])), 'addr' => htmlentities(($contact['addr'] ?? '') ?: $contact['url']),
'forum' => $contact['forum'] 'forum' => $contact['forum']
]; ];
} }

View file

@ -26,12 +26,12 @@ class Index extends BaseSettingsModule
self::checkFormSecurityTokenRedirectOnError('settings/2fa', 'settings_2fa'); self::checkFormSecurityTokenRedirectOnError('settings/2fa', 'settings_2fa');
try { try {
User::getIdFromPasswordAuthentication(local_user(), defaults($_POST, 'password', '')); User::getIdFromPasswordAuthentication(local_user(), $_POST['password'] ?? '');
$has_secret = (bool) PConfig::get(local_user(), '2fa', 'secret'); $has_secret = (bool) PConfig::get(local_user(), '2fa', 'secret');
$verified = PConfig::get(local_user(), '2fa', 'verified'); $verified = PConfig::get(local_user(), '2fa', 'verified');
switch (defaults($_POST, 'action', '')) { switch ($_POST['action'] ?? '') {
case 'enable': case 'enable':
if (!$has_secret && !$verified) { if (!$has_secret && !$verified) {
$Google2FA = new Google2FA(); $Google2FA = new Google2FA();

View file

@ -49,12 +49,12 @@ class Verify extends BaseSettingsModule
return; return;
} }
if (defaults($_POST, 'action', null) == 'verify') { if (($_POST['action'] ?? '') == 'verify') {
self::checkFormSecurityTokenRedirectOnError('settings/2fa/verify', 'settings_2fa_verify'); self::checkFormSecurityTokenRedirectOnError('settings/2fa/verify', 'settings_2fa_verify');
$google2fa = new Google2FA(); $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) { if ($valid) {
PConfig::set(local_user(), '2fa', 'verified', true); PConfig::set(local_user(), '2fa', 'verified', true);

View file

@ -29,7 +29,7 @@ class Smilies extends BaseModule
public static function content() public static function content()
{ {
$smilies = Content\Smilies::getList(); $smilies = Content\Smilies::getList();
$count = count(defaults($smilies, 'texts', [])); $count = count($smilies['texts'] ?? []);
$tpl = Renderer::getMarkupTemplate('smilies.tpl'); $tpl = Renderer::getMarkupTemplate('smilies.tpl');
return Renderer::replaceMacros($tpl, [ return Renderer::replaceMacros($tpl, [

View file

@ -36,7 +36,7 @@ class HTTPException
500 => L10n::t('Internal Server Error'), 500 => L10n::t('Internal Server Error'),
503 => L10n::t('Service Unavailable'), 503 => L10n::t('Service Unavailable'),
]; ];
$title = defaults($titles, $e->getCode(), 'Error ' . $e->getCode()); $title = ($titles[$e->getCode()] ?? '') ?: 'Error ' . $e->getCode();
if (empty($message)) { if (empty($message)) {
// Explanations are taken from https://en.wikipedia.org/wiki/List_of_HTTP_status_codes // 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.'), 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')]; return ['$title' => $title, '$message' => $message, '$back' => L10n::t('Go back')];

View file

@ -41,7 +41,7 @@ class Starred extends BaseModule
Item::update(['starred' => $starred], ['id' => $itemId]); Item::update(['starred' => $starred], ['id' => $itemId]);
// See if we've been passed a return path to redirect to // See if we've been passed a return path to redirect to
$returnPath = defaults($_REQUEST, 'return', ''); $returnPath = $_REQUEST['return'] ?? '';
if ($returnPath) { if ($returnPath) {
$rand = '_=' . time(); $rand = '_=' . time();
if (strpos($returnPath, '?')) { if (strpos($returnPath, '?')) {

View file

@ -17,9 +17,9 @@ class ThemeDetails extends BaseModule
$info = Theme::getInfo($theme); $info = Theme::getInfo($theme);
// Unfortunately there will be no translation for this string // Unfortunately there will be no translation for this string
$description = defaults($info, 'description', ''); $description = $info['description'] ?? '';
$version = defaults($info, 'version' , ''); $version = $info['version'] ?? '';
$credits = defaults($info, 'credits' , ''); $credits = $info['credits'] ?? '';
echo json_encode([ echo json_encode([
'img' => Theme::getScreenshot($theme), 'img' => Theme::getScreenshot($theme),

View file

@ -28,12 +28,12 @@ class Recovery extends BaseModule
return; return;
} }
if (defaults($_POST, 'action', null) == 'recover') { if (($_POST['action'] ?? '') == 'recover') {
self::checkFormSecurityTokenRedirectOnError('2fa', 'twofactor_recovery'); self::checkFormSecurityTokenRedirectOnError('2fa', 'twofactor_recovery');
$a = self::getApp(); $a = self::getApp();
$recovery_code = defaults($_POST, 'recovery_code', ''); $recovery_code = $_POST['recovery_code'] ?? '';
if (RecoveryCode::existsForUser(local_user(), $recovery_code)) { if (RecoveryCode::existsForUser(local_user(), $recovery_code)) {
RecoveryCode::markUsedForUser(local_user(), $recovery_code); RecoveryCode::markUsedForUser(local_user(), $recovery_code);

View file

@ -28,7 +28,7 @@ class Xrd extends BaseModule
} }
$uri = urldecode(Strings::escapeTags(trim($_GET['uri']))); $uri = urldecode(Strings::escapeTags(trim($_GET['uri'])));
if (defaults($_SERVER, 'HTTP_ACCEPT', '') == 'application/jrd+json') { if (($_SERVER['HTTP_ACCEPT'] ?? '') == 'application/jrd+json') {
$mode = 'json'; $mode = 'json';
} else { } else {
$mode = 'xml'; $mode = 'xml';
@ -39,7 +39,7 @@ class Xrd extends BaseModule
} }
$uri = urldecode(Strings::escapeTags(trim($_GET['resource']))); $uri = urldecode(Strings::escapeTags(trim($_GET['resource'])));
if (defaults($_SERVER, 'HTTP_ACCEPT', '') == 'application/xrd+xml') { if (($_SERVER['HTTP_ACCEPT'] ?? '') == 'application/xrd+xml') {
$mode = 'xml'; $mode = 'xml';
} else { } else {
$mode = 'json'; $mode = 'json';