Skip to content

Commit

Permalink
Fixed #8413: Provide a way to show queries for an access level thresh…
Browse files Browse the repository at this point in the history
…old.

git-svn-id: http://mantisbt.svn.sourceforge.net/svnroot/mantisbt/trunk@4597 f5dc347c-c33d-0410-90a0-b07cc1902cb9
  • Loading branch information
vboctor committed Sep 28, 2007
1 parent 4b020e6 commit b0cef96
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 18 deletions.
18 changes: 12 additions & 6 deletions config_defaults_inc.php
Expand Up @@ -6,7 +6,7 @@
# See the README and LICENSE files for details

# --------------------------------------------------------
# $Id: config_defaults_inc.php,v 1.361 2007-09-22 22:21:14 vboctor Exp $
# $Id: config_defaults_inc.php,v 1.362 2007-09-28 01:57:56 vboctor Exp $
# --------------------------------------------------------


Expand Down Expand Up @@ -1222,10 +1222,6 @@
# $g_bug_count_hyperlink_prefix = 'view_all_set.php?type=1'; # permanently change the filter
$g_bug_count_hyperlink_prefix = 'view_all_set.php?type=1&temporary=y'; # only change the filter this time

# --- Queries --------------------
# Shows the total number/unique number of queries executed to serve the page.
$g_show_queries_count = ON;

# The regular expression to use when validating new user login names
# The default regular expression allows a-z, A-z, 0-9, as well as space and
# underscore. If you change this, you may want to update the
Expand Down Expand Up @@ -1481,12 +1477,22 @@
# original To, Cc, Bcc included in the message body.
$g_debug_email = OFF;

# --- Queries --------------------
# Shows the total number/unique number of queries executed to serve the page.
$g_show_queries_count = ON;

# Indicates the access level required for a user to see the queries count / list.
# This only has an effect if $g_show_queries_count is ON. Note that this threshold
# is compared against the user's default global access level rather than the
# threshold based on the current active project.
$g_show_queries_threshold = ADMINISTRATOR;

# Shows the list of all queries that are executed in chronological order from top
# to bottom. This option is only effective when $g_show_queries_count is ON.
# WARNING: Potential security hazard. Only turn this on when you really
# need it (for debugging/profiling)
$g_show_queries_list = OFF;

# --- detailed error messages -----
# Shows a list of variables and their values when an error is triggered
# Only applies to error types configured to 'halt' in $g_display_errors, below
Expand Down
14 changes: 7 additions & 7 deletions core/graph_api.php
Expand Up @@ -6,7 +6,7 @@
# See the README and LICENSE files for details

# --------------------------------------------------------
# $Id: graph_api.php,v 1.35 2007-08-14 01:46:35 thraxisp Exp $
# $Id: graph_api.php,v 1.36 2007-09-28 01:57:56 vboctor Exp $
# --------------------------------------------------------

