Query Monitor - Version 2.7.1

Version Description

  • Display a warning (rather than triggering a fatal error) for scripts and style dependencies which have gone missing during the duration of the page load.
  • Tweak some more Debug Bar add-on styles.
  • Ensure erroneous non-SELECT queries are also highlighted in red.
  • Further tweaks to QM's output if JavaScript isn't available for any reason.
  • Add PHP4-style constructors to the Debug Bar classes to avoid fatals with Debug Bar add-ons which are explicitly using them.
  • In the event that QM's JavaScript doesn't get enqueued, force the QM output to display so users can at least debug the issue.
  • Remove the abstract output() methods from abstract classes which implement QM_Output to avoid PHP bug #43200.
  • Fixing a notice in the admin component when get_current_screen() isn't an object.
Download this release

Release Info

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

Code changes from version 2.7.0 to 2.7.1

assets/query-monitor.css CHANGED
@@ -383,6 +383,7 @@ body.wp-admin.folded #qm {
383
  .qm .qm-warn,
384
  .qm .qm-warn td,
385
  .qm .qm-warn th,
 
386
  .qm .qm-warn td .qm-info {
387
  color: #f00 !important;
388
  }
@@ -484,11 +485,30 @@ html[dir="rtl"] .qm th {
484
  text-align: right !important;
485
  }
486
 
 
 
 
 
 
 
 
 
 
487
  /* Debug bar add-ons */
488
 
 
489
  .qm-debug-bar pre {
490
  font-size: 11px !important;
491
  padding: 10px !important;
 
 
 
 
 
 
 
 
 
492
  }
493
 
494
  .qm-debug-bar .left {
383
  .qm .qm-warn,
384
  .qm .qm-warn td,
385
  .qm .qm-warn th,
386
+ .qm .qm-warn td .qm-nonselectsql,
387
  .qm .qm-warn td .qm-info {
388
  color: #f00 !important;
389
  }
485
  text-align: right !important;
486
  }
487
 
488
+ /* No-JS tweaks */
489
+
490
+ .qm-no-js #qm-authentication,
491
+ .qm-no-js .qm-sort-controls,
492
+ .qm-no-js a.qm-toggle,
493
+ .qm-no-js select.qm-filter {
494
+ display: none !important;
495
+ }
496
+
497
  /* Debug bar add-ons */
498
 
499
+ .qm-debug-bar textarea,
500
  .qm-debug-bar pre {
501
  font-size: 11px !important;
502
  padding: 10px !important;
503
+ border: 1px solid #e8e8e8 !important;
504
+ margin: 4px 0 !important;
505
+ color: inherit !important;
506
+ background: transparent !important;
507
+ font-family: Menlo, Monaco, Consolas, 'Courier New', monospace !important;
508
+ }
509
+
510
+ .qm-debug-bar textarea {
511
+ resize: vertical !important;
512
  }
513
 
