From 92ba02e3c0afbe84bd2e6acccb614c95465cc4d1 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Wed, 6 Oct 2021 16:07:45 +0200 Subject: [PATCH] fix PHP 8.0 errors: key(): Argument #1 ($array) must be of type array, null given guarding key() from calling with null eg. $button = key($content['button']) --> key($content['button'] ?? []) or check before !empty($content['button']) --- inc/class.projectmanager_eroles_ui.inc.php | 4 ++-- inc/class.projectmanager_roles_ui.inc.php | 4 ++-- inc/class.projectmanager_ui.inc.php | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/inc/class.projectmanager_eroles_ui.inc.php b/inc/class.projectmanager_eroles_ui.inc.php index b91a0294..bebe7b46 100644 --- a/inc/class.projectmanager_eroles_ui.inc.php +++ b/inc/class.projectmanager_eroles_ui.inc.php @@ -111,9 +111,9 @@ function eroles($content=null) } } } - if ($content['delete'] || $content['edit']) + if (!empty($content['delete']) || !empty($content['edit'])) { - $erole = $content['delete'] ? key($content['delete']) : key($content['edit']); + $erole = key($content['delete'] ?? $content['edit']); if(!($erole = $this->eroles->read($erole))) { $msg = lang('Permission denied !!!'); diff --git a/inc/class.projectmanager_roles_ui.inc.php b/inc/class.projectmanager_roles_ui.inc.php index a421b176..01bcbcd6 100644 --- a/inc/class.projectmanager_roles_ui.inc.php +++ b/inc/class.projectmanager_roles_ui.inc.php @@ -113,9 +113,9 @@ function roles($content=null) } } } - if ($content['delete'] || $content['edit']) + if (!empty($content['delete']) || !empty($content['edit'])) { - $role = $content['delete'] ? key($content['delete']) : key($content['edit']); + $role = key($content['delete'] ?? $content['edit']); if(!($role = $this->roles->read($role)) || $role['pm_id'] && !$this->check_acl(EGW_ACL_ROLES,$role['pm_id']) || !$role['pm_id'] && !$this->is_admin) diff --git a/inc/class.projectmanager_ui.inc.php b/inc/class.projectmanager_ui.inc.php index 95320f91..bc520f42 100644 --- a/inc/class.projectmanager_ui.inc.php +++ b/inc/class.projectmanager_ui.inc.php @@ -521,7 +521,7 @@ function edit($content=null,$view=false) { reset($sel_options['pm_accounting_type']); $content['pm_accounting_type'] = $preserv['pm_accounting_type'] = - key($sel_options['pm_accounting_type']); + key($sel_options['pm_accounting_type'] ?? []); } $readonlys['pm_accounting_type'] = true; } @@ -728,11 +728,11 @@ function pm_list($content=null,$msg='') $delete_sources = $content['delete_sources']; $content = $content['nm']['rows']; - if ($content['delete'] || $content['ganttchart']) + if (!empty($content['delete']) || !empty($content['ganttchart'])) { foreach(array('delete','ganttchart') as $action) { - if ($content[$action]) + if (!empty($content[$action])) { $pm_id = key($content[$action]); break;