if ( ON == config_get( 'use_jpgraph' ) ) {
Expand Down Expand Up @@ -79,7 +79,7 @@ function graph_bar( $p_metrics, $p_title='', $p_graph_width = 350, $p_graph_heig
$p1->SetFillColor('yellow');
$p1->SetWidth(0.8);
$graph->Add($p1);
if ( ON == config_get( 'show_queries_count' ) ) {
if ( helper_show_queries() ) {
$graph->subtitle->Set( db_count_queries() . ' queries (' . db_count_unique_queries() . ' unique) (' . db_time_queries() . 'sec)' );
$graph->subtitle->SetFont( $t_graph_font, FS_NORMAL, 8 );
}
Expand Down Expand Up @@ -160,7 +160,7 @@ function graph_group( $p_metrics, $p_title='', $p_graph_width = 350, $p_graph_he
$gbplot = new GroupBarPlot(array($p1,$p3,$p2));
$graph->Add($gbplot);

if ( ON == config_get( 'show_queries_count' ) ) {
if ( helper_show_queries() ) {
$graph->subtitle->Set( db_count_queries() . ' queries (' . db_count_unique_queries() . ' unique) (' . db_time_queries() . 'sec)' );
$graph->subtitle->SetFont( $t_graph_font, FS_NORMAL, 8 );
}
Expand Down Expand Up @@ -210,7 +210,7 @@ function graph_group_pct( $p_title='', $p_graph_width = 350, $p_graph_height = 4
$gbplot = new GroupBarPlot(array($p1,$p2,$p3));

$graph->Add($gbplot);
if ( ON == config_get( 'show_queries_count' ) ) {
if ( helper_show_queries() ) {
$graph->subtitle->Set( db_count_queries() . ' queries (' . db_count_unique_queries() . ' unique)' );
}
$graph->Stroke();
Expand Down Expand Up @@ -249,7 +249,7 @@ function graph_pie( $p_metrics, $p_title='',
$p1->value->SetFont( $t_graph_font );

$graph->Add($p1);
if ( ON == config_get( 'show_queries_count' ) ) {
if ( helper_show_queries() ) {
$graph->subtitle->Set( db_count_queries() . ' queries (' . db_count_unique_queries() . ' unique) (' . db_time_queries() . 'sec)' );
$graph->subtitle->SetFont( $t_graph_font, FS_NORMAL, 8 );
}
Expand Down Expand Up @@ -317,7 +317,7 @@ function graph_cumulative_bydate( $p_metrics, $p_graph_width = 300, $p_graph_hei
$p2->SetLegend( lang_get( 'legend_resolved' ) );
$graph->Add($p2);

if ( ON == config_get( 'show_queries_count' ) ) {
if ( helper_show_queries() ) {
$graph->subtitle->Set( db_count_queries() . ' queries (' . db_count_unique_queries() . ' unique) (' . db_time_queries() . 'sec)' );
$graph->subtitle->SetFont( $t_graph_font, FS_NORMAL, 8 );
}
Expand Down Expand Up @@ -372,7 +372,7 @@ function graph_bydate( $p_metrics, $p_labels, $p_title, $p_graph_width = 300, $p
$graph->Add($t_line[$i]);
}

if ( ON == config_get( 'show_queries_count' ) ) {
if ( helper_show_queries() ) {
$graph->subtitle->Set( db_count_queries() . ' queries (' . db_count_unique_queries() . ' unique) (' . db_time_queries() . 'sec)' );
$graph->subtitle->SetFont( $t_graph_font, FS_NORMAL, 8 );
}
Expand Down
9 changes: 8 additions & 1 deletion core/helper_api.php
Expand Up @@ -6,7 +6,7 @@
# See the README and LICENSE files for details

# --------------------------------------------------------
# $Id: helper_api.php,v 1.74 2007-09-22 17:13:05 vboctor Exp $
# $Id: helper_api.php,v 1.75 2007-09-28 01:57:56 vboctor Exp $
# --------------------------------------------------------

### Helper API ###
Expand Down Expand Up @@ -398,4 +398,11 @@ function helper_get_tab_index_value() {
function helper_get_tab_index() {
return 'tabindex="' . helper_get_tab_index_value() . '"';
}

# --------------------
# returns a boolean indicating whether SQL queries executed should be shown
# or not.
function helper_show_queries() {
return ON == config_get( 'show_queries_count' ) && access_has_global_level( config_get( 'show_queries_threshold' ) );
}
?>
4 changes: 2 additions & 2 deletions core/html_api.php
Expand Up @@ -6,7 +6,7 @@
# See the README and LICENSE files for details

# --------------------------------------------------------
# $Id: html_api.php,v 1.216 2007-09-27 21:34:32 giallu Exp $
# $Id: html_api.php,v 1.217 2007-09-28 01:57:56 vboctor Exp $
# --------------------------------------------------------

###########################################################################
Expand Down Expand Up @@ -416,7 +416,7 @@ function html_footer( $p_file ) {
}

# print db queries that were run
if ( ON == config_get( 'show_queries_count' ) ) {
if ( helper_show_queries() ) {
$t_count = count( $g_queries_array );
echo "\t", $t_count, ' total queries executed.<br />', "\n";
$t_unique_queries = 0;
Expand Down
4 changes: 2 additions & 2 deletions core/print_api.php
Expand Up @@ -6,7 +6,7 @@
# See the README and LICENSE files for details

# --------------------------------------------------------
# $Id: print_api.php,v 1.181 2007-09-26 02:54:57 vboctor Exp $
# $Id: print_api.php,v 1.182 2007-09-28 01:57:56 vboctor Exp $
# --------------------------------------------------------

$t_core_dir = dirname( __FILE__ ).DIRECTORY_SEPARATOR;
Expand Down Expand Up @@ -80,7 +80,7 @@ function print_successful_redirect_to_bug( $p_bug_id ) {
# configured system wait time.
# If the show query count is OFF, redirect right away.
function print_successful_redirect( $p_redirect_to ) {
if ( ON == config_get( 'show_queries_count' ) ) {
if ( helper_show_queries() ) {
html_meta_redirect( $p_redirect_to );
html_page_top1();
html_page_top2();
Expand Down

0 comments on commit b0cef96

Please sign in to comment.