Query Monitor - Version 2.5.3

Version Description

  • Show an inline error when a hook has an invalid action
  • Show a warning in the admin toolbar when HTTP requests fail
  • Fix the time shown when filtering queries
  • Fix empty stack traces (regression at some point)
Download this release

Release Info

Developer johnbillion
Plugin Icon 128x128 Query Monitor
Version 2.5.3
Comparing to
See all releases

Code changes from version 2.5.2 to 2.5.3

Backtrace.php CHANGED
@@ -37,6 +37,7 @@ class QM_Backtrace {
37
  '_deprecated_argument' => true,
38
  '_deprecated_file' => true,
39
  '_deprecated_function' => true,
 
40
  );
41
  protected static $show_args = array(
42
  'do_action' => 1,
@@ -70,6 +71,8 @@ class QM_Backtrace {
70
  public function get_stack() {
71
  $trace = array_map( 'QM_Backtrace::filter_trace', $this->trace );
72
  $trace = array_values( array_filter( $trace ) );
 
 
73
  return $trace;
74
  }
75
 
37
  '_deprecated_argument' => true,
38
  '_deprecated_file' => true,
39
  '_deprecated_function' => true,
40
+ 'dbDelta' => true,
41
  );
42
  protected static $show_args = array(
43
  'do_action' => 1,
71
  public function get_stack() {
72
  $trace = array_map( 'QM_Backtrace::filter_trace', $this->trace );
73
  $trace = array_values( array_filter( $trace ) );
74
+ if ( empty( $trace ) and isset( $this->trace[0]['file'] ) )
75
+ $trace[] = QM_Util::standard_dir( $this->trace[0]['file'], '' );
76
  return $trace;
77
  }
78
 
Plugin.php CHANGED
@@ -14,7 +14,7 @@ GNU General Public License for more details.
14
 
15
  */
16
 
17
- class QM_Plugin {
18
 
19
  /**
20
  * Class constructor
14
 
15
  */
16
 
17
+ abstract class QM_Plugin {
18
 
19
  /**
20
  * Class constructor
Util.php CHANGED
@@ -193,7 +193,7 @@ class QM_Util {
193
 
194
  } catch ( ReflectionException $e ) {
195
 
196
- # Nothing
197
 
198
  }
199
 
193
 
194
  } catch ( ReflectionException $e ) {
195
 
196
+ $callback['error'] = new WP_Error( 'reflection_exception', $e->getMessage() );
197
 
198
  }
199
 
assets/query-monitor.css CHANGED
@@ -57,6 +57,10 @@ body.mp6 #wpadminbar .quicklinks .menupop ul li.qm-true > a:hover {
57
  background-color: #c00;
58
  }
59
 
 
 
 
 
60
  #wp-admin-bar-query-monitor-errors {
61
  background-color: #c00 !important;
62
  }
@@ -65,6 +69,10 @@ body.mp6 #wpadminbar .quicklinks .menupop ul li.qm-true > a:hover {
65
  background-color: #c00 !important;
66
  }
67
 
 
 
 
 
68
  #wp-admin-bar-query-monitor-stricts a {
69
  color: #555 !important;
70
  }
@@ -319,7 +327,7 @@ select.qm-filter {
319
  display: block !important;
320
  font-family: Menlo, Monaco, Consolas, 'Courier New', monospace !important;
321
  font-weight: normal !important;
322
- font-size: 11px !important;
323
  margin: 4px 0 2px !important;
324
  border: 1px solid #e6e6e6 !important;
325
  padding: 1px !important;
57
  background-color: #c00;
58
  }
59
 
60
+ #wpadminbar .qm-warning > a {
61
+ color: #fff !important;
62
+ }
63
+
64
  #wp-admin-bar-query-monitor-errors {
65
  background-color: #c00 !important;
66
  }
69
  background-color: #c00 !important;
70
  }
71
 
72
+ #wpadminbar .qm-error > a {
73
+ color: #fff !important;
74
+ }
75
+
76
  #wp-admin-bar-query-monitor-stricts a {
77
  color: #555 !important;
78
  }
327
  display: block !important;
328
  font-family: Menlo, Monaco, Consolas, 'Courier New', monospace !important;
329
  font-weight: normal !important;
330
+ font-size: 10px !important;
331
  margin: 4px 0 2px !important;
332
  border: 1px solid #e6e6e6 !important;
333
  padding: 1px !important;
components/admin.php CHANGED
@@ -141,7 +141,7 @@ class QM_Component_Admin extends QM_Component {
141
  $col = 'link';
142
 
143
  echo '<tr>';
144
- echo '<td rowspan="2">' . __( 'Columns', 'query-monitor' ) . '</td>';
145
  echo "<td colspan='2'>manage_<span class='qm-current'>{$cols}</span>_columns</td>";
146
  echo '</tr>';
147
  echo '<tr>';
@@ -149,7 +149,7 @@ class QM_Component_Admin extends QM_Component {
149
  echo '</tr>';
150
 
151
  echo '<tr>';
152
- echo '<td rowspan="1">' . __( 'Column', 'query-monitor' ) . '</td>';
153
  echo "<td colspan='2'>manage_<span class='qm-current'>{$col}</span>_custom_column</td>";
154
  echo '</tr>';
155
 
141
  $col = 'link';
142
 
143
  echo '<tr>';
144
+ echo '<td rowspan="2">' . __( 'Column Filters', 'query-monitor' ) . '</td>';
145
  echo "<td colspan='2'>manage_<span class='qm-current'>{$cols}</span>_columns</td>";
146
  echo '</tr>';
147
  echo '<tr>';
149
  echo '</tr>';
150
 
151
  echo '<tr>';
152
+ echo '<td rowspan="1">' . __( 'Column Action', 'query-monitor' ) . '</td>';
153
  echo "<td colspan='2'>manage_<span class='qm-current'>{$col}</span>_custom_column</td>";
154
  echo '</tr>';
155
 
components/db_queries.php CHANGED
@@ -404,15 +404,15 @@ class QM_Component_DB_Queries extends QM_Component {
404
  $total_stime = number_format_i18n( $db->total_time, 4 );
405
  $total_ltime = number_format_i18n( $db->total_time, 10 );
406
 
407
- echo '<tr>';
408
- echo '<td valign="top" colspan="' . ( $span - 1 ) . '">' . sprintf( __( 'Total Queries: %s', 'query-monitor' ), number_format_i18n( $db->total_qs ) ) . '</td>';
409
- echo "<td valign='top' title='{$total_ltime}'>{$total_stime}</td>";
410
- echo '</tr>';
411
-
412
  echo '<tr class="qm-items-shown qm-hide">';
413
  echo '<td valign="top" colspan="' . ( $span - 1 ) . '">' . sprintf( __( 'Queries in filter: %s', 'query-monitor' ), '<span class="qm-items-number">' . number_format_i18n( $db->total_qs ) . '</span>' ) . '</td>';
414
  echo "<td valign='top' class='qm-items-time'>{$total_stime}</td>";
415
  echo '</tr>';
 
 
 
 
 
416
  echo '</tfoot>';
417
 
418
  } else {
@@ -438,6 +438,8 @@ class QM_Component_DB_Queries extends QM_Component {
438
  unset( $cols['component'] );
439
  if ( is_null( $row['result'] ) )
440
  unset( $cols['result'] );
 
 
441
 
442
  $row_attr = array();
443
  $stime = number_format_i18n( $row['ltime'], 4 );
@@ -461,8 +463,10 @@ class QM_Component_DB_Queries extends QM_Component {
461
  $row_attr['data-qm-db_queries-component'] = $row['component']->name;
462
  if ( isset( $cols['caller'] ) )
463
  $row_attr['data-qm-db_queries-caller'] = $row['caller_name'];
464
- if ( isset( $cols['time'] ) )
465
  $row_attr['data-qm-db_queries-time'] = $row['ltime'];
 
 
466
 
467
  $stack = esc_attr( $row['stack'] );
468
  $attr = '';
@@ -479,7 +483,10 @@ class QM_Component_DB_Queries extends QM_Component {
479
  echo "<td valign='top' class='qm-row-caller qm-ltr' title='{$stack}'>{$row['caller']}</td>";
480
 
481
  if ( isset( $cols['stack'] ) ) {
482
- $stack = implode( '<br/>', $row['stack'] );
 
 
 
483
  echo "<td valign='top' class='qm-row-caller qm-row-stack qm-ltr'>{$stack}</td>";
484
  }
485
 
404
  $total_stime = number_format_i18n( $db->total_time, 4 );
405
  $total_ltime = number_format_i18n( $db->total_time, 10 );
406
 
 
 
 
 
 
407
  echo '<tr class="qm-items-shown qm-hide">';
408
  echo '<td valign="top" colspan="' . ( $span - 1 ) . '">' . sprintf( __( 'Queries in filter: %s', 'query-monitor' ), '<span class="qm-items-number">' . number_format_i18n( $db->total_qs ) . '</span>' ) . '</td>';
409
  echo "<td valign='top' class='qm-items-time'>{$total_stime}</td>";
410
  echo '</tr>';
411
+
412
+ echo '<tr>';
413
+ echo '<td valign="top" colspan="' . ( $span - 1 ) . '">' . sprintf( __( 'Total Queries: %s', 'query-monitor' ), number_format_i18n( $db->total_qs ) ) . '</td>';
414
+ echo "<td valign='top' title='{$total_ltime}'>{$total_stime}</td>";
415
+ echo '</tr>';
416
  echo '</tfoot>';
417
 
418
  } else {
438
  unset( $cols['component'] );
439
  if ( is_null( $row['result'] ) )
440
  unset( $cols['result'] );
441
+ if ( is_null( $row['stack'] ) )
442
+ unset( $cols['stack'] );
443
 
444
  $row_attr = array();
445
  $stime = number_format_i18n( $row['ltime'], 4 );
463
  $row_attr['data-qm-db_queries-component'] = $row['component']->name;
464
  if ( isset( $cols['caller'] ) )
465
  $row_attr['data-qm-db_queries-caller'] = $row['caller_name'];
466
+ if ( isset( $cols['time'] ) ) {
467
  $row_attr['data-qm-db_queries-time'] = $row['ltime'];
468
+ $row_attr['data-qm-time'] = $row['ltime'];
469
+ }
470
 
471
  $stack = esc_attr( $row['stack'] );
472
  $attr = '';
483
  echo "<td valign='top' class='qm-row-caller qm-ltr' title='{$stack}'>{$row['caller']}</td>";
484
 
485
  if ( isset( $cols['stack'] ) ) {
486
+ # This isn't optimal...
487
+ $stack = explode( ', ', $row['stack'] );
488
+ $stack = array_reverse( $stack );
489
+ $stack = implode( '<br>', $stack );
490
  echo "<td valign='top' class='qm-row-caller qm-row-stack qm-ltr'>{$stack}</td>";
491
  }
492
 
components/hooks.php CHANGED
@@ -154,6 +154,13 @@ class QM_Component_Hooks extends QM_Component {
154
  echo '<td valign="top" class="qm-priority">' . $action['priority'] . '</td>';
155
  echo '<td valign="top" class="qm-ltr">';
156
  echo esc_html( $action['callback']['name'] );
 
 
 
 
 
 
 
157
  echo '</td>';
158
  echo '<td valign="top">';
159
  echo esc_html( $component );
154
  echo '<td valign="top" class="qm-priority">' . $action['priority'] . '</td>';
155
  echo '<td valign="top" class="qm-ltr">';
156
  echo esc_html( $action['callback']['name'] );
157
+ if ( isset( $action['callback']['error'] ) ) {
158
+ echo '<br><span class="qm-warn">';
159
+ printf( __( 'Error: %s', 'query-monitor' ),
160
+ esc_html( $action['callback']['error']->get_error_message() )
161
+ );
162
+ echo '<span>';
163
+ }
164
  echo '</td>';
165
  echo '<td valign="top">';
166
  echo esc_html( $component );
components/http.php CHANGED
@@ -17,7 +17,6 @@ GNU General Public License for more details.
17
  class QM_Component_HTTP extends QM_Component {
18
 
19
  var $id = 'http';
20
- var $http = array();
21
 
22
  function __construct() {
23
 
@@ -29,6 +28,18 @@ class QM_Component_HTTP extends QM_Component {
29
  # http://core.trac.wordpress.org/ticket/25747
30
  add_filter( 'pre_http_request', array( $this, 'http_response' ), 99, 3 );
31
  add_filter( 'query_monitor_menus', array( $this, 'admin_menu' ), 60 );
 
 
 
 
 
 
 
 
 
 
 
 
32
 
33
  }
34
 
@@ -84,6 +95,13 @@ class QM_Component_HTTP extends QM_Component {
84
  function http_response( $response, array $args, $url ) {
85
  $this->data['http'][$args['_qm_key']]['end'] = microtime( true );
86
  $this->data['http'][$args['_qm_key']]['response'] = $response;
 
 
 
 
 
 
 
87
  return $response;
88
  }
89
 
@@ -95,9 +113,17 @@ class QM_Component_HTTP extends QM_Component {
95
  ? __( 'HTTP Requests', 'query-monitor' )
96
  : __( 'HTTP Requests (%s)', 'query-monitor' );
97
 
98
- $menu[] = $this->menu( array(
99
- 'title' => sprintf( $title, number_format_i18n( $count ) )
100
- ) );
 
 
 
 
 
 
 
 
101
  return $menu;
102
 
103
  }
17
  class QM_Component_HTTP extends QM_Component {
18
 
19
  var $id = 'http';
 
20
 
21
  function __construct() {
22
 
28
  # http://core.trac.wordpress.org/ticket/25747
29
  add_filter( 'pre_http_request', array( $this, 'http_response' ), 99, 3 );
30
  add_filter( 'query_monitor_menus', array( $this, 'admin_menu' ), 60 );
31
+ add_filter( 'query_monitor_class', array( $this, 'admin_class' ) );
32
+
33
+ }
34
+
35
+ function admin_class( array $class ) {
36
+
37
+ if ( isset( $this->data['errors']['error'] ) )
38
+ $class[] = 'qm-error';
39
+ else if ( isset( $this->data['errors']['warning'] ) )
40
+ $class[] = 'qm-warning';
41
+
42
+ return $class;
43
 
44
  }
45
 
95
  function http_response( $response, array $args, $url ) {
96
  $this->data['http'][$args['_qm_key']]['end'] = microtime( true );
97
  $this->data['http'][$args['_qm_key']]['response'] = $response;
98
+
99
+ if ( is_wp_error( $response ) ) {
100
+ $this->data['errors']['error'][] = $args['_qm_key'];
101
+ } else {
102
+ if ( intval( wp_remote_retrieve_response_code( $response ) ) >= 400 )
103
+ $this->data['errors']['warning'][] = $args['_qm_key'];
104
+ }
105
  return $response;
106
  }
107
 
113
  ? __( 'HTTP Requests', 'query-monitor' )
114
  : __( 'HTTP Requests (%s)', 'query-monitor' );
115
 
116
+ $args = array(
117
+ 'title' => sprintf( $title, number_format_i18n( $count ) ),
118
+ );
119
+
120
+ if ( isset( $this->data['errors']['error'] ) )
121
+ $args['meta']['classname'] = 'qm-error';
122
+ else if ( isset( $this->data['errors']['warning'] ) )
123
+ $args['meta']['classname'] = 'qm-warning';
124
+
125
+ $menu[] = $this->menu( $args );
126
+
127
  return $menu;
128
 
129
  }
query-monitor.php CHANGED
@@ -2,7 +2,7 @@
2
  /*
3
  Plugin Name: Query Monitor
4
  Description: Monitoring of database queries, hooks, conditionals and more.
5
- Version: 2.5.2
6
  Plugin URI: https://github.com/johnbillion/QueryMonitor
7
  Author: John Blackbourn
8
  Author URI: https://johnblackbourn.com/
2
  /*
3
  Plugin Name: Query Monitor
4
  Description: Monitoring of database queries, hooks, conditionals and more.
5
+ Version: 2.5.3
6
  Plugin URI: https://github.com/johnbillion/QueryMonitor
7
  Author: John Blackbourn
8
  Author URI: https://johnblackbourn.com/
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: johnbillion
3
  Tags: debug, debugging, development, developer, performance, profiler, profiling, queries
4
  Requires at least: 3.5
5
  Tested up to: 3.7
6
- Stable tag: 2.5.2
7
  License: GPLv2 or later
8
 
9
  View debugging and performance information on database queries, hooks, conditionals, HTTP requests, redirects and more.
@@ -110,6 +110,12 @@ I know!
110
 
111
  == Changelog ==
112
 
 
 
 
 
 
 
113
  = 2.5.2 =
114
  * Prevent uncaught exceptions with static method actions
115
  * Misc formatting tweaks
3
  Tags: debug, debugging, development, developer, performance, profiler, profiling, queries
4
  Requires at least: 3.5
5
  Tested up to: 3.7
6
+ Stable tag: 2.5.3
7
  License: GPLv2 or later
8
 
9
  View debugging and performance information on database queries, hooks, conditionals, HTTP requests, redirects and more.
110
 
111
  == Changelog ==
112
 
113
+ = 2.5.3 =
114
+ * Show an inline error when a hook has an invalid action
115
+ * Show a warning in the admin toolbar when HTTP requests fail
116
+ * Fix the time shown when filtering queries
117
+ * Fix empty stack traces (regression at some point)
118
+
119
  = 2.5.2 =
120
  * Prevent uncaught exceptions with static method actions
121
  * Misc formatting tweaks