forked from extern/egroupware
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
This commit is contained in:
parent
02270f63fb
commit
74cc2f03ff
@ -612,6 +612,20 @@ class Accounts
|
|||||||
$account['account_firstname'] , $account['account_lastname'], $account_id);
|
$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
|
* Format an email address according to the system standard
|
||||||
*
|
*
|
||||||
|
@ -154,7 +154,7 @@ class Link extends Link\Storage
|
|||||||
'name' => 'Accounts',
|
'name' => 'Accounts',
|
||||||
'icon' => 'addressbook/accounts',
|
'icon' => 'addressbook/accounts',
|
||||||
'query' => 'EGroupware\\Api\\Accounts::link_query',
|
'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' => array('menuaction'=>'addressbook.addressbook_ui.view','ajax'=>'true'),
|
||||||
'view_id' => 'account_id'
|
'view_id' => 'account_id'
|
||||||
),
|
),
|
||||||
@ -914,7 +914,12 @@ class Link extends Link\Storage
|
|||||||
}
|
}
|
||||||
else
|
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;
|
$titles[$id] = $title;
|
||||||
|
Loading…
Reference in New Issue
Block a user