From 964a71f6d32c1393167c7c502aebe80d218304c6 Mon Sep 17 00:00:00 2001 From: ralf Date: Thu, 1 Feb 2024 09:45:10 +0200 Subject: [PATCH] try fixing race-condition: Call to a member function exists() on null --- api/src/loader/common.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/api/src/loader/common.php b/api/src/loader/common.php index 12b2c432a5..eddd8cf354 100755 --- a/api/src/loader/common.php +++ b/api/src/loader/common.php @@ -291,37 +291,37 @@ if (file_exists(EGW_SERVER_ROOT.'/phpgwapi')) * @author skeeter * This function will return a properly formatted account_id. This can take either a name or an account_id as paramters. If a name is provided it will return the associated id. * $account_id = get_account_id($accountid); - * @param int/string $account_id either a name or an id - * @param int/string $default_id either a name or an id + * @param int|string $account_id either a name or an id + * @param int|string $default_id either a name or an id * @return int account_id */ function get_account_id($account_id = '',$default_id = '') { - if (gettype($account_id) == 'integer') + if (is_int($account_id)) { return $account_id; } - elseif ($account_id == '') + if ($account_id == '') { if ($default_id == '') { - return (isset($GLOBALS['egw_info']['user']['account_id'])?$GLOBALS['egw_info']['user']['account_id']:0); + return $GLOBALS['egw_info']['user']['account_id'] ?? 0; } elseif (is_string($default_id)) { - return $GLOBALS['egw']->accounts->name2id($default_id); + return Api\Accounts::getInstance()->name2id($default_id); } return (int)$default_id; } elseif (is_string($account_id)) { - if((int)$account_id && $GLOBALS['egw']->accounts->exists((int)$account_id) == True) + if((int)$account_id && Api\Accounts::getInstance()->exists((int)$account_id)) { return (int)$account_id; } else { - return $GLOBALS['egw']->accounts->name2id($account_id); + return Api\Accounts::getInstance()->name2id($account_id); } } } @@ -433,4 +433,4 @@ if (!function_exists('display_sidebox')) }, $_file); $GLOBALS['egw']->framework->sidebox($appname,$menu_title,$file); } -} +} \ No newline at end of file