View Issue Details

IDProjectCategoryView StatusLast Update
0006097mantisbtsecuritypublic2005-09-11 08:12
Reportermspears Assigned Tothraxisp  
PrioritynormalSeveritymajorReproducibilityalways
Status closedResolutionfixed 
Product Version1.0.0rc1 
Fixed in Version1.0.0rc2 
Summary0006097: user ID is cached indefinately
Description

Whenever you run the CVS checkin script, the user always shows up as anonymous (if anonymous logins are allowed). This problem exists because the $g_cache_current_user_id variable is global and never resets to NULL upon successful authentication.

In authentication_api.php, the function auth_get_current_user_id() defines

global $g_cache_current_user_id;

if ( null !== $g_cache_current_user_id ) {
    return $g_cache_current_user_id;
}

This creates an indefinite user ID cache that never gets purged. So, whomever calls this function first wins.

Additional Information

For our purposes, we added code to reset the cached user ID upon successful authentication like

function auth_attempt_script_login( $p_username, $p_password = null ) {
    global $g_cache_current_user_id;

    ... 

    # ok, we're good to login now
    $g_cache_current_user_id = NULL;       

    return true;
}

This fixed the anonymous CVS user problem. However, I'm sure there are other places where authentication may occur which also needs to reset the cached user ID.

TagsNo tags attached.

Activities

thraxisp

thraxisp

2005-08-10 12:24

reporter   ~0011142

The $g_cache_current_user_id variable should persist through the run of the program. It serves to reduce the number of database queries. You are correct, however, that it should be cleared, or properly set when the script login happens. I also noted that the user cookie evaluation may be wrong in some cases.

Fixed in CVS.
core/authentication_api.php -> 1.53