Merge pull request #899 from MrPetovan/task/7190-replace-defaults-call

[various] Replace deprecated defaults() calls by ?? operator
pull/904/head
Hypolite Petovan 2019-10-17 12:55:42 -04:00 committed by GitHub
commit 1f0e3ee604
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 27 additions and 26 deletions

View File

@ -126,8 +126,8 @@ function blogger_settings(App $a, &$s)
function blogger_settings_post(App $a, array &$b) function blogger_settings_post(App $a, array &$b)
{ {
if (!empty($_POST['blogger-submit'])) { if (!empty($_POST['blogger-submit'])) {
PConfig::set(local_user(), 'blogger', 'post', defaults($_POST, 'blogger', false)); PConfig::set(local_user(), 'blogger', 'post', $_POST['blogger'] ?? false);
PConfig::set(local_user(), 'blogger', 'post_by_default', defaults($_POST, 'bl_bydefault', false)); PConfig::set(local_user(), 'blogger', 'post_by_default', $_POST['bl_bydefault'] ?? false);
PConfig::set(local_user(), 'blogger', 'bl_username', trim($_POST['bl_username'])); PConfig::set(local_user(), 'blogger', 'bl_username', trim($_POST['bl_username']));
PConfig::set(local_user(), 'blogger', 'bl_password', trim($_POST['bl_password'])); PConfig::set(local_user(), 'blogger', 'bl_password', trim($_POST['bl_password']));
PConfig::set(local_user(), 'blogger', 'bl_blog', trim($_POST['bl_blog'])); PConfig::set(local_user(), 'blogger', 'bl_blog', trim($_POST['bl_blog']));

View File

@ -238,8 +238,8 @@ function buffer_settings_post(App $a, array &$b)
PConfig::set(local_user(), 'buffer', 'post' , false); PConfig::set(local_user(), 'buffer', 'post' , false);
PConfig::set(local_user(), 'buffer', 'post_by_default', false); PConfig::set(local_user(), 'buffer', 'post_by_default', false);
} else { } else {
PConfig::set(local_user(), 'buffer', 'post' , intval(defaults($_POST, 'buffer', false))); PConfig::set(local_user(), 'buffer', 'post' , intval($_POST['buffer'] ?? false));
PConfig::set(local_user(), 'buffer', 'post_by_default', intval(defaults($_POST, 'buffer_bydefault', false))); PConfig::set(local_user(), 'buffer', 'post_by_default', intval($_POST['buffer_bydefault'] ?? false));
} }
} }
} }

View File

@ -16,6 +16,7 @@ use Friendica\Core\Hook;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Core\PConfig; use Friendica\Core\PConfig;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\Core\Session;
use Friendica\Util\Network; use Friendica\Util\Network;
use Friendica\Util\Proxy as ProxyUtils; use Friendica\Util\Proxy as ProxyUtils;
@ -116,7 +117,7 @@ function curweather_network_mod_init(App $a, &$b)
$rpt = PConfig::get(local_user(), 'curweather', 'curweather_loc'); $rpt = PConfig::get(local_user(), 'curweather', 'curweather_loc');
// Set the language to the browsers language or default and use metric units // Set the language to the browsers language or default and use metric units
$lang = defaults($_SESSION, 'language', Config::get('system', 'language')); $lang = Session::get('language', Config::get('system', 'language'));
$units = PConfig::get( local_user(), 'curweather', 'curweather_units'); $units = PConfig::get( local_user(), 'curweather', 'curweather_units');
$appid = Config::get('curweather', 'appid'); $appid = Config::get('curweather', 'appid');
$cachetime = intval(Config::get('curweather', 'cachetime')); $cachetime = intval(Config::get('curweather', 'cachetime'));

View File

@ -114,7 +114,7 @@ function irc_content(&$a) {
if($autochans) if($autochans)
$channels = $autochans; $channels = $autochans;
else else
$channels = defaults($_GET, 'channels', 'friendica'); $channels = ($_GET['channels'] ?? '') ?: 'friendica';
/* add the chatroom frame and some html */ /* add the chatroom frame and some html */
$o .= <<< EOT $o .= <<< EOT

View File

@ -480,7 +480,7 @@ function jappixmini_script(App $a)
return; return;
} }
if (defaults($_GET, "mode", '') == "minimal") { if (($_GET['mode'] ?? '') == 'minimal') {
return; return;
} }

View File

