From ae39a1759a88e5dd71d8c03f05e2cf36dda8d35b Mon Sep 17 00:00:00 2001 From: FliegenKLATSCH Date: Wed, 20 Apr 2022 15:09:19 +0200 Subject: [PATCH] Silence some php 8.1 warnings (#1029) --- admin_admins.php | 2 +- admin_customers.php | 2 +- admin_domains.php | 4 ++-- customer_domains.php | 8 ++++---- lib/Froxlor/Api/Commands/Admins.php | 2 +- lib/Froxlor/Api/Commands/Customers.php | 2 +- lib/Froxlor/PhpHelper.php | 2 +- lib/Froxlor/System/IgnorantRecursiveDirectoryIterator.php | 5 +++-- 8 files changed, 14 insertions(+), 13 deletions(-) diff --git a/admin_admins.php b/admin_admins.php index 3c8031d8..9dbfe602 100644 --- a/admin_admins.php +++ b/admin_admins.php @@ -260,7 +260,7 @@ if ($page == 'admins' && $userinfo['change_serversettings'] == '1') { $dec_places = Settings::Get('panel.decimal_places'); $result['traffic'] = round($result['traffic'] / (1024 * 1024), $dec_places); $result['diskspace'] = round($result['diskspace'] / 1024, $dec_places); - $result['email'] = $idna_convert->decode($result['email']); + $result['email'] = $idna_convert->decode($result['email'] ?? ''); $customers_ul = \Froxlor\UI\HTML::makecheckbox('customers_ul', $lng['customer']['unlimited'], '-1', false, $result['customers'], true, true); if ($result['customers'] == '-1') { diff --git a/admin_customers.php b/admin_customers.php index ac393f73..dd46f5a3 100644 --- a/admin_customers.php +++ b/admin_customers.php @@ -395,7 +395,7 @@ if ($page == 'customers' && $userinfo['customers'] != '0') { $dec_places = Settings::Get('panel.decimal_places'); $result['traffic'] = round($result['traffic'] / (1024 * 1024), $dec_places); $result['diskspace'] = round($result['diskspace'] / 1024, $dec_places); - $result['email'] = $idna_convert->decode($result['email']); + $result['email'] = $idna_convert->decode($result['email'] ?? ''); $diskspace_ul = \Froxlor\UI\HTML::makecheckbox('diskspace_ul', $lng['customer']['unlimited'], '-1', false, $result['diskspace'], true, true); if ($result['diskspace'] == '-1') { diff --git a/admin_domains.php b/admin_domains.php index fc88f711..78bfda32 100644 --- a/admin_domains.php +++ b/admin_domains.php @@ -674,7 +674,7 @@ if ($page == 'domains' || $page == 'overview') { function formatDomainEntry(&$row, &$idna_convert) { $row['domain'] = $idna_convert->decode($row['domain']); - $row['aliasdomain'] = $idna_convert->decode($row['aliasdomain']); + $row['aliasdomain'] = $idna_convert->decode($row['aliasdomain'] ?? ''); $row['ipandport'] = ''; foreach ($row['ipsandports'] as $rowip) { @@ -685,7 +685,7 @@ function formatDomainEntry(&$row, &$idna_convert) } } $row['ipandport'] = substr($row['ipandport'], 0, - 1); - $row['termination_date'] = str_replace("0000-00-00", "", $row['termination_date']); + $row['termination_date'] = str_replace("0000-00-00", "", $row['termination_date'] ?? ''); $row['termination_css'] = ""; if ($row['termination_date'] != "") { diff --git a/customer_domains.php b/customer_domains.php index 26fe3833..b2d651a4 100644 --- a/customer_domains.php +++ b/customer_domains.php @@ -83,7 +83,7 @@ if ($page == 'overview') { $statsapp = 'webalizer'; } $row = [ - 'domain' => $idna_convert->decode($parentdomain) + 'domain' => $idna_convert->decode($parentdomain ?? '') ]; eval("\$domains.=\"" . \Froxlor\UI\Template::getTemplate("domains/domains_delimiter") . "\";"); @@ -472,8 +472,8 @@ if ($page == 'overview') { function formatDomainEntry(&$row, &$idna_convert) { $row['domain'] = $idna_convert->decode($row['domain']); - $row['aliasdomain'] = $idna_convert->decode($row['aliasdomain']); - $row['domainalias'] = $idna_convert->decode($row['domainalias']); + $row['aliasdomain'] = $idna_convert->decode($row['aliasdomain'] ?? ''); + $row['domainalias'] = $idna_convert->decode($row['domainalias'] ?? ''); /** * check for set ssl-certs to show different state-icons @@ -503,7 +503,7 @@ function formatDomainEntry(&$row, &$idna_convert) } } - $row['termination_date'] = str_replace("0000-00-00", "", $row['termination_date']); + $row['termination_date'] = str_replace("0000-00-00", "", $row['termination_date'] ?? ''); $row['termination_css'] = ""; if ($row['termination_date'] != "") { diff --git a/lib/Froxlor/Api/Commands/Admins.php b/lib/Froxlor/Api/Commands/Admins.php index 747edfc9..0d39e53c 100644 --- a/lib/Froxlor/Api/Commands/Admins.php +++ b/lib/Froxlor/Api/Commands/Admins.php @@ -472,7 +472,7 @@ class Admins extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt // parameters $name = $this->getParam('name', true, $result['name']); $idna_convert = new \Froxlor\Idna\IdnaWrapper(); - $email = $this->getParam('email', true, $idna_convert->decode($result['email'])); + $email = $this->getParam('email', true, $idna_convert->decode($result['email'] ?? '')); $password = $this->getParam('admin_password', true, ''); $def_language = $this->getParam('def_language', true, $result['def_language']); $custom_notes = $this->getParam('custom_notes', true, $result['custom_notes']); diff --git a/lib/Froxlor/Api/Commands/Customers.php b/lib/Froxlor/Api/Commands/Customers.php index b1dd1034..d5b9fb4c 100644 --- a/lib/Froxlor/Api/Commands/Customers.php +++ b/lib/Froxlor/Api/Commands/Customers.php @@ -950,7 +950,7 @@ class Customers extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resource $move_to_admin = (int) ($this->getParam('move_to_admin', true, 0)); $idna_convert = new \Froxlor\Idna\IdnaWrapper(); - $email = $this->getParam('email', true, $idna_convert->decode($result['email'])); + $email = $this->getParam('email', true, $idna_convert->decode($result['email'] ?? '')); $name = $this->getParam('name', true, $result['name']); $firstname = $this->getParam('firstname', true, $result['firstname']); $company_required = empty($result['company']) && ((! empty($name) && empty($firstname)) || (empty($name) && ! empty($firstname)) || (empty($name) && empty($firstname))); diff --git a/lib/Froxlor/PhpHelper.php b/lib/Froxlor/PhpHelper.php index 5b7c0b14..f9069fcb 100644 --- a/lib/Froxlor/PhpHelper.php +++ b/lib/Froxlor/PhpHelper.php @@ -63,7 +63,7 @@ class PhpHelper $subject[$field] = self::htmlentitiesArray($subject[$field], $fields, $quote_style, $charset); } } - } else { + } elseif (!empty($subject)) { $subject = htmlentities($subject, $quote_style, $charset); } diff --git a/lib/Froxlor/System/IgnorantRecursiveDirectoryIterator.php b/lib/Froxlor/System/IgnorantRecursiveDirectoryIterator.php index 97f8a6ba..51cf6e1b 100644 --- a/lib/Froxlor/System/IgnorantRecursiveDirectoryIterator.php +++ b/lib/Froxlor/System/IgnorantRecursiveDirectoryIterator.php @@ -10,8 +10,9 @@ namespace Froxlor\System; class IgnorantRecursiveDirectoryIterator extends \RecursiveDirectoryIterator { - public function getChildren() - { + #[\ReturnTypeWillChange] + public function getChildren() + { try { return new IgnorantRecursiveDirectoryIterator($this->getPathname()); } catch (\UnexpectedValueException $e) {