Query Monitor - Version 2.5.4

Version Description

  • Avoid a fatal error when strict errors are triggered at compile time
  • Avoid a warning when PDO or Mysqli is in use
  • Updated CSS for WordPress 3.8. Retains support for default 3.7 and MP6 on 3.7
  • Tweak PHP error_reporting in the Environment component
Download this release

Release Info

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

Code changes from version 2.5.3 to 2.5.4

assets/query-monitor.css CHANGED
@@ -16,12 +16,13 @@ GNU General Public License for more details.
16
 
17
 
18
  #wpadminbar .quicklinks .menupop ul li.qm-true > a {
19
- color: #4a4 !important;
20
- }
21
- body.mp6 #wpadminbar .quicklinks .menupop ul li.qm-true > a {
22
  color: #8c8 !important;
23
  }
24
- body.mp6 #wpadminbar .quicklinks .menupop ul li.qm-true > a:hover {
 
 
 
 
25
  color: #4a4 !important;
26
  }
27
 
@@ -34,10 +35,16 @@ body.mp6 #wpadminbar .quicklinks .menupop ul li.qm-true > a:hover {
34
  }
35
 
36
  #wp-admin-bar-query-monitor-stricts {
 
 
 
37
  background-color: #eee !important;
38
  }
39
 
40
  #wpadminbar .qm-strict {
 
 
 
41
  background-color: #000;
42
  }
43
 
@@ -73,10 +80,7 @@ body.mp6 #wpadminbar .quicklinks .menupop ul li.qm-true > a:hover {
73
  color: #fff !important;
74
  }
75
 
76
- #wp-admin-bar-query-monitor-stricts a {
77
- color: #555 !important;
78
- }
79
-
80
  #wp-admin-bar-query-monitor-notices a,
81
  #wp-admin-bar-query-monitor-expensive a,
82
  #wp-admin-bar-query-monitor-warnings a,
@@ -84,17 +88,22 @@ body.mp6 #wpadminbar .quicklinks .menupop ul li.qm-true > a:hover {
84
  color: #eee !important;
85
  }
86
 
 
 
 
 
87
  #wp-admin-bar-query-monitor small {
88
  font-size: 11px !important;
89
  }
90
 
91
- #wp-admin-bar-query-monitor.hover a small,
92
- #wp-admin-bar-query-monitor.hover a .ab-label {
93
  text-shadow: none !important;
94
  color: #333 !important;
95
  }
96
- body.mp6 #wp-admin-bar-query-monitor.hover a small,
97
- body.mp6 #wp-admin-bar-query-monitor.hover a .ab-label {
 
98
  color: #2ea2cc !important;
99
  }
100
 
@@ -104,18 +113,40 @@ body.mp6 #wp-admin-bar-query-monitor.hover a .ab-label {
104
  }
105
 
106
  #wpadminbar #wp-admin-bar-query-monitor .ab-icon {
107
- font: 16px/16px 'Open Sans', sans-serif !important;
108
  width: auto !important;
109
- padding: 0 2px !important;
110
- color: #999 !important;
111
- line-height: 32px !important;
112
  display: none !important;
 
 
 
 
 
113
  }
114
 
115
  @media screen and (max-width: 782px) {
116
- body.mp6 #wpadminbar #wp-admin-bar-query-monitor .ab-icon {
 
117
  display: block !important;
118
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
119
  }
120
 
121
  #qm {
16
 
17
 
18
  #wpadminbar .quicklinks .menupop ul li.qm-true > a {
 
 
 
19
  color: #8c8 !important;
20
  }
21
+ body:not(.mp6) #wpadminbar .quicklinks .menupop.qm-wp-37 ul li.qm-true > a {
22
+ color: #4a4 !important;
23
+ }
24
+
25
+ #wpadminbar .quicklinks .menupop ul li.qm-true > a:hover {
26
  color: #4a4 !important;
27
  }
28
 
35
  }
36
 
37
  #wp-admin-bar-query-monitor-stricts {
38
+ background-color: #555 !important;
39
+ }
40
+ body:not(.mp6) .qm-wp-37 #wp-admin-bar-query-monitor-stricts {
41
  background-color: #eee !important;
42
  }
43
 
44
  #wpadminbar .qm-strict {
45
+ background-color: #3c3c3c;
46
+ }
47
+ body:not(.mp6) #wpadminbar .qm-wp-37 .qm-strict {
48
  background-color: #000;
49
  }
50
 
80
  color: #fff !important;
81
  }
82
 
83
+ #wp-admin-bar-query-monitor-stricts a,
 
 
 
84
  #wp-admin-bar-query-monitor-notices a,