@ -337,7 +337,7 @@ class qqFileUploader {
if (!isset($pathinfo['extension'])) { if (!isset($pathinfo['extension'])) {
Logger::warning('extension isn\'t set.', ['filename' => $filename]); Logger::warning('extension isn\'t set.', ['filename' => $filename]);
} }
$ext = defaults($pathinfo, 'extension', ''); $ext = $pathinfo['extension'] ?? '';
if($this->allowedExtensions && !in_array(strtolower($ext), $this->allowedExtensions)){ if($this->allowedExtensions && !in_array(strtolower($ext), $this->allowedExtensions)){
$these = implode(', ', $this->allowedExtensions); $these = implode(', ', $this->allowedExtensions);

View File

@ -109,8 +109,8 @@ function notifyall_content(&$a)
$o = Renderer::replaceMacros(Renderer::getMarkupTemplate('notifyall_form.tpl', 'addon/notifyall/'), [ $o = Renderer::replaceMacros(Renderer::getMarkupTemplate('notifyall_form.tpl', 'addon/notifyall/'), [
'$title' => $title, '$title' => $title,
'$text' => htmlspecialchars(defaults($_REQUEST, 'text', '')), '$text' => htmlspecialchars($_REQUEST['text'] ?? ''),
'$subject' => ['subject', L10n::t('Message subject'), defaults($_REQUEST, 'subject', ''),''], '$subject' => ['subject', L10n::t('Message subject'), $_REQUEST['subject'] ?? '',''],
'$test' => ['test',L10n::t('Test mode (only send to administrator)'), 0,''], '$test' => ['test',L10n::t('Test mode (only send to administrator)'), 0,''],
'$submit' => L10n::t('Submit') '$submit' => L10n::t('Submit')
]); ]);

View File

@ -215,10 +215,10 @@ function openstreetmap_addon_admin(&$a, &$o)
function openstreetmap_addon_admin_post(&$a) function openstreetmap_addon_admin_post(&$a)
{ {
$urltms = defaults($_POST, 'tmsserver', OSM_TMS); $urltms = ($_POST['tmsserver'] ?? '') ?: OSM_TMS;
$urlnom = defaults($_POST, 'nomserver', OSM_NOM); $urlnom = ($_POST['nomserver'] ?? '') ?: OSM_NOM;
$zoom = defaults($_POST, 'zoom', OSM_ZOOM); $zoom = ($_POST['zoom'] ?? '') ?: OSM_ZOOM;
$marker = defaults($_POST, 'marker', OSM_MARKER); $marker = ($_POST['marker'] ?? '') ?: OSM_MARKER;
Config::set('openstreetmap', 'tmsserver', $urltms); Config::set('openstreetmap', 'tmsserver', $urltms);
Config::set('openstreetmap', 'nomserver', $urlnom); Config::set('openstreetmap', 'nomserver', $urlnom);

View File

@ -361,13 +361,13 @@ function pumpio_settings_post(App $a, array &$b)
$host = trim($host); $host = trim($host);
$host = str_replace(["https://", "http://"], ["", ""], $host); $host = str_replace(["https://", "http://"], ["", ""], $host);
PConfig::set(local_user(), 'pumpio', 'post' , defaults($_POST, 'pumpio', false)); PConfig::set(local_user(), 'pumpio', 'post' , $_POST['pumpio'] ?? false);
PConfig::set(local_user(), 'pumpio', 'import' , defaults($_POST, 'pumpio_import', false)); PConfig::set(local_user(), 'pumpio', 'import' , $_POST['pumpio_import'] ?? false);
PConfig::set(local_user(), 'pumpio', 'host' , $host); PConfig::set(local_user(), 'pumpio', 'host' , $host);
PConfig::set(local_user(), 'pumpio', 'user' , $user); PConfig::set(local_user(), 'pumpio', 'user' , $user);
PConfig::set(local_user(), 'pumpio', 'public' , defaults($_POST, 'pumpio_public', false)); PConfig::set(local_user(), 'pumpio', 'public' , $_POST['pumpio_public'] ?? false);
PConfig::set(local_user(), 'pumpio', 'mirror' , defaults($_POST, 'pumpio_mirror', false)); PConfig::set(local_user(), 'pumpio', 'mirror' , $_POST['pumpio_mirror'] ?? false);
PConfig::set(local_user(), 'pumpio', 'post_by_default', defaults($_POST, 'pumpio_bydefault', false)); PConfig::set(local_user(), 'pumpio', 'post_by_default', $_POST['pumpio_bydefault'] ?? false);
if (!empty($_POST['pumpio_mirror'])) { if (!empty($_POST['pumpio_mirror'])) {
PConfig::delete(local_user(), 'pumpio', 'lastdate'); PConfig::delete(local_user(), 'pumpio', 'lastdate');

View File

@ -37,7 +37,7 @@ function rendertime_page_end(Friendica\App $a, &$o)
$ignored_modules = ["fbrowser"]; $ignored_modules = ["fbrowser"];
$ignored = in_array($a->module, $ignored_modules); $ignored = in_array($a->module, $ignored_modules);
if (is_site_admin() && (defaults($_GET, "mode", '') != "minimal") && !$a->is_mobile && !$a->is_tablet && !$ignored) { if (is_site_admin() && (($_GET['mode'] ?? '') != 'minimal') && !$a->is_mobile && !$a->is_tablet && !$ignored) {
$o = $o . '<div class="renderinfo">' . L10n::t("Database: %s/%s, Network: %s, Rendering: %s, Session: %s, I/O: %s, Other: %s, Total: %s", $o = $o . '<div class="renderinfo">' . L10n::t("Database: %s/%s, Network: %s, Rendering: %s, Session: %s, I/O: %s, Other: %s, Total: %s",
round($profiler->get('database') - $profiler->get('database_write'), 3), round($profiler->get('database') - $profiler->get('database_write'), 3),

View File

@ -151,11 +151,11 @@ function wppost_settings_post(&$a,&$b) {
if(!empty($_POST['wppost-submit'])) { if(!empty($_POST['wppost-submit'])) {
PConfig::set(local_user(),'wppost','post',intval($_POST['wppost'])); PConfig::set(local_user(),'wppost','post',intval($_POST['wppost']));
PConfig::set(local_user(),'wppost','post_by_default',intval(defaults($_POST, 'wp_bydefault', false))); PConfig::set(local_user(),'wppost','post_by_default',intval($_POST['wp_bydefault'] ?? false));
PConfig::set(local_user(),'wppost','wp_username',trim($_POST['wp_username'])); PConfig::set(local_user(),'wppost','wp_username',trim($_POST['wp_username']));
PConfig::set(local_user(),'wppost','wp_password',trim($_POST['wp_password'])); PConfig::set(local_user(),'wppost','wp_password',trim($_POST['wp_password']));
PConfig::set(local_user(),'wppost','wp_blog',trim($_POST['wp_blog'])); PConfig::set(local_user(),'wppost','wp_blog',trim($_POST['wp_blog']));
PConfig::set(local_user(),'wppost','backlink',trim(defaults($_POST, 'wp_backlink', ''))); PConfig::set(local_user(),'wppost','backlink',trim($_POST['wp_backlink'] ?? ''));
PConfig::set(local_user(),'wppost','shortcheck',trim($_POST['wp_shortcheck'])); PConfig::set(local_user(),'wppost','shortcheck',trim($_POST['wp_shortcheck']));
$wp_backlink_text = Strings::escapeTags(trim($_POST['wp_backlink_text'])); $wp_backlink_text = Strings::escapeTags(trim($_POST['wp_backlink_text']));
$wp_backlink_text = BBCode::convert($wp_backlink_text, false, 8); $wp_backlink_text = BBCode::convert($wp_backlink_text, false, 8);

View File

@ -37,9 +37,9 @@ function xmpp_addon_settings_post()
return; return;
} }
PConfig::set(local_user(), 'xmpp', 'enabled', defaults($_POST, 'xmpp_enabled', false)); PConfig::set(local_user(), 'xmpp', 'enabled', $_POST['xmpp_enabled'] ?? false);
PConfig::set(local_user(), 'xmpp', 'individual', defaults($_POST, 'xmpp_individual', false)); PConfig::set(local_user(), 'xmpp', 'individual', $_POST['xmpp_individual'] ?? false);
PConfig::set(local_user(), 'xmpp', 'bosh_proxy', defaults($_POST, 'xmpp_bosh_proxy', '')); PConfig::set(local_user(), 'xmpp', 'bosh_proxy', $_POST['xmpp_bosh_proxy'] ?? '');
info(L10n::t('XMPP settings updated.') . EOL); info(L10n::t('XMPP settings updated.') . EOL);
} }
@ -138,7 +138,7 @@ function xmpp_converse(App $a)
return; return;
} }
if (defaults($_GET, "mode", '') == "minimal") { if (($_GET['mode'] ?? '') == 'minimal') {
return; return;
} }