Update of /cvsroot/mantisbt/mantisbt/core
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12717
Modified Files:
authentication_api.php bug_api.php helper_api.php lang_api.php
project_api.php user_api.php
Log Message:
Batch 2 of possible 'performance' commits - mainly based on simplifying xdebug
output
Reduce number of calls to config_get etc.
NOTE: the auth_*/helper_project_* changes to do with cookies need a double
check that nothing screwy can happen.
My view page:
OLD:
config_get: 3573 calls, 1,271ms total self, 6,214ms total cum.
config_get_global: 7,774 calls, 749 total self, 1,580 total cum.
auth_is_user_authenticated: 1,473 calls, 274ms total self, 2406ms total cum.
lang_get_current: 103 calls, 11ms self, 12ms cum.
helper_get_current_project: 665calls, total self 335ms, total cum. 1,137
NEW:
config_get: 952 calls, self: 551ms, total cum: 1,199ms
config_get_global: 2532 calls, self: 235ms, total cum: 511ms
auth_is_user_authenticated: 1473 calls, self: 6.3ms, total cum: 14ms
lang_get_current: 103 calls, 5.6ms self, 5.8ms cum
helper_get_current_project: 665 calls, 7.5 self, cum. 14ms
viewall page: total cumulative from 12,xxx ms -> 5xxx ms.
Index: lang_api.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/core/lang_api.php,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -d -r1.39 -r1.40
--- lang_api.php 4 Aug 2005 20:57:51 -0000 1.39
+++ lang_api.php 29 Oct 2005 09:52:52 -0000 1.40
@@ -174,8 +174,9 @@
function lang_get_current( ) {
global $g_lang_overrides;
- if (count($g_lang_overrides) > 0 ) {
- $t_lang = $g_lang_overrides[ count( $g_lang_overrides )
- 1];
+ $t_count_overrides = count($g_lang_overrides);
+ if ($t_count_overrides > 0 ) {
+ $t_lang = $g_lang_overrides[ $t_count_overrides - 1];
} else {
$t_lang = lang_get_default();
}
Index: helper_api.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/core/helper_api.php,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -d -r1.62 -r1.63
--- helper_api.php 25 Jul 2005 11:55:36 -0000 1.62
+++ helper_api.php 29 Oct 2005 09:52:52 -0000 1.63
@@ -148,40 +148,43 @@
# This typically applies to the view bug pages where the "current"
# project as used by the filters, etc, does not match the bug being
viewed.
$g_project_override = null;
+ $g_cache_current_project = null;
# --------------------
# Return the current project id as stored in a cookie
# If no cookie exists, the user's default project is returned
function helper_get_current_project() {
- global $g_project_override;
+ global $g_project_override, $g_cache_current_project;
if ( $g_project_override !== null ) {
return $g_project_override;
}
-
- $t_cookie_name = config_get( 'project_cookie' );
- $t_project_id = gpc_get_cookie( $t_cookie_name, null );
+ if( $g_cache_current_project === null) {
+ $t_cookie_name = config_get( 'project_cookie' );
- if ( null === $t_project_id ) {
- $t_pref_row = user_pref_cache_row(
auth_get_current_user_id(), ALL_PROJECTS, false );
- if ( false === $t_pref_row ) {
- $t_project_id = ALL_PROJECTS;
+ $t_project_id = gpc_get_cookie( $t_cookie_name, null );
+
+ if ( null === $t_project_id ) {
+ $t_pref_row = user_pref_cache_row(
auth_get_current_user_id(), ALL_PROJECTS, false );
+ if ( false === $t_pref_row ) {
+ $t_project_id = ALL_PROJECTS;
+ } else {
+ $t_project_id =
$t_pref_row['default_project'];
+ }
} else {
- $t_project_id = $t_pref_row['default_project'];
+ $t_project_id = split( ';', $t_project_id );
+ $t_project_id = $t_project_id[ count(
$t_project_id ) - 1 ];
}
- } else {
- $t_project_id = split( ';', $t_project_id );
- $t_project_id = $t_project_id[ count( $t_project_id ) -
1 ];
- }
- if ( !project_exists( $t_project_id ) ||
- ( 0 == project_get_field( $t_project_id, 'enabled' ) )
||
- !access_has_project_level( VIEWER, $t_project_id ) ) {
- $t_project_id = ALL_PROJECTS;
+ if ( !project_exists( $t_project_id ) ||
+ ( 0 == project_get_field( $t_project_id,
'enabled' ) ) ||
+ !access_has_project_level( VIEWER,
$t_project_id ) ) {
+ $t_project_id = ALL_PROJECTS;
+ }
+ $g_cache_current_project = (int)$t_project_id;
}
-
- return (int)$t_project_id;
+ return $g_cache_current_project;
}
# --------------------
Index: user_api.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/core/user_api.php,v
retrieving revision 1.106
retrieving revision 1.107
diff -u -d -r1.106 -r1.107
--- user_api.php 22 Jul 2005 15:34:03 -0000 1.106
+++ user_api.php 29 Oct 2005 09:52:52 -0000 1.107
@@ -36,12 +36,12 @@
$c_user_id = db_prepare_int( $p_user_id );
- $t_user_table = config_get( 'mantis_user_table' );
-
if ( isset ( $g_cache_user[$c_user_id] ) ) {
return $g_cache_user[$c_user_id];
}
+ $t_user_table = config_get( 'mantis_user_table' );
+
$query = "SELECT *
FROM $t_user_table
WHERE id='$c_user_id'";
Index: authentication_api.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/core/authentication_api.php,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -d -r1.53 -r1.54
--- authentication_api.php 10 Aug 2005 16:21:28 -0000 1.53
+++ authentication_api.php 29 Oct 2005 09:52:52 -0000 1.54
@@ -13,6 +13,8 @@
$g_script_login_cookie = null;
$g_cache_anonymous_user_cookie_string = null;
+ $g_cache_current_user_cookie_string = null;
+ $g_cache_cookie_valid = null;
#===================================
# Boolean queries and ensures
@@ -52,6 +54,9 @@
# Return true if there is a currently logged in and authenticated user,
# false otherwise
function auth_is_user_authenticated() {
+ global $g_cache_cookie_valid;
+ if($g_cache_cookie_valid)
+ return true;
return ( auth_is_cookie_valid( auth_get_current_user_cookie() )
);
}
@@ -367,7 +372,11 @@
# if no user is logged in and anonymous login is enabled, returns
cookie for anonymous user
# otherwise returns '' (an empty string)
function auth_get_current_user_cookie() {
- global $g_script_login_cookie,
$g_cache_anonymous_user_cookie_string;
+ global $g_script_login_cookie,
$g_cache_anonymous_user_cookie_string, $g_cache_current_user_cookie_string;
+
+ if( isset( $g_cache_current_user_cookie_string ) ) {
+ return $g_cache_current_user_cookie_string;
+ }
# if logging in via a script, return that cookie
if ( $g_script_login_cookie !== null ) {
@@ -402,6 +411,7 @@
}
}
+ $g_cache_current_user_cookie_string = $t_cookie;
return $t_cookie;
}
@@ -414,8 +424,8 @@
# is cookie valid?
function auth_is_cookie_valid( $p_cookie_string ) {
- global $g_cache_current_user_id;
-
+ global $g_cache_current_user_id, $g_cache_cookie_valid;
+
# fail if DB isn't accessible
if ( !db_is_connected() ) {
return false;
@@ -442,8 +452,12 @@
$result = db_query( $query );
# return true if a matching cookie was found
- return ( 1 == db_num_rows( $result ) );
- }
+ $g_cache_cookie_valid = false;
+ if( 1 == db_num_rows( $result ) ) {
+ $g_cache_cookie_valid = true;
+ return ( true );
+ }
+}
#########################################
# SECURITY NOTE: cache globals are initialized here to prevent them
Index: bug_api.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/core/bug_api.php,v
retrieving revision 1.95
retrieving revision 1.96
diff -u -d -r1.95 -r1.96
--- bug_api.php 2 May 2005 14:06:58 -0000 1.95
+++ bug_api.php 29 Oct 2005 09:52:52 -0000 1.96
@@ -82,13 +82,13 @@
function bug_cache_row( $p_bug_id, $p_trigger_errors=true ) {
global $g_cache_bug;
+ if ( isset( $g_cache_bug[$p_bug_id] ) ) {
+ return $g_cache_bug[$p_bug_id];
+ }
+
$c_bug_id = db_prepare_int( $p_bug_id );
$t_bug_table = config_get( 'mantis_bug_table' );
- if ( isset( $g_cache_bug[$c_bug_id] ) ) {
- return $g_cache_bug[$c_bug_id];
- }
-
$query = "SELECT *
FROM $t_bug_table
WHERE id='$c_bug_id'";
Index: project_api.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/core/project_api.php,v
retrieving revision 1.75
retrieving revision 1.76
diff -u -d -r1.75 -r1.76
--- project_api.php 28 Jun 2005 19:22:53 -0000 1.75
+++ project_api.php 29 Oct 2005 09:52:52 -0000 1.76
@@ -39,14 +39,13 @@
function project_cache_row( $p_project_id, $p_trigger_errors=true ) {
global $g_cache_project, $g_cache_project_missing;
- $c_project_id = db_prepare_int( $p_project_id );
-
if ( isset ( $g_cache_project[(int)$p_project_id] ) ) {
return $g_cache_project[(int)$p_project_id];
} else if ( isset( $g_cache_project_missing[(int)$p_project_id]
) ) {
return false;
}
+ $c_project_id = db_prepare_int( $p_project_id );
$t_project_table = config_get( 'mantis_project_table' );
$query = "SELECT *
-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.
Get Certified Today * Register for a JBoss Training Course
Free Certification Exam for All Training Attendees Through End of 2005
Visit http://www.jboss.com/services/certification for more information
|