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
This commit is contained in:
Ralf Becker 2021-11-08 12:34:34 +01:00
parent 74cc2f03ff
commit 12a77b2126

View File

@ -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)) {
if ($record->$name !== null)
{
$names = array();
foreach($record->$name as $_name) {
$names[] = Api\Accounts::username($_name);
foreach((array)$record->$name as $_name) {
$names[] = Api\Accounts::title((int)$_name ?: $_name);
}
$record->$name = implode(', ', $names);
} else {
$record->$name = Api\Accounts::username($record->$name);
}
}
else
{