514
  .qm-debug-bar .left {
assets/query-monitor.js CHANGED
@@ -57,6 +57,8 @@ jQuery( function($) {
57
 
58
  var is_admin = $('body').hasClass('wp-admin');
59
 
 
 
60
  if ( $('#wp-admin-bar-query-monitor').length ) {
61
 
62
  var container = document.createDocumentFragment();
@@ -139,7 +141,7 @@ jQuery( function($) {
139
  time = QM_i18n.number_format( time, 4 );
140
 
141
  var results = table.find('.qm-items-shown').removeClass('qm-hide');
142
- results.find('.qm-items-number').text(matches.length);
143
  results.find('.qm-items-time').text(time);
144
 
145
  $(this).blur();
57
 
58
  var is_admin = $('body').hasClass('wp-admin');
59
 
60
+ $('#qm').removeClass('qm-no-js').addClass('qm-js');
61
+
62
  if ( $('#wp-admin-bar-query-monitor').length ) {
63
 
64
  var container = document.createDocumentFragment();
141
  time = QM_i18n.number_format( time, 4 );
142
 
143
  var results = table.find('.qm-items-shown').removeClass('qm-hide');
144
+ results.find('.qm-items-number').text( QM_i18n.number_format( matches.length, 0 ) );
145
  results.find('.qm-items-time').text(time);
146
 
147
  $(this).blur();
classes/debug_bar.php CHANGED
@@ -49,4 +49,8 @@ class Debug_Bar {
49
  <?php
50
  }
51
 
 
 
 
 
52
  }
49
  <?php
50
  }
51
 
52
+ public function Debug_Bar() {
53
+ Debug_Bar::__construct();
54
+ }
55
+
56
  }
classes/debug_bar_panel.php CHANGED
@@ -62,4 +62,8 @@ abstract class Debug_Bar_Panel {
62
  return $classes;
63
  }
64
 
 
 
 
 
65
  }
62
  return $classes;
63
  }
64
 
65
+ public function Debug_Bar_Panel( $title = '' ) {
66
+ Debug_Bar_Panel::__construct( $title );
67
+ }
68
+
69
  }
collectors/admin.php CHANGED
@@ -26,7 +26,7 @@ class QM_Collector_Admin extends QM_Collector {
26
 
27
  global $pagenow;
28
 
29
- if ( isset( $_GET['page'] ) ) {
30
  $this->data['base'] = get_current_screen()->base;
31
  } else {
32
  $this->data['base'] = $pagenow;
26
 
27
  global $pagenow;
28
 
29
+ if ( isset( $_GET['page'] ) && get_current_screen() != null ) {
30
  $this->data['base'] = get_current_screen()->base;
31
  } else {
32
  $this->data['base'] = $pagenow;
collectors/assets.php CHANGED
@@ -61,16 +61,31 @@ class QM_Collector_Assets extends QM_Collector {
61
  }
62
  }
63
  $raw = $this->data['raw'][ $type ];
64
- $broken = array_diff( $raw->queue, $raw->done );
 
65
 
66
  if ( !empty( $broken ) ) {
67
- foreach ( $broken as $handle ) {
68
- $item = $raw->query( $handle );
69
- $broken = array_merge( $broken, $this->get_broken_dependencies( $item, $raw ) );
 
 
 
 
70
  }
71
 
72
- $this->data['broken'][ $type ] = array_unique( $broken );
73
- sort( $this->data['broken'][ $type ] );
 
 
 
 
 
 
 
 
 
 
74
  }
75
 
76
  }
61
  }
62
  }
63
  $raw = $this->data['raw'][ $type ];
64
+ $broken = array_values( array_diff( $raw->queue, $raw->done ) );
65
+ $missing = array();
66
 
67
  if ( !empty( $broken ) ) {
68
+ foreach ( $broken as $key => $handle ) {
69
+ if ( $item = $raw->query( $handle ) ) {
70
+ $broken = array_merge( $broken, $this->get_broken_dependencies( $item, $raw ) );
71
+ } else {
72
+ unset( $broken[ $key ] );
73
+ $missing[] = $handle;
74
+ }
75
  }
76
 
77
+ if ( !empty( $broken ) ) {
78
+ $this->data['broken'][ $type ] = array_unique( $broken );
79
+ sort( $this->data['broken'][ $type ] );
80
+ }
81
+ }
82
+
83
+ if ( ! empty( $missing ) ) {
84
+ $this->data['missing'][ $type ] = array_unique( $missing );
85
+ sort( $this->data['missing'][ $type ] );
86
+ foreach ( $this->data['missing'][ $type ] as $handle ) {
87
+ $raw->add( $handle, false );
88
+ }
89
  }
90
 
91
  }
