View Issue Details

IDProjectCategoryView StatusLast Update
0003903mantisbtsqlpublic2004-07-07 18:55
Reportergrangeway Assigned Tovboctor  
PrioritynormalSeverityfeatureReproducibilityalways
Status closedResolutionfixed 
Product Versiongit trunk 
Fixed in Version0.19.0a1 
Summary0003903: optimisation of lang_load_default()
Description

lang_load_default currently does a join on user/user_prefs tables to load default language.

For $t_cookie to be set to a valid user, auth_get_current_user_id() should also be set.

Therefore, it appears we should be able to remove the join from this query, by modifying lines 78-81 of lang_api to read:

$query = "SELECT DISTINCT language
FROM $t_mantis_user_pref_table
WHERE id=" . auth_get_current_user_id();

and removing
$t_mantis_user_table = config_get( 'mantis_user_table' );

TagsNo tags attached.

Activities

grangeway

grangeway

2004-05-29 18:55

reporter   ~0005638

In fact, it appears the complete implementation, eliminating 1 additional db query per page could be:

function lang_load_default() {
    $t_cookie_string = gpc_get_cookie( config_get( 'string_cookie' ), '' );

    # Confirm that the user's language can be determined
    if ( !is_blank( $t_cookie_string ) ) {
        $t_active_language = user_pref_get_pref( auth_get_current_user_id() , 'language' );

        if ( false == $t_active_language ) {
            $t_active_language = config_get( 'default_language' );
        }
    } else {
        $t_active_language = config_get( 'default_language' );
    }

    lang_load( $t_active_language );
}
vboctor

vboctor

2004-05-29 19:38

manager   ~0005639

function lang_load_default() {
$t_active_language = false;

# Confirm that the user's language can be determined
if ( auth_is_user_authenticated() ) {
    $t_active_language = user_pref_get_pref( auth_get_current_user_id() , 'language' );
}

if ( false === $t_active_language ) {
    $t_active_language = config_get( 'default_language' );
}

lang_load( $t_active_language );

}

vboctor

vboctor

2004-05-29 20:29

manager   ~0005640

Implemented in CVS and will be included in next release.

Thanks to Glen Starrett patch and grangeway.