Skip to content

Commit

Permalink
2.1.3
Browse files Browse the repository at this point in the history
Remove QM_DB_LONG (pretty pointless)
Fix display of wp_admin_bar instantiated queries
Fix function trace for HTTP calls and transients
  • Loading branch information
johnbillion committed Dec 7, 2011
1 parent 7c58705 commit 7280680
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 44 deletions.
61 changes: 23 additions & 38 deletions components/db_queries.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
define( 'SAVEQUERIES', true );
if ( !defined( 'QM_DB_EXPENSIVE' ) )
define( 'QM_DB_EXPENSIVE', 0.05 );
if ( !defined( 'QM_DB_LONG' ) )
define( 'QM_DB_LONG', 1000 );
if ( !defined( 'QM_DB_LIMIT' ) )
define( 'QM_DB_LIMIT', 100 );

Expand Down Expand Up @@ -117,18 +115,15 @@ function add_func_time( $func, $ltime ) {

function process_db_object( $id, $db ) {

$rows = array();
$total_time = 0;
$total_qs = 0;
$ignored_time = 0;
$has_results = false;
$rows = array();
$total_time = 0;
$total_qs = 0;
$has_results = false;

foreach ( (array) $db->queries as $query ) {

/* ********************************************************* */
#if ( false !== strpos( $query[2], 'wp_admin_bar' ) )
# continue;
/* ********************************************************* */
if ( false !== strpos( $query[2], 'wp_admin_bar' ) and !isset( $_REQUEST['qm_display_all'] ) )
continue;

$sql = $query[0];
$ltime = $query[1];
Expand All @@ -140,24 +135,15 @@ function process_db_object( $id, $db ) {
else
$result = null;

if ( strpos( $funcs, 'wp_admin_bar' ) ) {
$ignored_time += $ltime;
} else {
$total_time += $ltime;
$total_qs++;
}
$total_time += $ltime;
$total_qs++;

if ( !empty( $funcs ) )
$func = reset( array_reverse( explode( ', ', $funcs ) ) );
else
$func = '<em class="qm-info">' . __( 'none', 'query_monitor' ) . '</em>';

if ( strpos( $funcs, 'wp_admin_bar' ) ) {
if ( isset( $_REQUEST['qm_display_all'] ) )
$this->add_func_time( $func, $ltime );
} else {
$this->add_func_time( $func, $ltime );
}
$this->add_func_time( $func, $ltime );

$sql = str_replace( array( "\r\n", "\r", "\n", "\t" ), ' ', $sql );
$sql = esc_html( trim( $sql ) );
Expand Down Expand Up @@ -217,7 +203,13 @@ function output_queries( $name, $db ) {
echo '</tr>';

if ( $max_exceeded ) {
echo '<tr><td colspan="' . $span . '" class="qm-expensive">' . sprintf( __( '%1$s %2$s queries were performed on this page load. Only the first %3$d are shown below. Total query time and cumulative function times should be accurate.', 'query_monitor' ), number_format_i18n( $total_qs ), $name, number_format_i18n( QM_DB_LIMIT ) ) . '</td></tr>';
echo '<tr>';
echo '<td colspan="' . $span . '" class="qm-expensive">' . sprintf( __( '%1$s %2$s queries were performed on this page load. Only the first %3$d are shown. Total times shown are for all queries.', 'query_monitor' ),
number_format_i18n( $total_qs ),
$name,
number_format_i18n( QM_DB_LIMIT )
) . '</td>';
echo '</tr>';
}

echo '<tr>';
Expand All @@ -237,23 +229,16 @@ function output_queries( $name, $db ) {

if ( !empty( $rows ) ) {

foreach ( $rows as $row ) {
if ( strpos( $row['funcs'], 'wp_admin_bar' ) ) {
if ( !isset( $_REQUEST['qm_display_all'] ) )
continue;
$row_class = 'qm-na';
} else {
$row_class = '';
}
foreach ( $rows as $i => $row ) {

if ( $i === QM_DB_LIMIT )
break;

$row_class = '';
$select = ( 0 === strpos( strtoupper( $row['sql'] ), 'SELECT' ) );
$ql = strlen( $row['sql'] );
$qs = size_format( $ql );
$stime = number_format_i18n( $row['ltime'], 4 );
$ltime = number_format_i18n( $row['ltime'], 10 );
if ( $select and ( $ql > QM_DB_LONG ) )
$row['qs'] = "<br /><span class='qm-expensive'>({$qs})</span>";
else
$row['qs'] = '';
$td = ( $row['ltime'] > QM_DB_EXPENSIVE ) ? " class='qm-expensive'" : '';
if ( !$select )
$row['sql'] = "<span class='qm-nonselectsql'>{$row['sql']}</span>";
Expand All @@ -274,7 +259,7 @@ function output_queries( $name, $db ) {

echo "
<tr class='{$row_class}'>\n
<td valign='top' class='qm-ltr'>{$row['sql']}{$row['qs']}</td>\n
<td valign='top' class='qm-ltr'>{$row['sql']}</td>\n
<td valign='top' class='qm-ltr' title='{$funcs}'>{$row['func']}</td>\n
{$results}
<td valign='top' title='{$ltime}'{$td}>{$stime}</td>\n
Expand Down
4 changes: 2 additions & 2 deletions components/http.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ function output( $args, $data ) {
'<br /><span>&nbsp;?&nbsp;</span>',
'<span>&nbsp;=&nbsp;</span>',
), $row['url'] );
unset( $row['trace'][0], $row['trace'][1], $row['trace'][2], $row['trace'][3] );
$f = 4;
unset( $row['trace'][0], $row['trace'][1], $row['trace'][2] );
$f = 6;
$func = $row['trace'][$f];
if ( 0 === strpos( $func, 'SimplePie' ) )
$func = $row['trace'][++$f];
Expand Down
4 changes: 2 additions & 2 deletions components/transients.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ function output( $args, $data ) {
if ( !empty( $data['trans'] ) ) {

foreach ( $data['trans'] as $row ) {
unset( $row['trace'][0], $row['trace'][1] );
$func = $row['trace'][2];
unset( $row['trace'][0], $row['trace'][1], $row['trace'][2], $row['trace'][3] );
$func = $row['trace'][5];
$transient = str_replace( array(
'_site_transient_',
'_transient_'
Expand Down
2 changes: 1 addition & 1 deletion query-monitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/*
Plugin Name: Query Monitor
Description: Monitoring of database queries, hooks, conditionals and much more.
Version: 2.1.2
Version: 2.1.3
Author: John Blackbourn
Author URI: http://lud.icro.us/
Expand Down
2 changes: 1 addition & 1 deletion wp-content/db.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/*
Plugin Name: Query Monitor
Version: 2.1.2
Version: 2.1.3
Move this file into your wp-content directory to provide additional
database query information in Query Monitor's output.
Expand Down

0 comments on commit 7280680

Please sign in to comment.