dispatchers/Html.php CHANGED
@@ -168,7 +168,9 @@ class QM_Dispatcher_Html extends QM_Dispatcher {
168
 
169
  QM_Util::include_files( $this->qm->plugin_path( 'output/html' ) );
170
 
171
- $class = array();
 
 
172
 
173
  if ( !is_admin() ) {
174
  $absolute = function_exists( 'twentyfifteen_setup' );
@@ -232,6 +234,11 @@ class QM_Dispatcher_Html extends QM_Dispatcher {
232
 
233
  echo '<script type="text/javascript">' . "\n\n";
234
  echo 'var qm = ' . json_encode( $json ) . ';' . "\n\n";
 
 
 
 
 
235
  echo '</script>' . "\n\n";
236
 
237
  }
168
 
169
  QM_Util::include_files( $this->qm->plugin_path( 'output/html' ) );
170
 
171
+ $class = array(
172
+ 'qm-no-js',
173
+ );
174
 
175
  if ( !is_admin() ) {
176
  $absolute = function_exists( 'twentyfifteen_setup' );
234
 
235
  echo '<script type="text/javascript">' . "\n\n";
236
  echo 'var qm = ' . json_encode( $json ) . ';' . "\n\n";
237
+ ?>
238
+ if ( 'undefined' === typeof QM_i18n ) {
239
+ document.getElementById( 'qm' ).style.display = 'block';
240
+ }
241
+ <?php
242
  echo '</script>' . "\n\n";
243
 
244
  }
output/Headers.php CHANGED
@@ -20,6 +20,4 @@ abstract class QM_Output_Headers implements QM_Output {
20
  $this->collector = $collector;
21
  }
22
 
23
- abstract public function output();
24
-
25
  }
20
  $this->collector = $collector;
21
  }
22
 
 
 
23
  }
