From dba803fff51b25b08dff47454915bc1b3be99fa9 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Mon, 8 Nov 2021 10:30:57 +0100 Subject: [PATCH 1/7] fix PHP 8.0 error: count(): Argument #1 ($value) must be of type Countable|array, null given plus some more IDE "errors" --- calendar/inc/class.calendar_uiforms.inc.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/calendar/inc/class.calendar_uiforms.inc.php b/calendar/inc/class.calendar_uiforms.inc.php index 9f5359cb66..37b047e681 100644 --- a/calendar/inc/class.calendar_uiforms.inc.php +++ b/calendar/inc/class.calendar_uiforms.inc.php @@ -55,7 +55,7 @@ class calendar_uiforms extends calendar_ui /** * default locking time for entries, that are opened by another user * - * @var locktime in seconds + * @var int lock time in seconds */ var $locktime_default=1; @@ -262,7 +262,7 @@ class calendar_uiforms extends calendar_ui ); } - return array( + $ret = array( 'participant_types' => $participant_types, 'participants' => $participants, 'owner' => $owner, @@ -278,6 +278,7 @@ class calendar_uiforms extends calendar_ui 'videoconference' => !empty($_GET['videoconference']), '##notify_externals' => !empty($_GET['videoconference']) ? 'yes' : $this->cal_prefs['notify_externals'], ); + return $ret; } /** @@ -1872,7 +1873,7 @@ class calendar_uiforms extends calendar_ui if ($event['recur_type'] != MCAL_RECUR_NONE) { - $readonlys['recur_exception'] = !count($content['recur_exception']); // otherwise we get a delete button + $readonlys['recur_exception'] = empty($content['recur_exception']); // otherwise we get a delete button //$onclick =& $etpl->get_cell_attribute('button[delete]','onclick'); //$onclick = str_replace('Delete this event','Delete this series of recuring events',$onclick); } @@ -2843,7 +2844,7 @@ class calendar_uiforms extends calendar_ui #error_log(__METHOD__.print_r($content,true)); if (is_numeric($cal_id = $content ? $content : $_REQUEST['cal_id'])) { - if (!($ical =& $boical->exportVCal(array($cal_id),'2.0','PUBLISH',false))) + if (!($ical = $boical->exportVCal(array($cal_id),'2.0','PUBLISH',false))) { $msg = lang('Permission denied'); @@ -2872,7 +2873,7 @@ class calendar_uiforms extends calendar_ui } else { - $ical =& $boical->exportVCal($events,'2.0','PUBLISH',false); + $ical = $boical->exportVCal($events,'2.0','PUBLISH',false); Api\Header\Content::type($content['file'] ? $content['file'] : 'event.ics','text/calendar',bytes($ical)); echo $ical; exit(); From a7796d8f27cf282e435ab905150d7bf0d98fe5e5 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Mon, 8 Nov 2021 10:55:45 +0100 Subject: [PATCH 2/7] fix PHP 8.0 TypeError: Unsupported operand types: EGroupware\Api\DateTime + int --- calendar/inc/class.calendar_so.inc.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/calendar/inc/class.calendar_so.inc.php b/calendar/inc/class.calendar_so.inc.php index c38081cd7c..fb9fc494e6 100644 --- a/calendar/inc/class.calendar_so.inc.php +++ b/calendar/inc/class.calendar_so.inc.php @@ -1663,6 +1663,10 @@ ORDER BY cal_user_type, cal_usre_id // check if recurrence enddate was adjusted if(isset($event['recur_enddate'])) { + if (is_object($event['recur_enddate'])) + { + $event['recur_enddate'] = Api\DateTime::user2server($event['recur_enddate'], 'ts'); + } // recurrences need to be truncated if((int)$event['recur_enddate'] > 0 && ((int)$old_repeats['recur_enddate'] == 0 || (int)$old_repeats['recur_enddate'] > (int)$event['recur_enddate']) From 7792c706a6aa4c497dac8828bc553a8cb6d46b49 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Mon, 8 Nov 2021 11:25:42 +0100 Subject: [PATCH 3/7] fix PHP 8.0 error: Undefined constant "__ALL__" --- admin/inc/class.admin_config.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/admin/inc/class.admin_config.inc.php b/admin/inc/class.admin_config.inc.php index 6db4049e5b..ae38805f4d 100644 --- a/admin/inc/class.admin_config.inc.php +++ b/admin/inc/class.admin_config.inc.php @@ -291,7 +291,7 @@ class admin_config // make everything readonly and remove save/apply button, if user has not rights to store config if ($GLOBALS['egw']->acl->check('site_config_acce',2,'admin')) { - $readonlys[__ALL__] = true; + $readonlys['__ALL__'] = true; $readonlys['cancel'] = false; } From 02270f63fb529648582bd1e13e2d985f0a8a4b9e Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Mon, 8 Nov 2021 11:36:25 +0100 Subject: [PATCH 4/7] fix PHP 8.0 TypeError: Exception::__construct(): Argument #2 ($code) must be of type int, string given --- api/src/Sharing.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/src/Sharing.php b/api/src/Sharing.php index 7962a0ab4b..13640b379b 100644 --- a/api/src/Sharing.php +++ b/api/src/Sharing.php @@ -396,7 +396,7 @@ class Sharing $class = strpos($status, '404') === 0 ? 'EGroupware\Api\Exception\NotFound' : (strpos($status, '401') === 0 ? 'EGroupware\Api\Exception\NoPermission' : 'EGroupware\Api\Exception'); - throw new $class($message, $status); + throw new $class($message, (int)$status); } /** From 74cc2f03ff9c672dde0ceb83c3aa7abfb4850bfd Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Mon, 8 Nov 2021 12:22:41 +0100 Subject: [PATCH 5/7] fix PHP 8.0 TypeError: Api\Accounts::username(): Argument #1 ($account_id) must be of type ?int, string given new method for account link-title not throwing an error, for non-numeric arguments and therefore stalling all titles --- api/src/Accounts.php | 14 ++++++++++++++ api/src/Link.php | 9 +++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/api/src/Accounts.php b/api/src/Accounts.php index f7cc06c5ae..2ec473a64c 100644 --- a/api/src/Accounts.php +++ b/api/src/Accounts.php @@ -612,6 +612,20 @@ class Accounts $account['account_firstname'] , $account['account_lastname'], $account_id); } + /** + * Return formatted username for Links, does NOT throw if $account_id is not int + * + * @param $account_id + */ + static function title($account_id) + { + if (empty($account_id) || !is_numeric($account_id) && !($id = self::getInstance()->name2id($account_id))) + { + return '#'.$account_id; + } + return self::username($id ?? $account_id); + } + /** * Format an email address according to the system standard * diff --git a/api/src/Link.php b/api/src/Link.php index 40a3bafeda..f86e96fd36 100644 --- a/api/src/Link.php +++ b/api/src/Link.php @@ -154,7 +154,7 @@ class Link extends Link\Storage 'name' => 'Accounts', 'icon' => 'addressbook/accounts', 'query' => 'EGroupware\\Api\\Accounts::link_query', - 'title' => 'EGroupware\\Api\\Accounts::username', + 'title' => 'EGroupware\\Api\\Accounts::title', 'view' => array('menuaction'=>'addressbook.addressbook_ui.view','ajax'=>'true'), 'view_id' => 'account_id' ), @@ -914,7 +914,12 @@ class Link extends Link\Storage } else { - $title = self::title($app,$id); // no titles method --> fallback to query each link separate + try { + $title = self::title($app, $id); // no titles method --> fallback to query each link separate + } + catch (\Throwable $e) { + $title = lang('Error').': '.$e->getMessage(); + } } } $titles[$id] = $title; From 12a77b2126a9dda86e98099554c5bdad5f365289 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Mon, 8 Nov 2021 12:34:34 +0100 Subject: [PATCH 6/7] fix PHP 8.0 TypeError: Api\Accounts::username(): Argument #1 ($account_id) must be of type ?int, string given using Api\Accounts::title() but cast to int, if giving an non-zero result --- .../inc/class.importexport_export_csv.inc.php | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/importexport/inc/class.importexport_export_csv.inc.php b/importexport/inc/class.importexport_export_csv.inc.php index aa3a8e0aee..b143d53346 100644 --- a/importexport/inc/class.importexport_export_csv.inc.php +++ b/importexport/inc/class.importexport_export_csv.inc.php @@ -387,18 +387,16 @@ class importexport_export_csv implements importexport_iface_export_record $record->$name = ''; } } - foreach($fields['select-account'] ?? [] as $name) { + foreach($fields['select-account'] ?? [] as $name) + { // Compare against null to deal with empty arrays - if ($record->$name !== null) { - if(is_array($record->$name)) { - $names = array(); - foreach($record->$name as $_name) { - $names[] = Api\Accounts::username($_name); - } - $record->$name = implode(', ', $names); - } else { - $record->$name = Api\Accounts::username($record->$name); + if ($record->$name !== null) + { + $names = array(); + foreach((array)$record->$name as $_name) { + $names[] = Api\Accounts::title((int)$_name ?: $_name); } + $record->$name = implode(', ', $names); } else { From d343203c20e6f6aa3ec7043e493c2691182a0f0a Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Mon, 8 Nov 2021 13:45:37 +0100 Subject: [PATCH 7/7] fix PHP 8.0 Unsupported operand types: EGroupware\Api\DateTime + int --- calendar/inc/class.calendar_so.inc.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/calendar/inc/class.calendar_so.inc.php b/calendar/inc/class.calendar_so.inc.php index fb9fc494e6..d8a19748f1 100644 --- a/calendar/inc/class.calendar_so.inc.php +++ b/calendar/inc/class.calendar_so.inc.php @@ -1667,6 +1667,10 @@ ORDER BY cal_user_type, cal_usre_id { $event['recur_enddate'] = Api\DateTime::user2server($event['recur_enddate'], 'ts'); } + if (is_object($old_repeats['recur_enddate'])) + { + $old_repeats['recur_enddate'] = Api\DateTime::user2server($old_repeats['recur_enddate'], 'ts'); + } // recurrences need to be truncated if((int)$event['recur_enddate'] > 0 && ((int)$old_repeats['recur_enddate'] == 0 || (int)$old_repeats['recur_enddate'] > (int)$event['recur_enddate'])