mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-28 09:39:00 +01:00
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
9638bddaac
commit
fa67fc24d7
@ -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