From: Glenn H. <thr...@us...> - 2005-07-11 23:49:37
|
Update of /cvsroot/mantisbt/mantisbt/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3056/core Modified Files: authentication_api.php Log Message: bypass db lookup if database is not connected when user isn't authenticated and allow_anonymous_login is on Index: authentication_api.php =================================================================== RCS file: /cvsroot/mantisbt/mantisbt/core/authentication_api.php,v retrieving revision 1.50 retrieving revision 1.51 diff -u -d -r1.50 -r1.51 --- authentication_api.php 9 Jun 2005 20:07:25 -0000 1.50 +++ authentication_api.php 11 Jul 2005 23:49:13 -0000 1.51 @@ -371,17 +371,20 @@ } else { if ( ON == config_get( 'allow_anonymous_login' ) ) { if ( $g_cache_anonymous_user_cookie_string == null ) { - $query = sprintf('SELECT id, cookie_string FROM %s WHERE username = "%s"', + if ( function_exists( 'db_is_connected' ) && db_is_connected() ) { + # get anonymous information if database is available + $query = sprintf('SELECT id, cookie_string FROM %s WHERE username = "%s"', config_get( 'mantis_user_table' ), config_get( 'anonymous_account' ) ); - $result = db_query( $query ); + $result = db_query( $query ); - if ( 1 == db_num_rows( $result ) ) { - $row = db_fetch_array( $result ); - $t_cookie = $row['cookie_string']; + if ( 1 == db_num_rows( $result ) ) { + $row = db_fetch_array( $result ); + $t_cookie = $row['cookie_string']; - $g_cache_anonymous_user_cookie_string = $t_cookie; - $g_cache_current_user_id = $row['id']; - } + $g_cache_anonymous_user_cookie_string = $t_cookie; + $g_cache_current_user_id = $row['id']; + } + } } else { $t_cookie = $g_cache_anonymous_user_cookie_string; } |