From a125be6074783584e5a29ec09fd8a478ae5f7552 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Mon, 8 Nov 2021 12:34:34 +0100 Subject: [PATCH] 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 {