mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-22 06:30:59 +01:00
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'])
This commit is contained in:
parent
b837a0235e
commit
d2c85cfe86
@ -183,12 +183,12 @@ class addressbook_ui extends addressbook_bo
|
||||
$msg = '';
|
||||
}
|
||||
}
|
||||
if ($_content['nm']['rows']['infolog'])
|
||||
if (!empty($_content['nm']['rows']['infolog']))
|
||||
{
|
||||
$org = key($_content['nm']['rows']['infolog']);
|
||||
return $this->infolog_org_view($org);
|
||||
}
|
||||
if ($_content['nm']['rows']['view']) // show all contacts of an organisation
|
||||
if (!empty($_content['nm']['rows']['view'])) // show all contacts of an organisation
|
||||
{
|
||||
$grouped_view = key($_content['nm']['rows']['view']);
|
||||
}
|
||||
@ -2260,7 +2260,7 @@ class addressbook_ui extends addressbook_bo
|
||||
// remove invalid shared-with entries (should not happen, as we validate already on client-side)
|
||||
$this->check_shared_with($content['shared']);
|
||||
|
||||
$button = @key($content['button']);
|
||||
$button = @key($content['button'] ?? []);
|
||||
unset($content['button']);
|
||||
$content['private'] = (int) ($content['owner'] && substr($content['owner'],-1) == 'p');
|
||||
$content['owner'] = (string) (int) $content['owner'];
|
||||
@ -2988,7 +2988,7 @@ class addressbook_ui extends addressbook_bo
|
||||
|
||||
if(is_array($content))
|
||||
{
|
||||
$button = is_array($content['button']) ? key($content['button']) : "";
|
||||
$button = key($content['button'] ?? []);
|
||||
switch ($button)
|
||||
{
|
||||
case 'vcard':
|
||||
@ -3071,7 +3071,7 @@ class addressbook_ui extends addressbook_bo
|
||||
$_GET['contact_id'] = array_shift($rows);
|
||||
$_GET['index'] = 0;
|
||||
}
|
||||
$contact_id = $_GET['contact_id'] ? $_GET['contact_id'] : ((int)$_GET['account_id'] ? 'account:'.(int)$_GET['account_id'] : 0);
|
||||
$contact_id = $_GET['contact_id'] ?? ((int)$_GET['account_id'] ? 'account:'.(int)$_GET['account_id'] : 0);
|
||||
if(!$contact_id || !is_array($content = $this->read($contact_id)))
|
||||
{
|
||||
Egw::redirect_link('/index.php',array(
|
||||
|
@ -139,7 +139,7 @@ class admin_categories
|
||||
$button = 'delete';
|
||||
$delete_subs = $content['delete']['subs']?true:false;
|
||||
}
|
||||
else
|
||||
elseif (!empty($content['button']))
|
||||
{
|
||||
$button = key($content['button']);
|
||||
unset($content['button']);
|
||||
@ -564,7 +564,7 @@ class admin_categories
|
||||
{
|
||||
$content = array_merge($content,$content[$action.'_popup']);
|
||||
}
|
||||
$content['nm']['action'] .= '_' . key($content[$action . '_action']);
|
||||
$content['nm']['action'] .= '_' . key($content[$action . '_action'] ?? []);
|
||||
|
||||
if(is_array($content[$action]))
|
||||
{
|
||||
@ -680,7 +680,7 @@ class admin_categories
|
||||
{
|
||||
$cmd = new admin_cmd_delete_category(
|
||||
$cat_id,
|
||||
key($content['button']) == 'delete_sub',
|
||||
key($content['button'] ?? []) == 'delete_sub',
|
||||
$content['admin_cmd']
|
||||
);
|
||||
$cmd->run();
|
||||
|
@ -70,7 +70,7 @@ class admin_cmds
|
||||
}
|
||||
$content['nm']['actions'] = self::cmd_actions();
|
||||
}
|
||||
elseif ($content['nm']['rows']['delete'])
|
||||
elseif (!empty($content['nm']['rows']['delete']))
|
||||
{
|
||||
$id = key($content['nm']['rows']['delete']);
|
||||
unset($content['nm']['rows']);
|
||||
|
@ -212,7 +212,7 @@ class admin_mail
|
||||
public function autoconfig(array $content)
|
||||
{
|
||||
// user pressed [Skip IMAP] --> jump to SMTP config
|
||||
if ($content['button'] && key($content['button']) == 'skip_imap')
|
||||
if (!empty($content['button']) && key($content['button']) === 'skip_imap')
|
||||
{
|
||||
unset($content['button']);
|
||||
if (!isset($content['acc_smtp_host'])) $content['acc_smtp_host'] = ''; // do manual mode right away
|
||||
@ -361,7 +361,7 @@ class admin_mail
|
||||
*/
|
||||
public function folder(array $content, $msg='', Horde_Imap_Client_Socket $imap=null)
|
||||
{
|
||||
if (isset($content['button']))
|
||||
if (!empty($content['button']))
|
||||
{
|
||||
$button = key($content['button']);
|
||||
unset($content['button']);
|
||||
@ -482,7 +482,7 @@ class admin_mail
|
||||
);
|
||||
$content['msg'] = $msg;
|
||||
|
||||
if (isset($content['button']))
|
||||
if (!empty($content['button']))
|
||||
{
|
||||
$button = key($content['button']);
|
||||
unset($content['button']);
|
||||
@ -619,7 +619,7 @@ class admin_mail
|
||||
);
|
||||
$content['msg'] = $msg;
|
||||
|
||||
if (isset($content['button']))
|
||||
if (!empty($content['button']))
|
||||
{
|
||||
$button = key($content['button']);
|
||||
unset($content['button']);
|
||||
@ -835,7 +835,7 @@ class admin_mail
|
||||
{
|
||||
$content['called_for'] = (int)$_GET['account_id'];
|
||||
$content['accounts'] = iterator_to_array(Mail\Account::search($content['called_for']));
|
||||
if ($content['accounts'])
|
||||
if (!empty($content['accounts']))
|
||||
{
|
||||
$content['acc_id'] = key($content['accounts']);
|
||||
//error_log(__METHOD__.__LINE__.'.'.array2string($content['acc_id']));
|
||||
@ -949,7 +949,7 @@ class admin_mail
|
||||
$tpl->disableElement('notify_save_default', !$is_multiple || !$edit_access);
|
||||
$tpl->disableElement('notify_use_default', !$is_multiple);
|
||||
|
||||
if (isset($content['button']))
|
||||
if (!empty($content['button']))
|
||||
{
|
||||
$button = key($content['button']);
|
||||
unset($content['button']);
|
||||
|
@ -313,7 +313,7 @@ class calendar_uiforms extends calendar_ui
|
||||
$msg = $this->export($content['id'],true);
|
||||
}
|
||||
// delete a recur-exception
|
||||
if ($content['recur_exception']['delete_exception'])
|
||||
if (!empty($content['recur_exception']['delete_exception']))
|
||||
{
|
||||
$date = key($content['recur_exception']['delete_exception']);
|
||||
// eT2 converts time to
|
||||
@ -338,7 +338,7 @@ class calendar_uiforms extends calendar_ui
|
||||
$update_type = 'edit';
|
||||
}
|
||||
// delete an alarm
|
||||
if ($content['alarm']['delete_alarm'])
|
||||
if (!empty($content['alarm']['delete_alarm']))
|
||||
{
|
||||
$id = key($content['alarm']['delete_alarm']);
|
||||
//echo "delete alarm $id"; _debug_array($content['alarm']['delete_alarm']);
|
||||
@ -2250,7 +2250,7 @@ class calendar_uiforms extends calendar_ui
|
||||
$readonlys['button[reject]'] = $readonlys['button[cancel]'] = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
elseif (!empty($event['button']))
|
||||
{
|
||||
//_debug_array($event);
|
||||
$button = key($event['button']);
|
||||
@ -2908,7 +2908,7 @@ class calendar_uiforms extends calendar_ui
|
||||
{
|
||||
throw new Api\Exception\NoPermission\Admin();
|
||||
}
|
||||
if ($_content)
|
||||
if (!empty($_content['button']))
|
||||
{
|
||||
$button = key($_content['button']);
|
||||
unset($_content['button']);
|
||||
|
@ -93,7 +93,7 @@ class calendar_uilist extends calendar_ui
|
||||
// handle a single button like actions
|
||||
foreach(array('delete','timesheet','document') as $button)
|
||||
{
|
||||
if ($_content['nm']['rows'][$button])
|
||||
if (!empty($_content['nm']['rows'][$button]))
|
||||
{
|
||||
$id = key($_content['nm']['rows'][$button]);
|
||||
$_content['nm']['action'] = $button;
|
||||
|
@ -106,11 +106,11 @@ class filemanager_select
|
||||
}
|
||||
}
|
||||
|
||||
$content['mime'] = key($sel_options['mime']);
|
||||
$content['mime'] = key($sel_options['mime'] ?? []);
|
||||
error_log(array2string($content['options-mime']));
|
||||
}
|
||||
}
|
||||
elseif(isset($content['button']))
|
||||
elseif(!empty($content['button']))
|
||||
{
|
||||
$button = key($content['button']);
|
||||
unset($content['button']);
|
||||
@ -205,7 +205,7 @@ class filemanager_select
|
||||
|
||||
$sel_options['mime'] = $content['options-mime'];
|
||||
}
|
||||
elseif(isset($content['apps']))
|
||||
elseif(!empty($content['apps']))
|
||||
{
|
||||
$app = key($content['apps']);
|
||||
if ($app == 'home') $content['path'] = filemanager_ui::get_home_dir();
|
||||
|
@ -573,13 +573,11 @@ class filemanager_ui
|
||||
{
|
||||
$content['nm']['path'] = urldecode($content['nm']['path']);
|
||||
}
|
||||
if ($content['button'])
|
||||
if (!empty($content['button']))
|
||||
{
|
||||
if ($content['button'])
|
||||
{
|
||||
$button = key($content['button']);
|
||||
unset($content['button']);
|
||||
}
|
||||
$button = key($content['button']);
|
||||
unset($content['button']);
|
||||
|
||||
switch ($button)
|
||||
{
|
||||
case 'upload':
|
||||
@ -1347,9 +1345,9 @@ class filemanager_ui
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif ($content['eacl'] && $content['is_owner'])
|
||||
elseif (!empty($content['eacl']) && !empty($content['is_owner']))
|
||||
{
|
||||
if ($content['eacl']['delete'])
|
||||
if (!empty($content['eacl']['delete']))
|
||||
{
|
||||
$ino_owner = key($content['eacl']['delete']);
|
||||
list(, $owner) = explode('-',$ino_owner,2); // $owner is a group and starts with a minus!
|
||||
|
@ -94,7 +94,7 @@ class infolog_customfields extends admin_customfields
|
||||
$create = $fields['create'];
|
||||
unset($fields['create']);
|
||||
|
||||
if ($fields['delete'])
|
||||
if (!empty($fields['delete']))
|
||||
{
|
||||
$delete = key($fields['delete']);
|
||||
unset($fields['delete']);
|
||||
@ -178,7 +178,7 @@ class infolog_customfields extends admin_customfields
|
||||
$create = $status['create'];
|
||||
unset($status['create']);
|
||||
|
||||
if ($status['delete'])
|
||||
if (!empty($status['delete']))
|
||||
{
|
||||
$delete = key($status['delete']);
|
||||
unset($status['delete']);
|
||||
@ -276,7 +276,7 @@ class infolog_customfields extends admin_customfields
|
||||
unset($this->status[$content['type2']]);
|
||||
unset($this->status['defaults'][$content['type2']]);
|
||||
unset($this->group_owners[$content['type2']]);
|
||||
$content['type2'] = key($this->content_types);
|
||||
$content['type2'] = key($this->content_types ?? []);
|
||||
|
||||
// save changes to repository
|
||||
$this->save_repository();
|
||||
|
@ -116,7 +116,7 @@ class infolog_favorite_portlet extends home_favorite_portlet
|
||||
{
|
||||
$popup =& $values;
|
||||
}
|
||||
$values['nm']['multi_action'] .= '_' . key($popup[$multi_action . '_action']);
|
||||
$values['nm']['multi_action'] .= '_' . key($popup[$multi_action . '_action'] ?? []);
|
||||
if($multi_action == 'link')
|
||||
{
|
||||
$popup[$multi_action] = $popup['link']['app'] . ':'.$popup['link']['id'];
|
||||
|
@ -831,7 +831,7 @@ class infolog_ui
|
||||
{
|
||||
$popup =& $values;
|
||||
}
|
||||
$values['nm']['multi_action'] .= '_' . key($popup[$multi_action . '_action']);
|
||||
$values['nm']['multi_action'] .= '_' . key($popup[$multi_action . '_action'] ?? []);
|
||||
if($multi_action == 'link')
|
||||
{
|
||||
$popup[$multi_action] = $popup['link']['app'] . ':'.$popup['link']['id'];
|
||||
@ -2498,7 +2498,7 @@ class infolog_ui
|
||||
if($content)
|
||||
{
|
||||
// Save
|
||||
$button = key($content['button']);
|
||||
$button = key($content['button'] ?? []);
|
||||
if($button == 'save' || $button == 'apply')
|
||||
{
|
||||
$this->bo->responsible_edit = array('info_status','info_percent','info_datecompleted');
|
||||
|
@ -68,7 +68,7 @@ class preferences_settings
|
||||
{
|
||||
$is_admin = $content['is_admin'] || $content['type'] != 'user';
|
||||
//error_log(__METHOD__."(".array2string($content).")");
|
||||
if ($content['button'])
|
||||
if (!empty($content['button']))
|
||||
{
|
||||
$button = key($content['button']);
|
||||
$appname = $content['old_appname'] ? $content['old_appname'] : 'common';
|
||||
|
@ -176,7 +176,7 @@ class resources_acl_ui
|
||||
$content = array('data' => array());
|
||||
}
|
||||
}
|
||||
elseif ($content['button'])
|
||||
elseif (!empty($content['button']))
|
||||
{
|
||||
$cats = new Categories($content['owner'] ? $content['owner'] : Categories::GLOBAL_ACCOUNT,'resources');
|
||||
|
||||
|
@ -32,7 +32,8 @@ class resources_reserve {
|
||||
$display_days = $_GET['planner_days'] ? $_GET['planner_days'] : 3;
|
||||
$planner_date = $_GET['date'] ? $_GET['date'] : strtotime('yesterday',$content['date'] ? $content['date'] : time());
|
||||
|
||||
if($_GET['confirm']) {
|
||||
if(!empty($_GET['confirm']))
|
||||
{
|
||||
$register_code = ($_GET['confirm'] && preg_match('/^[0-9a-f]{32}$/',$_GET['confirm'])) ? $_GET['confirm'] : false;
|
||||
if($register_code && $registration = registration_bo::confirm($register_code)) {
|
||||
// Get calendar through link
|
||||
@ -48,17 +49,19 @@ class resources_reserve {
|
||||
$planner_date = mktime(0,0,0,date('m',$data['start']),date('d',$data['start']),date('Y',$data['start']));
|
||||
$readonlys['__ALL__'] = true;
|
||||
$content = array(
|
||||
'resource' => key($data['participant_types']['r']),
|
||||
'resource' => key($data['participant_types']['r'] ?? []),
|
||||
'date' => $data['start'],
|
||||
'time' => $data['start'] - mktime(0,0,0,date('m',$data['start']),date('d',$data['start']),date('Y',$data['start'])),
|
||||
'quantity' => 0
|
||||
);
|
||||
calendar_so::split_status($data['participant_types']['r'][$content['resource']], $content['quantity'],$role);
|
||||
$data['msg']= '<div class="confirm">'.lang('Registration confirmed %1', Api\DateTime::to($data['start'])) .'</div>';
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
$data['msg']= '<div class="confirm">'.lang('Unable to process confirmation.').'</div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->tmpl->read('resources.sitemgr_book');
|
||||
|
||||
|
@ -38,7 +38,7 @@ $db_backup = new Api\Db\Backup();
|
||||
$asyncservice = new Api\Asyncservice();
|
||||
|
||||
// download a backup, has to be before any output !!!
|
||||
if ($_POST['download'])
|
||||
if (!empty($_POST['download']))
|
||||
{
|
||||
$file = key($_POST['download']);
|
||||
$file = $db_backup->backup_dir.'/'.basename($file); // basename to now allow to change the dir
|
||||
@ -166,7 +166,7 @@ if ($_POST['upload'] && is_array($_FILES['uploaded']) && !$_FILES['uploaded']['e
|
||||
sprintf('%3.1f MB (%d)',$_FILES['uploaded']['size']/(1024*1024),$_FILES['uploaded']['size']).$md5));
|
||||
}
|
||||
// delete a backup
|
||||
if ($_POST['delete'])
|
||||
if (!empty($_POST['delete']))
|
||||
{
|
||||
$file = key($_POST['delete']);
|
||||
$file = $db_backup->backup_dir.'/'.basename($file); // basename to not allow to change the dir
|
||||
@ -174,7 +174,7 @@ if ($_POST['delete'])
|
||||
if (unlink($file)) $setup_tpl->set_var('error_msg',lang("backup '%1' deleted",$file));
|
||||
}
|
||||
// rename a backup
|
||||
if ($_POST['rename'])
|
||||
if (!empty($_POST['rename']))
|
||||
{
|
||||
$file = key($_POST['rename']);
|
||||
$new_name = $_POST['new_name'][$file];
|
||||
@ -190,7 +190,7 @@ if ($_POST['rename'])
|
||||
}
|
||||
}
|
||||
// restore a backup
|
||||
if ($_POST['restore'])
|
||||
if (!empty($_POST['restore']))
|
||||
{
|
||||
$file = key($_POST['restore']);
|
||||
$file = $db_backup->backup_dir.'/'.basename($file); // basename to not allow to change the dir
|
||||
@ -217,12 +217,12 @@ if ($_POST['restore'])
|
||||
}
|
||||
}
|
||||
// create a new scheduled backup
|
||||
if ($_POST['schedule'])
|
||||
if (!empty($_POST['schedule']))
|
||||
{
|
||||
$asyncservice->set_timer($_POST['times'],'db_backup-'.implode(':',$_POST['times']),'admin.admin_db_backup.do_backup','');
|
||||
}
|
||||
// cancel a scheduled backup
|
||||
if (is_array($_POST['cancel']))
|
||||
if (!empty($_POST['cancel']) && is_array($_POST['cancel']))
|
||||
{
|
||||
$id = key($_POST['cancel']);
|
||||
$asyncservice->cancel_timer($id);
|
||||
|
@ -879,8 +879,8 @@ class timesheet_ui extends timesheet_bo
|
||||
{
|
||||
$etpl = new Etemplate('timesheet.index');
|
||||
|
||||
if ($_GET['msg']) $msg = $_GET['msg'];
|
||||
if ($content['nm']['rows']['delete'])
|
||||
if (!empty($_GET['msg'])) $msg = $_GET['msg'];
|
||||
if (!empty($content['nm']['rows']['delete']))
|
||||
{
|
||||
$ts_id = key($content['nm']['rows']['delete']);
|
||||
if ($this->delete($ts_id))
|
||||
@ -892,13 +892,13 @@ class timesheet_ui extends timesheet_bo
|
||||
$msg = lang('Error deleting the entry!!!');
|
||||
}
|
||||
}
|
||||
if (is_array($content) && isset($content['nm']['rows']['document'])) // handle insert in default document button like an action
|
||||
if (is_array($content) && !empty($content['nm']['rows']['document'])) // handle insert in default document button like an action
|
||||
{
|
||||
$id = @key($content['nm']['rows']['document']);
|
||||
$content['nm']['action'] = 'document';
|
||||
$content['nm']['selected'] = array($id);
|
||||
}
|
||||
if ($content['nm']['action'])
|
||||
if (!empty($content['nm']['action']))
|
||||
{
|
||||
// remove sum-* rows from checked rows
|
||||
$content['nm']['selected'] = array_filter($content['nm']['selected'], function($id)
|
||||
@ -1309,7 +1309,7 @@ class timesheet_ui extends timesheet_bo
|
||||
$GLOBALS['egw']->redirect_link('/admin/index.php', null, 'admin');
|
||||
}
|
||||
}
|
||||
if (isset($content['statis']['delete']))
|
||||
if (!empty($content['statis']['delete']))
|
||||
{
|
||||
$id = key($content['statis']['delete']);
|
||||
if (isset($this->status_labels_config[$id]))
|
||||
|
Loading…
Reference in New Issue
Block a user