From f75d518c54f32f1b0207276e5214ca25498e6f0c Mon Sep 17 00:00:00 2001 From: Luis Henrique Mulinari Date: Thu, 5 Oct 2023 11:11:30 -0300 Subject: [PATCH] Check if log2logstash is defined before calling it --- ...s-potential-multi-dataset-queries-collector.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/prometheus-collectors/class-potential-multi-dataset-queries-collector.php b/prometheus-collectors/class-potential-multi-dataset-queries-collector.php index b58566d9da..dee8e78bac 100644 --- a/prometheus-collectors/class-potential-multi-dataset-queries-collector.php +++ b/prometheus-collectors/class-potential-multi-dataset-queries-collector.php @@ -51,17 +51,23 @@ public function sql_query_log( $query ): void { ] ); + if ( ! function_exists( '\Automattic\VIP\Logstash\log2logstash' ) ) { + return; + } + $backtrace = function_exists( 'wp_debug_backtrace_summary' ) ? wp_debug_backtrace_summary( null, 4, false ) : []; // phpcs:ignore \Automattic\VIP\Logstash\log2logstash( [ 'severity' => 'debug', 'feature' => 'potential_multi_dataset_queries', 'message' => 'Potential multi dataset query detected', - 'blog_id' => get_current_blog_id(), 'extra' => [ - 'uri' => isset( $_SERVER['REQUEST_URI'] ) ? esc_url_raw( $_SERVER['REQUEST_URI'] ) : '', - 'http_method' => isset( $_SERVER['REQUEST_METHOD'] ) ? sanitize_text_field( $_SERVER['REQUEST_METHOD'] ) : '', - 'backtrace' => $backtrace, + 'uri' => isset( $_SERVER['REQUEST_URI'] ) ? esc_url_raw( $_SERVER['REQUEST_URI'] ) : '', + 'http_method' => isset( $_SERVER['REQUEST_METHOD'] ) ? sanitize_text_field( $_SERVER['REQUEST_METHOD'] ) : '', + 'backtrace' => $backtrace, + 'last_global_table' => $last_global_table, + 'last_blog_table' => $last_blog_table, + 'blog_ids_count' => $blog_ids_count, ], ] );