85
  #wp-admin-bar-query-monitor-expensive a,
86
  #wp-admin-bar-query-monitor-warnings a,
88
  color: #eee !important;
89
  }
90
 
91
+ body:not(.mp6) .qm-wp-37 #wp-admin-bar-query-monitor-stricts a {
92
+ color: #555 !important;
93
+ }
94
+
95
  #wp-admin-bar-query-monitor small {
96
  font-size: 11px !important;
97
  }
98
 
99
+ body:not(.mp6) #wp-admin-bar-query-monitor.qm-wp-37.hover a small,
100
+ body:not(.mp6) #wp-admin-bar-query-monitor.qm-wp-37.hover a .ab-label {
101
  text-shadow: none !important;
102
  color: #333 !important;
103
  }
104
+ #wp-admin-bar-query-monitor.hover a small,
105
+ #wp-admin-bar-query-monitor.hover a .ab-label {
106
+ text-shadow: none !important;
107
  color: #2ea2cc !important;
108
  }
109
 
113
  }
114
 
115
  #wpadminbar #wp-admin-bar-query-monitor .ab-icon {
116
+ font: 18px/44px 'Open Sans', sans-serif !important;
117
  width: auto !important;
118
+ padding: 0 10px !important;
119
+ color: #aaa !important;
 
120
  display: none !important;
121
+ background: red !important;
122
+ }
123
+ /* for mp6 on 3.7, reduce the menu icon line height */
124
+ body.mp6 #wpadminbar #wp-admin-bar-query-monitor.qm-wp-37 .ab-icon {
125
+ line-height: 30px !important;
126
  }
127
 
128
  @media screen and (max-width: 782px) {
129
+ /* force menu icon to show up */
130
+ #wpadminbar #wp-admin-bar-query-monitor .ab-icon {
131
  display: block !important;
132
  }
133
+ /* hide menu text */
134
+ #wpadminbar #wp-admin-bar-query-monitor .ab-label {
135
+ display: none !important;
136
+ }
137
+ /* for default 3.7, override our rule above and hide the menu icon */
138
+ body:not(.mp6) #wpadminbar #wp-admin-bar-query-monitor.qm-wp-37 .ab-icon {
139
+ display: none !important;
140
+ }
141
+ /* for default 3.7, override our rule above and show the menu text */
142
+ body:not(.mp6) #wpadminbar #wp-admin-bar-query-monitor.qm-wp-37 .ab-label {
143
+ display: inline-block !important;
144
+ }
145
+ }
146
+
147
+ /* for 3.7, fix the label margin */
148
+ #wpadminbar #wp-admin-bar-query-monitor.qm-wp-37 .ab-label {
149
+ margin: 0 !important;
150
  }
151
 
152
  #qm {
components/environment.php CHANGED
@@ -24,7 +24,6 @@ class QM_Component_Environment extends QM_Component {
24
  'post_max_size',
25
  'display_errors',
26
  'log_errors',
27
- # 'error_log',
28
  );
29
 
30
  function __construct() {
@@ -46,20 +45,10 @@ class QM_Component_Environment extends QM_Component {
46
  $this->data['php']['variables'][$setting]['before'] = $val;
47
  }
48
 
49
- if ( isset( $wpdb->qm_php_vars ) and isset( $wpdb->qm_php_vars['error_reporting'] ) )
50
- $val = $wpdb->qm_php_vars['error_reporting'];
51
- else
52
- $val = implode( '<br/>', $this->get_error_reporting() );
53
-
54
- $this->data['php']['variables']['error_reporting']['before'] = $val;
55
-
56
  }
57
 
