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

@ -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

View 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));

View 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');

View 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)) {

View 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;
}

View 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")) {

View 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');