Query Monitor - Version 2.6.6

Version Description

  • More robust support for alternative database drivers (including mysqli in core)
  • Avoid warnings and notices when a custom database class is in place and it's not saving queries (ie. HyperDB)
  • Better handling when certain functions (such as memory_get_peak_usage()) are disabled
Download this release

Release Info

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

Code changes from version 2.6.5 to 2.6.6

collectors/db_queries.php CHANGED
@@ -124,6 +124,8 @@ class QM_Collector_DB_Queries extends QM_Collector {
124
  $rows = array();
125
  $types = array();
126
  $total_time = 0;
 
 
127
 
128
  foreach ( (array) $db->queries as $query ) {
129
 
124
  $rows = array();
125
  $types = array();
126
  $total_time = 0;
127
+ $has_result = false;
128
+ $has_trace = false;
129
 
130
  foreach ( (array) $db->queries as $query ) {
131
 
collectors/environment.php CHANGED
@@ -111,13 +111,20 @@ class QM_Collector_Environment extends QM_Collector {
111
  " );
112
 
113
  if ( is_resource( $db->dbh ) ) {
114
- $version = mysql_get_server_info( $db->dbh );
115
- $driver = 'mysql';
116
- } else if ( is_object( $db->dbh ) and method_exists( $db->dbh, 'db_version' ) ) {
117
- $version = $db->dbh->db_version();
118
- $driver = get_class( $db->dbh );
119
  } else {
120
- $version = $driver = '<span class="qm-warn">' . __( 'Unknown', 'query-monitor' ) . '</span>';
 
 
 
 
 
 
 
121
  }
122
 
123
  $this->data['db'][$id] = array(
111
  " );
112
 
113
  if ( is_resource( $db->dbh ) ) {
114
+ # Standard mysql extension
115
+ $driver = 'mysql';
116
+ } else if ( is_object( $db->dbh ) ) {
117
+ # mysqli or PDO
118
+ $driver = get_class( $db->dbh );
119
  } else {
120
+ # Who knows?
121
+ $driver = '<span class="qm-warn">' . __( 'Unknown', 'query-monitor' ) . '</span>';
122
+ }
123
+
124
+ if ( method_exists( $db, 'db_version' ) ) {
125
+ $version = $db->db_version();
126
+ } else {
127
+ $version = '<span class="qm-warn">' . __( 'Unknown', 'query-monitor' ) . '</span>';
128
  }
129
 
130
  $this->data['db'][$id] = array(
collectors/overview.php CHANGED
@@ -36,7 +36,14 @@ class QM_Collector_Overview extends QM_Collector {
36
  else
37
  $this->data['time_usage'] = 0;
38
 
39
- $this->data['memory'] = memory_get_peak_usage();
 
 
 
 
 
 
 
40
  $this->data['memory_limit'] = QM_Util::convert_hr_to_bytes( ini_get( 'memory_limit' ) );
41
  $this->data['memory_usage'] = ( 100 / $this->data['memory_limit'] ) * $this->data['memory'];
42
 
36
  else
37
  $this->data['time_usage'] = 0;
38
 
39
+ if ( function_exists( 'memory_get_peak_usage' ) ) {
40
+ $this->data['memory'] = memory_get_peak_usage();
41
+ } else if ( function_exists( 'memory_get_usage' ) ) {
42
+ $this->data['memory'] = memory_get_usage();
43
+ } else {
44
+ $this->data['memory'] = 0;
45
+ }
46
+
47
  $this->data['memory_limit'] = QM_Util::convert_hr_to_bytes( ini_get( 'memory_limit' ) );
48
  $this->data['memory_usage'] = ( 100 / $this->data['memory_limit'] ) * $this->data['memory'];
49
 
dispatchers/Html.php CHANGED
@@ -153,7 +153,7 @@ class QM_Dispatcher_Html extends QM_Dispatcher {
153
  public function js_admin_bar_menu() {
154
 
155
  $class = implode( ' ', apply_filters( 'query_monitor_class', array( QM_Util::wpv() ) ) );
156
- $title = implode( ' &nbsp; ', apply_filters( 'query_monitor_title', array() ) );
157
 
158
  if ( empty( $title ) )
159
  $title = __( 'Query Monitor', 'query-monitor' );
153
  public function js_admin_bar_menu() {
154
 
155
  $class = implode( ' ', apply_filters( 'query_monitor_class', array( QM_Util::wpv() ) ) );
156
+ $title = implode( '&nbsp;&nbsp;&nbsp;', apply_filters( 'query_monitor_title', array() ) );
157
 
158
  if ( empty( $title ) )
159
  $title = __( 'Query Monitor', 'query-monitor' );
output/html/db_queries.php CHANGED
@@ -146,27 +146,32 @@ class QM_Output_Html_DB_Queries extends QM_Output_Html {
146
  echo '<th colspan="' . $span . '">' . sprintf( __( '%s Queries', 'query-monitor' ), $name ) . '</th>';
147
  echo '</tr>';
148
 
149
- if ( ! $db->has_trace ) {
 
 
 
 
 
 
 
 
 
150
  echo '<tr>';
151
- echo '<td colspan="' . $span . '" class="qm-warn">' . sprintf( __( 'Extended query information such as the component and affected rows is not available. Query Monitor was unable to symlink its <code>db.php</code> file into place. <a href="%s" target="_blank">See this wiki page for more information.</a>', 'query-monitor' ),
152
- 'https://github.com/johnbillion/query-monitor/wiki/db.php-Symlink'
153
- ) . '</td>';
154
- echo '</tr>';
155
- }
156
 
157
- echo '<tr>';
158
- echo '<th scope="col" class="qm-sorted-asc">&nbsp;' . $this->build_sorter() . '</th>';
159
- echo '<th scope="col">' . __( 'Query', 'query-monitor' ) . $this->build_filter( 'type', array_keys( $db->types ) ) . '</th>';
160
- echo '<th scope="col">' . __( 'Caller', 'query-monitor' ) . $this->build_filter( 'caller', wp_list_pluck( $data['times'], 'caller' ) ) . '</th>';
161
 
162
- if ( $db->has_trace )
163
- echo '<th scope="col">' . __( 'Component', 'query-monitor' ) . $this->build_filter( 'component', wp_list_pluck( $data['component_times'], 'component' ) ) . '</th>';
164
 
165
- if ( $db->has_result )
166
- echo '<th scope="col">' . __( 'Rows', 'query-monitor' ) . $this->build_sorter() . '</th>';
 
 
167
 
168
- echo '<th scope="col" class="qm-num">' . __( 'Time', 'query-monitor' ) . $this->build_sorter() . '</th>';
169
- echo '</tr>';
170
  echo '</thead>';
171
 
172
  if ( !empty( $db->rows ) ) {
146
  echo '<th colspan="' . $span . '">' . sprintf( __( '%s Queries', 'query-monitor' ), $name ) . '</th>';
147
  echo '</tr>';
148
 
149
+ if ( !empty( $db->rows ) ) {
150
+
151
+ if ( ! $db->has_trace ) {
152
+ echo '<tr>';
153
+ echo '<td colspan="' . $span . '" class="qm-warn">' . sprintf( __( 'Extended query information such as the component and affected rows is not available. Query Monitor was unable to symlink its <code>db.php</code> file into place. <a href="%s" target="_blank">See this wiki page for more information.</a>', 'query-monitor' ),
154
+ 'https://github.com/johnbillion/query-monitor/wiki/db.php-Symlink'
155
+ ) . '</td>';
156
+ echo '</tr>';
157
+ }
158
+
159
  echo '<tr>';
160
+ echo '<th scope="col" class="qm-sorted-asc">&nbsp;' . $this->build_sorter() . '</th>';
161
+ echo '<th scope="col">' . __( 'Query', 'query-monitor' ) . $this->build_filter( 'type', array_keys( $db->types ) ) . '</th>';
162
+ echo '<th scope="col">' . __( 'Caller', 'query-monitor' ) . $this->build_filter( 'caller', wp_list_pluck( $data['times'], 'caller' ) ) . '</th>';
 
 
163
 
164
+ if ( $db->has_trace )
165
+ echo '<th scope="col">' . __( 'Component', 'query-monitor' ) . $this->build_filter( 'component', wp_list_pluck( $data['component_times'], 'component' ) ) . '</th>';
 
 
166
 
167
+ if ( $db->has_result )
168
+ echo '<th scope="col">' . __( 'Rows', 'query-monitor' ) . $this->build_sorter() . '</th>';
169
 
170
+ echo '<th scope="col" class="qm-num">' . __( 'Time', 'query-monitor' ) . $this->build_sorter() . '</th>';
171
+ echo '</tr>';
172
+
173
+ }
174
 
 
 
175
  echo '</thead>';
176
 
177
  if ( !empty( $db->rows ) ) {
output/html/overview.php CHANGED
@@ -62,7 +62,13 @@ class QM_Output_Html_Overview extends QM_Output_Html {
62
  echo '<tbody>';
63
  echo '<tr>';
64
  echo "<td>{$total_stime}{$time_usage}</td>";
65
- echo '<td>' . sprintf( __( '%s kB', 'query-monitor' ), number_format_i18n( $data['memory'] / 1024 ) ) . $memory_usage . '</td>';
 
 
 
 
 
 
66
  if ( isset( $db_query_num ) ) {
67
  echo "<td>{$db_stime}</td>";
68
  echo '<td>';
@@ -86,13 +92,19 @@ class QM_Output_Html_Overview extends QM_Output_Html {
86
 
87
  $data = $this->collector->get_data();
88
 
 
 
 
 
 
 
89
  $title[] = sprintf(
90
  _x( '%s<small>S</small>', 'page load time', 'query-monitor' ),
91
  number_format_i18n( $data['time'], 2 )
92
  );
93
  $title[] = sprintf(
94
  _x( '%s<small>MB</small>', 'memory usage', 'query-monitor' ),
95
- number_format_i18n( ( $data['memory'] / 1024 / 1024 ), 2 )
96
  );
97
  return $title;
98
  }
62
  echo '<tbody>';
63
  echo '<tr>';
64
  echo "<td>{$total_stime}{$time_usage}</td>";
65
+
66
+ if ( empty( $data['memory'] ) ) {
67
+ echo '<td><em>' . __( 'Unknown', 'query-monitor' ) . '</em><br><span class="qm-info">' . __( 'Neither memory_get_peak_usage() nor memory_get_usage() are available. Speak to your host and get them to sort it out.', 'query-monitor' ) . '</span></td>';
68
+ } else {
69
+ echo '<td>' . sprintf( __( '%s kB', 'query-monitor' ), number_format_i18n( $data['memory'] / 1024 ) ) . $memory_usage . '</td>';
70
+ }
71
+
72
  if ( isset( $db_query_num ) ) {
73
  echo "<td>{$db_stime}</td>";
74
  echo '<td>';
92
 
93
  $data = $this->collector->get_data();
94
 
95
+ if ( empty( $data['memory'] ) ) {
96
+ $memory = '??';
97
+ } else {
98
+ $memory = number_format_i18n( ( $data['memory'] / 1024 / 1024 ), 2 );
99
+ }
100
+
101
  $title[] = sprintf(
102
  _x( '%s<small>S</small>', 'page load time', 'query-monitor' ),
103
  number_format_i18n( $data['time'], 2 )
104
  );
105
  $title[] = sprintf(
106
  _x( '%s<small>MB</small>', 'memory usage', 'query-monitor' ),
107
+ $memory
108
  );
109
  return $title;
110
  }
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.6.5
6
  Plugin URI: https://github.com/johnbillion/query-monitor
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.6.6
6
  Plugin URI: https://github.com/johnbillion/query-monitor
7
  Author: John Blackbourn
8
  Author URI: https://johnblackbourn.com/
readme.txt CHANGED
@@ -1,9 +1,9 @@
1
  === Query Monitor ===
2
  Contributors: johnbillion
3
- Tags: debug, debugging, development, developer, performance, profiler, profiling, queries
4
  Requires at least: 3.5
5
  Tested up to: 3.9
6
- Stable tag: 2.6.5
7
  License: GPLv2 or later
8
 
9
  View debugging and performance information on database queries, hooks, conditionals, HTTP requests, redirects and more.
@@ -133,6 +133,10 @@ Long answer: Query Monitor has a small impact on page generation time because it
133
 
134
  On pages that have an especially high number of database queries (in the hundreds), Query Monitor currently uses more memory than I would like it to. This is due to the amount of data that is captured in the stack trace for each query. I have been and will be working to continually reduce this.
135
 
 
 
 
 
136
  = Where can I suggest a new feature or report a bug? =
137
 
138
  Please use [the issue tracker on Query Monitor's GitHub repo](https://github.com/johnbillion/QueryMonitor/issues) as it's easier to keep track of issues there, rather than on the wordpress.org support forums.
@@ -143,6 +147,11 @@ No, I do not accept donations. If you like the plugin, I'd love for you to [leav
143
 
144
  == Changelog ==
145
 
 
 
 
 
 
146
  = 2.6.5 =
147
  * Avoid the "Class 'QM_Backtrace' not found" error
148
  * Correct the layout of the Slow Queries and Query Errors panels
1
  === Query Monitor ===
2
  Contributors: johnbillion
3
+ Tags: debug, debugging, development, developer, performance, profiler, profiling, queries, query monitor
4
  Requires at least: 3.5
5
  Tested up to: 3.9
6
+ Stable tag: 2.6.6
7
  License: GPLv2 or later
8
 
9
  View debugging and performance information on database queries, hooks, conditionals, HTTP requests, redirects and more.
133
 
134
  On pages that have an especially high number of database queries (in the hundreds), Query Monitor currently uses more memory than I would like it to. This is due to the amount of data that is captured in the stack trace for each query. I have been and will be working to continually reduce this.
135
 
136
+ = Are there any add-on plugins for Query Monitor? =
137
+
138
+ Yep, the first one was released recently: [Query Monitor bbPress & BuddyPress Conditionals](https://wordpress.org/plugins/query-monitor-bbpress-buddypress-conditionals/) by Stephen Edgar.
139
+
140
  = Where can I suggest a new feature or report a bug? =
141
 
142
  Please use [the issue tracker on Query Monitor's GitHub repo](https://github.com/johnbillion/QueryMonitor/issues) as it's easier to keep track of issues there, rather than on the wordpress.org support forums.
147
 
148
  == Changelog ==
149
 
150
+ = 2.6.6 =
151
+ * More robust support for alternative database drivers (including `mysqli` in core)
152
+ * Avoid warnings and notices when a custom database class is in place and it's not saving queries (ie. HyperDB)
153
+ * Better handling when certain functions (such as `memory_get_peak_usage()`) are disabled
154
+
155
  = 2.6.5 =
156
  * Avoid the "Class 'QM_Backtrace' not found" error
157
  * Correct the layout of the Slow Queries and Query Errors panels