You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
CUser::getIdByContactId() looks up the result by the wrong key #441
getIdByContactId() (modules/users/users.class.php L269–273) loads users with loadAll(), which keys the list by user_id, and then reads $users[$contactId]['user_id']. It only returns the right id when the user id equals the contact id (as for the admin, which is why CUsersTest::testGetIdByContactId() passes). Otherwise it returns '' with an undefined-key warning, or another user's id.
Fix: return $users ? (string) key($users) : '' (or query user_id directly), and add a test where the two ids differ. The deprecated CUser::getUserIdByContactID() wrapper calls it too.
Activity
CUser::getIdByContactId(): read the user id from the list's key