Skip to content

Commit

Permalink
Performance optimisation: - based on analysis of Xdebug cachegrind ou…
Browse files Browse the repository at this point in the history
…tput.

git-svn-id: http://mantisbt.svn.sourceforge.net/svnroot/mantisbt/trunk@4692 f5dc347c-c33d-0410-90a0-b07cc1902cb9
  • Loading branch information
mantis committed Oct 31, 2007
1 parent 88bf302 commit d570598
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions core/authentication_api.php
Expand Up @@ -27,6 +27,7 @@

$g_script_login_cookie = null;
$g_cache_anonymous_user_cookie_string = null;
$g_cache_cookie_valid = null;

#===================================
# Boolean queries and ensures
Expand Down Expand Up @@ -62,7 +63,11 @@ function auth_ensure_user_authenticated( $p_return_page = '' ) {
# Return true if there is a currently logged in and authenticated user,
# false otherwise
function auth_is_user_authenticated() {
return ( auth_is_cookie_valid( auth_get_current_user_cookie() ) );
global $g_cache_cookie_valid;
if($g_cache_cookie_valid == true)
return $g_cache_cookie_valid;
$g_cache_cookie_valid = auth_is_cookie_valid( auth_get_current_user_cookie() );
return $g_cache_cookie_valid;
}


Expand Down Expand Up @@ -185,10 +190,11 @@ function auth_attempt_script_login( $p_username, $p_password = null ) {
# Logout the current user and remove any remaining cookies from their browser
# Returns true on success, false otherwise
function auth_logout() {
global $g_cache_current_user_id;
global $g_cache_current_user_id, $g_cache_cookie_valid;

# clear cached userid
$g_cache_current_user_id = null;
$g_cache_cookie_valid = null;

# clear cookies, if they were set
if (auth_clear_cookies()) {
Expand Down Expand Up @@ -318,9 +324,10 @@ function auth_set_cookies( $p_user_id, $p_perm_login=false ) {
# --------------------
# Clear login cookies, return true if they were cleared
function auth_clear_cookies() {
global $g_script_login_cookie;
global $g_script_login_cookie, $g_cache_cookie_valid;

$t_cookies_cleared = false;
$g_cache_cookie_valid = null;

# clear cookie, if not logged in from script
if ($g_script_login_cookie == null) {
Expand Down

0 comments on commit d570598

Please sign in to comment.