58
- function get_error_reporting() {
59
-
60
- # @TODO move this into QM_Util and call it in QueryMonitorDB too
61
 
62
- $error_reporting = error_reporting();
63
  $levels = array();
64
 
65
  $constants = array(
@@ -67,6 +56,10 @@ class QM_Component_Environment extends QM_Component {
67
  'E_WARNING',
68
  'E_PARSE',
69
  'E_NOTICE',
 
 
 
 
70
  'E_USER_ERROR',
71
  'E_USER_WARNING',
72
  'E_USER_NOTICE',
@@ -124,8 +117,19 @@ class QM_Component_Environment extends QM_Component {
124
  WHERE Variable_name IN ( '" . implode( "', '", array_keys( $mysql_vars ) ) . "' )
125
  " );
126
 
 
 
 
 
 
 
 
 
 
 
127
  $this->data['db'][$id] = array(
128
- 'version' => mysql_get_server_info( $db->dbh ),
 
129
  'user' => $db->dbuser,
130
  'host' => $db->dbhost,
131
  'name' => $db->dbname,
@@ -162,8 +166,9 @@ class QM_Component_Environment extends QM_Component {
162
  foreach ( $this->php_vars as $setting )
163
  $this->data['php']['variables'][$setting]['after'] = ini_get( $setting );
164
 
165
- $this->data['php']['variables']['error_reporting']['after'] = implode( '<br/>', $this->get_error_reporting() );
166
 
 
167
  $this->data['wp'] = array(
168
  'version' => $wp_version,
169
  'WP_DEBUG' => QM_Util::format_bool_constant( 'WP_DEBUG' ),
@@ -202,7 +207,7 @@ class QM_Component_Environment extends QM_Component {
202
  echo '<tbody>';
203
 
204
  echo '<tr>';
205
- echo '<td rowspan="' . ( 2 + count( $data['php']['variables'] ) ) . '">PHP</td>';
206
  echo '<td>version</td>';
207
  echo "<td>{$data['php']['version']}</td>";
208
  echo '</tr>';
@@ -224,6 +229,13 @@ class QM_Component_Environment extends QM_Component {
224
  echo '</tr>';
225
  }
226
 
 
 
 
 
 
 
 
227
  if ( isset( $data['db'] ) ) {
228
 
229
  foreach ( $data['db'] as $id => $db ) {
@@ -234,11 +246,16 @@ class QM_Component_Environment extends QM_Component {
234
  $name = $id . '<br />MySQL';
235
 
236
  echo '<tr>';
237
- echo '<td rowspan="' . ( 4 + count( $db['variables'] ) ) . '">' . $name . '</td>';
238
  echo '<td>version</td>';
239
  echo '<td>' . $db['version'] . '</td>';
240
  echo '</tr>';
241
 
 
 
 
 
 
242
  echo '<tr>';
243
  echo '<td>user</td>';
244
  echo '<td>' . $db['user'] . '</td>';
24
  'post_max_size',
25
  'display_errors',
26
  'log_errors',
 
27
  );
28
 
29
  function __construct() {
45
  $this->data['php']['variables'][$setting]['before'] = $val;
46
  }
47
 
 
 
 
 
 
 
 
48
  }
49
 
50
+ public static function get_error_levels( $error_reporting ) {
 
 
51
 
 
52
  $levels = array();
53
 
54
  $constants = array(
56
  'E_WARNING',
57
  'E_PARSE',
58
  'E_NOTICE',
59
+ 'E_CORE_ERROR',
60
+ 'E_CORE_WARNING',
61
+ 'E_COMPILE_ERROR',
62
+ 'E_COMPILE_WARNING',
63
  'E_USER_ERROR',
64
  'E_USER_WARNING',
65
  'E_USER_NOTICE',
117
  WHERE Variable_name IN ( '" . implode( "', '", array_keys( $mysql_vars ) ) . "' )
118
  " );
119
 
120
+ if ( is_resource( $db->dbh ) ) {
121
+ $version = mysql_get_server_info( $db->dbh );
122
+ $driver = 'mysql';
123
+ } else if ( is_object( $db->dbh ) and method_exists( $db->dbh, 'db_version' ) ) {
124
+ $version = $db->dbh->db_version();
125
+ $driver = get_class( $db->dbh );
126
+ } else {
127
+ $version = $driver = '<span class="qm-warn">' . __( 'Unknown', 'query-monitor' ) . '</span>';
128
+ }
129
+
130
  $this->data['db'][$id] = array(
131
+ 'version' => $version,
132
+ 'driver' => $driver,
133
  'user' => $db->dbuser,
134
  'host' => $db->dbhost,
135
  'name' => $db->dbname,
166
  foreach ( $this->php_vars as $setting )
167
  $this->data['php']['variables'][$setting]['after'] = ini_get( $setting );
168
 
169
+ $this->data['php']['error_reporting'] = error_reporting();
170
 
171
+ # @TODO put WP's other debugging constants in here, eg. SCRIPT_DEBUG
172
  $this->data['wp'] = array(
173
  'version' => $wp_version,
174
  'WP_DEBUG' => QM_Util::format_bool_constant( 'WP_DEBUG' ),
207
  echo '<tbody>';
208
 
209
  echo '<tr>';
210
+ echo '<td rowspan="' . ( 3 + count( $data['php']['variables'] ) ) . '">PHP</td>';
211
  echo '<td>version</td>';
212
  echo "<td>{$data['php']['version']}</td>";
213
  echo '</tr>';
229
  echo '</tr>';
230
  }
231
 
232
+ $error_levels = implode( '<br/>', self::get_error_levels( $data['php']['error_reporting'] ) );
233
+
234
+ echo '<tr>';
235
+ echo '<td>error_reporting</td>';
236
+ echo "<td>{$data['php']['error_reporting']}<br><span class='qm-info'>{$error_levels}</span></td>";
237
+ echo '</tr>';
238
+
239
  if ( isset( $data['db'] ) ) {
240
 
241
  foreach ( $data['db'] as $id => $db ) {
246
  $name = $id . '<br />MySQL';
247
 
248
  echo '<tr>';
249
+ echo '<td rowspan="' . ( 5 + count( $db['variables'] ) ) . '">' . $name . '</td>';
250
  echo '<td>version</td>';
251
  echo '<td>' . $db['version'] . '</td>';
252
  echo '</tr>';
253
 
254
+ echo '<tr>';
255
+ echo '<td>driver</td>';
256
+ echo '<td>' . $db['driver'] . '</td>';
257
+ echo '</tr>';
258
+
259
  echo '<tr>';
260
  echo '<td>user</td>';
261
  echo '<td>' . $db['user'] . '</td>';
components/php_errors.php CHANGED
@@ -193,7 +193,8 @@ class QM_Component_PHP_Errors extends QM_Component {
193
  if ( error_reporting() > 0 ) {
194
 
195
  $trace = new QM_Backtrace;
196
- $func = reset( $trace->get_stack() );
 
197
  $key = md5( $message . $file . $line . $func );
198
 
199
  $filename = QM_Util::standard_dir( $file, '' );
193
  if ( error_reporting() > 0 ) {
194
 
195
  $trace = new QM_Backtrace;
196
+ $stack = $trace->get_stack();
197
+ $func = reset( $stack );
198
  $key = md5( $message . $file . $line . $func );
199
 
200
  $filename = QM_Util::standard_dir( $file, '' );
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.3
6
  Plugin URI: https://github.com/johnbillion/QueryMonitor
7
  Author: John Blackbourn
8
  Author URI: https://johnblackbourn.com/
@@ -26,7 +26,9 @@ GNU General Public License for more details.
26
 
27
  defined( 'ABSPATH' ) or die();
28
 
29
- require_once dirname( __FILE__ ) . '/autoloader.php';
 
 
30
 
31
  class QueryMonitor extends QM_Plugin {
32
 
@@ -78,6 +80,13 @@ class QueryMonitor extends QM_Plugin {
78
 
79
  public function activate( $sitewide = false ) {
80
 
 
 
 
 
 
 
 
81
  if ( $admins = QM_Util::get_admins() )
82
  $admins->add_cap( 'view_query_monitor' );
83
 
@@ -131,7 +140,7 @@ class QueryMonitor extends QM_Plugin {
131
  public function js_admin_bar_menu() {
132
 
133
  $class = implode( ' ', apply_filters( 'query_monitor_class', array( QM_Util::wpv() ) ) );
134
- $title = implode( ' / ', apply_filters( 'query_monitor_title', array() ) );
135
 
136
  if ( empty( $title ) )
137
  $title = __( 'Query Monitor', 'query-monitor' );
@@ -184,6 +193,9 @@ class QueryMonitor extends QM_Plugin {
184
 
185
  public function action_shutdown() {
186
 
 
 
 
187
  if ( QM_Util::is_ajax() )
188
  $this->output_ajax();
189
  else if ( $this->did_footer )
@@ -203,6 +215,7 @@ class QueryMonitor extends QM_Plugin {
203
  if ( QM_Util::is_ajax() )
204
  ob_start();
205
 
 
206
  if ( !defined( 'DONOTCACHEPAGE' ) )
207
  define( 'DONOTCACHEPAGE', 1 );
208
 
@@ -229,8 +242,6 @@ class QueryMonitor extends QM_Plugin {
229
 
230
  public function output_footer() {
231
 
232
- if ( !$this->show_query_monitor() )
233
- return;
234
 
235
  # Flush the output buffer to avoid crashes
236
  if ( !is_feed() ) {
@@ -276,9 +287,6 @@ class QueryMonitor extends QM_Plugin {
276
  if ( headers_sent() )
277
  return;
278
 
279
- if ( !$this->show_query_monitor() )
280
- return;
281
-
282
  foreach ( $this->get_components() as $component )
283
  $component->process();
284
 
2
  /*
3
  Plugin Name: Query Monitor
4
  Description: Monitoring of database queries, hooks, conditionals and more.
5
+ Version: 2.5.4
6
  Plugin URI: https://github.com/johnbillion/QueryMonitor
7
  Author: John Blackbourn
8
  Author URI: https://johnblackbourn.com/
26
 
27
  defined( 'ABSPATH' ) or die();
28
 
29
+ # No autoloaders for us. See https://github.com/johnbillion/QueryMonitor/issues/7
30
+ foreach ( array( 'Backtrace', 'Component', 'Plugin', 'Util' ) as $f )
31
+ require_once dirname( __FILE__ ) . "/{$f}.php";
32
 
33
  class QueryMonitor extends QM_Plugin {
34
 
80
 
81
  public function activate( $sitewide = false ) {
82
 
83
+ if ( ! extension_loaded( 'spl' ) ) {
84
+ die( sprintf( 'This plugin requires the <a href="%s">%s</a> extension, which is not installed on your server.',
85
+ 'http://php.net/manual/book.spl.php',
86
+ 'Standard PHP Library (SPL)'
87
+ ) );
88
+ }
89
+
90
  if ( $admins = QM_Util::get_admins() )
91
  $admins->add_cap( 'view_query_monitor' );
92
 
140
  public function js_admin_bar_menu() {
141
 
142
  $class = implode( ' ', apply_filters( 'query_monitor_class', array( QM_Util::wpv() ) ) );
143
+ $title = implode( ' &nbsp; ', apply_filters( 'query_monitor_title', array() ) );
144
 
145
  if ( empty( $title ) )
146
  $title = __( 'Query Monitor', 'query-monitor' );
193
 
194
  public function action_shutdown() {
195
 
196
+ if ( !$this->show_query_monitor() )
197
+ return;
198
+
199
  if ( QM_Util::is_ajax() )
200
  $this->output_ajax();
201
  else if ( $this->did_footer )
215
  if ( QM_Util::is_ajax() )
216
  ob_start();
217
 
218
+ # @todo move into output_html
219
  if ( !defined( 'DONOTCACHEPAGE' ) )
220
  define( 'DONOTCACHEPAGE', 1 );
221
 
242
 
243
  public function output_footer() {
244
 
 
 
245
 
246
  # Flush the output buffer to avoid crashes
247
  if ( !is_feed() ) {
287
  if ( headers_sent() )
288
  return;
289
 
 
 
 
290
  foreach ( $this->get_components() as $component )
291
  $component->process();
292
 
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  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.3
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.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
2
  Contributors: johnbillion
3
  Tags: debug, debugging, development, developer, performance, profiler, profiling, queries
4
  Requires at least: 3.5
5
+ Tested up to: 3.8
6
+ Stable tag: 2.5.4
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.4 =
114
+ * Avoid a fatal error when strict errors are triggered at compile time
115
+ * Avoid a warning when PDO or Mysqli is in use
116
+ * Updated CSS for WordPress 3.8. Retains support for default 3.7 and MP6 on 3.7
117
+ * Tweak PHP error_reporting in the Environment component
118
+
119
  = 2.5.3 =
120
  * Show an inline error when a hook has an invalid action
121
  * Show a warning in the admin toolbar when HTTP requests fail
wp-content/db.php CHANGED
@@ -25,10 +25,12 @@ GNU General Public License for more details.
25
 
26
  defined( 'ABSPATH' ) or die();
27
 
28
- if ( ! is_readable( $autoloader = dirname( __FILE__ ) . '/../autoloader.php' ) )
29
- return;
30
-
31
- include_once $autoloader;
 
 
32
 
33
  if ( !defined( 'SAVEQUERIES' ) )
34
  define( 'SAVEQUERIES', true );
@@ -70,7 +72,7 @@ class QueryMonitorDB extends wpdb {
70
  if ( ! $this->ready )
71
  return false;
72
 
73
- if ( $this->show_errors and class_exists( 'QM_Component_DB_Queries' ) )
74
  $this->hide_errors();
75
 
76
  // some queries are made before the plugins have been loaded, and thus cannot be filtered with this method
25
 
26
  defined( 'ABSPATH' ) or die();
27
 
28
+ # No autoloaders for us. See https://github.com/johnbillion/QueryMonitor/issues/7
29
+ foreach ( array( 'Backtrace', 'Component', 'Plugin', 'Util' ) as $f ) {
30
+ if ( ! is_readable( $file = dirname( __FILE__ ) . "/../{$f}.php" ) )
31
+ return;
32
+ require_once $file;
33
+ }
34
 
35
  if ( !defined( 'SAVEQUERIES' ) )
36
  define( 'SAVEQUERIES', true );
72
  if ( ! $this->ready )
73
  return false;
74
 
75
+ if ( $this->show_errors )
76
  $this->hide_errors();
77
 
78
  // some queries are made before the plugins have been loaded, and thus cannot be filtered with this method