PluginProbe
ElasticPress / 5.3.5
ElasticPress v5.3.5
5.3.5 5.3.4 3.6.5 3.6.6 4.0.0 4.0.1 4.1.0 4.2.0 4.2.1 4.2.2 4.3.0 4.3.1 4.4.0 4.4.1 4.5.0 4.5.1 4.5.2 4.6.0 4.6.1 4.7.0 4.7.1 4.7.2 5.0.0 5.0.1 5.0.2 All 108 releases
← All changes | includes/classes/QueryLogger.php +14 -5 4.6.05.3.5 View file →
@@ -88,9 +88,9 @@
88 88 *
89 89 * @param bool $should_filter_old Whether it should filter out old entries or not. Default to true, only return entries newer than the limit
90 90 * @return array
91 91 */
92 - public function get_logs( bool $should_filter_old = true ) : array {
92 + public function get_logs( bool $should_filter_old = true ): array {
93 93 $logs = ( defined( 'EP_IS_NETWORK' ) && EP_IS_NETWORK ) ?
94 94 get_site_transient( self::CACHE_KEY, [] ) :
95 95 get_transient( self::CACHE_KEY, [] );
96 96
@@ -213,9 +213,9 @@
213 213 *
214 214 * @param array $notices Current EP notices
215 215 * @return array
216 216 */
217 - public function maybe_add_notice( array $notices ) : array {
217 + public function maybe_add_notice( $notices ) {
218 218 if ( ! current_user_can( Utils\get_capability() ) ) {
219 219 return $notices;
220 220 }
221 221
@@ -276,9 +276,9 @@
276 276 * @param array $query The failed query
277 277 * @param string $type The query type
278 278 * @return array
279 279 */
280 - protected function format_log_entry( array $query, string $type ) : array {
280 + protected function format_log_entry( array $query, string $type ): array {
281 281 global $wp;
282 282
283 283 $query_time = ( ! empty( $query['time_start'] ) && ! empty( $query['time_finish'] ) ) ?
284 284 ( $query['time_finish'] - $query['time_start'] ) * 1000 :
@@ -300,9 +300,18 @@
300 300 $query['args']['headers']['X-ElasticPress-Request-ID'] :
301 301 null;
302 302
303 303 $status = wp_remote_retrieve_response_code( $query['request'] );
304 - $result = json_decode( wp_remote_retrieve_body( $query['request'] ), true );
304 + if ( is_wp_error( $query['request'] ) ) {
305 + $result = [
306 + 'is_wp_error' => true,
307 + 'code' => $query['request']->get_error_code(),
308 + 'message' => $query['request']->get_error_message(),
309 + 'data' => $query['request']->get_error_data(),
310 + ];
311 + } else {
312 + $result = json_decode( wp_remote_retrieve_body( $query['request'] ), true );
313 + }
305 314
306 315 $formatted_log = [
307 316 'wp_url' => home_url( add_query_arg( [ $_GET ], $wp->request ) ), // phpcs:ignore WordPress.Security.NonceVerification
308 317 'es_req' => $query['args']['method'] . ' ' . $query['url'],
@@ -334,9 +343,9 @@
334 343 * @param array $query The failed query
335 344 * @param string $type The query type
336 345 * @return boolean
337 346 */
338 - protected function should_log_query_type( array $query, string $type ) : bool {
347 + protected function should_log_query_type( array $query, string $type ): bool {
339 348 /**
340 349 * Filter the array with a map from query types to callables. If the callable returns true,
341 350 * the query will be logged.
342 351 *