Skip to content

Commit 19cc2e7

Browse files
committed
Emit notice when saved queries are missing due to odd DB implementations
1 parent 99248a4 commit 19cc2e7

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

plugins/performance-lab/includes/server-timing/defaults.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,17 @@ function perflab_register_default_server_timing_before_template_metrics(): void
4949
'measure_callback' => static function ( $metric ) use ( $current_function ): void {
5050
// This should never happen, but some odd database implementations may be doing it wrong.
5151
if ( ! isset( $GLOBALS['wpdb']->queries ) || ! is_array( $GLOBALS['wpdb']->queries ) ) {
52+
wp_trigger_error(
53+
$current_function,
54+
esc_html(
55+
sprintf(
56+
/* translators: 1: before-template-db-queries, 2: $wpdb->queries */
57+
__( 'Unable to compute server timing for "%1$s" because %2$s is not an array.', 'performance-lab' ),
58+
'before-template-db-queries',
59+
'$wpdb->queries'
60+
)
61+
)
62+
);
5263
return;
5364
}
5465

0 commit comments

Comments
 (0)