output/Html.php CHANGED
@@ -18,8 +18,6 @@ abstract class QM_Output_Html implements QM_Output {
18
 
19
  protected static $file_link_format = null;
20
 
21
- abstract public function output();
22
-
23
  public function __construct( QM_Collector $collector ) {
24
  $this->collector = $collector;
25
  }
18
 
19
  protected static $file_link_format = null;
20
 
 
 
21
  public function __construct( QM_Collector $collector ) {
22
  $this->collector = $collector;
23
  }
output/html/assets.php CHANGED
@@ -56,7 +56,8 @@ class QM_Output_Html_Assets extends QM_Output_Html {
56
  echo '<tbody>';
57
 
58
  foreach ( array(
59
- 'broken' => __( 'Missing Dependencies', 'query-monitor' ),
 
60
  'header' => __( 'Header %s', 'query-monitor' ),
61
  'footer' => __( 'Footer %s', 'query-monitor' ),
62
  ) as $position => $position_label ) {
@@ -147,9 +148,10 @@ class QM_Output_Html_Assets extends QM_Output_Html {
147
  $handles = array_unique( array_merge( $dependencies->queue, $dependencies->done ) );
148
 
149
  foreach ( $handles as $handle ) {
150
- $item = $dependencies->query( $handle );
151
- if ( in_array( $script->handle, $item->deps ) ) {
152
- $dependents[] = $handle;
 
153
  }
154
  }
155
 
@@ -163,7 +165,7 @@ class QM_Output_Html_Assets extends QM_Output_Html {
163
 
164
  $data = $this->collector->get_data();
165
 
166
- if ( !empty( $data['broken'] ) ) {
167
  $class[] = 'qm-error';
168
  }
169
 
@@ -178,7 +180,7 @@ class QM_Output_Html_Assets extends QM_Output_Html {
178
  'title' => $this->collector->name()
179
  );
180
 
181
- if ( !empty( $data['broken'] ) ) {
182
  $args['meta']['classname'] = 'qm-error';
183
  }
184
 
56
  echo '<tbody>';
57
 
58
  foreach ( array(
59
+ 'missing' => __( 'Missing %s', 'query-monitor' ),
60
+ 'broken' => __( 'Broken Dependencies', 'query-monitor' ),
61
  'header' => __( 'Header %s', 'query-monitor' ),
62
  'footer' => __( 'Footer %s', 'query-monitor' ),
63
  ) as $position => $position_label ) {
148
  $handles = array_unique( array_merge( $dependencies->queue, $dependencies->done ) );
149
 
150
  foreach ( $handles as $handle ) {
151
+ if ( $item = $dependencies->query( $handle ) ) {
152
+ if ( in_array( $script->handle, $item->deps ) ) {
153
+ $dependents[] = $handle;
154
+ }
155
  }
156
  }
157
 
165
 
166
  $data = $this->collector->get_data();
167
 
168
+ if ( !empty( $data['broken'] ) or !empty( $data['missing'] ) ) {
169
  $class[] = 'qm-error';
170
  }
171
 
180
  'title' => $this->collector->name()
181
  );
182
 
183
+ if ( !empty( $data['broken'] ) or !empty( $data['missing'] ) ) {
184
  $args['meta']['classname'] = 'qm-error';
185
  }
186
 
output/html/db_callers.php CHANGED
@@ -62,7 +62,7 @@ class QM_Output_Html_DB_Callers extends QM_Output_Html {
62
 
63
  foreach ( $data['types'] as $type_name => $type_count ) {
64
  if ( isset( $row['types'][$type_name] ) ) {
65
- echo "<td valign='top' class='qm-num'>{$row['types'][$type_name]}</td>";
66
  } else {
67
  echo "<td valign='top' class='qm-num'>&nbsp;</td>";
68
  }
62
 
63
  foreach ( $data['types'] as $type_name => $type_count ) {
64
  if ( isset( $row['types'][$type_name] ) ) {
65
+ echo "<td valign='top' class='qm-num'>" . number_format_i18n( $row['types'][$type_name] ) . "</td>";
66
  } else {
67
  echo "<td valign='top' class='qm-num'>&nbsp;</td>";
68
  }
output/html/db_components.php CHANGED
@@ -64,7 +64,7 @@ class QM_Output_Html_DB_Components extends QM_Output_Html {
64
 
65
  foreach ( $data['types'] as $type_name => $type_count ) {
66
  if ( isset( $row['types'][$type_name] ) ) {
67
- echo "<td valign='top' class='qm-num'>{$row['types'][$type_name]}</td>";
68
  } else {
69
  echo "<td valign='top' class='qm-num'>&nbsp;</td>";
70
  }
64
 
65
  foreach ( $data['types'] as $type_name => $type_count ) {
66
  if ( isset( $row['types'][$type_name] ) ) {
67
+ echo "<td valign='top' class='qm-num'>" . number_format_i18n( $row['types'][$type_name] ) . "</td>";
68
  } else {
69
  echo "<td valign='top' class='qm-num'>&nbsp;</td>";
70
  }
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.7.0
6
  Plugin URI: https://querymonitor.com/
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.7.1
6
  Plugin URI: https://querymonitor.com/
7
  Author: John Blackbourn
8
  Author URI: https://johnblackbourn.com/
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: johnbillion
3
  Tags: debug, debug-bar, debugging, development, developer, performance, profiler, profiling, queries, query monitor
4
  Requires at least: 3.5
5
  Tested up to: 4.1.1
6
- Stable tag: 2.7.0
7
  License: GPLv2 or later
8
 
9
  View debugging and performance information on database queries, hooks, conditionals, HTTP requests, redirects and more.
@@ -156,6 +156,16 @@ No, I do not accept donations. If you like the plugin, I'd love for you to [leav
156
 
157
  == Changelog ==
158
 
 
 
 
 
 
 
 
 
 
 
159
  = 2.7.0 =
160
  * Detect broken dependencies for scripts and styles.
161
  * Calculate and output the dependents of scripts and styles.
3
  Tags: debug, debug-bar, debugging, development, developer, performance, profiler, profiling, queries, query monitor
4
  Requires at least: 3.5
5
  Tested up to: 4.1.1
6
+ Stable tag: 2.7.1
7
  License: GPLv2 or later
8
 
9
  View debugging and performance information on database queries, hooks, conditionals, HTTP requests, redirects and more.
156
 
157
  == Changelog ==
158
 
159
+ = 2.7.1 =
160
+ * Display a warning (rather than triggering a fatal error) for scripts and style dependencies which have gone missing during the duration of the page load.
161
+ * Tweak some more Debug Bar add-on styles.
162
+ * Ensure erroneous non-SELECT queries are also highlighted in red.
163
+ * Further tweaks to QM's output if JavaScript isn't available for any reason.
164
+ * Add PHP4-style constructors to the Debug Bar classes to avoid fatals with Debug Bar add-ons which are explicitly using them.
165
+ * In the event that QM's JavaScript doesn't get enqueued, force the QM output to display so users can at least debug the issue.
166
+ * Remove the abstract `output()` methods from abstract classes which implement `QM_Output` to avoid PHP bug #43200.
167
+ * Fixing a notice in the admin component when `get_current_screen()` isn't an object.
168
+
169
  = 2.7.0 =
170
  * Detect broken dependencies for scripts and styles.
171
  * Calculate and output the dependents of scripts and styles.