From 35cae96dcda021fccac559efd5e12762accc682d Mon Sep 17 00:00:00 2001 From: Felipe Elia Date: Mon, 12 Jun 2023 13:33:31 -0300 Subject: [PATCH] Ensure get_elasticsearch_error_reason returns a string --- includes/utils.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/includes/utils.php b/includes/utils.php index e9aed09df8..41a20a0016 100644 --- a/includes/utils.php +++ b/includes/utils.php @@ -805,15 +805,15 @@ function get_elasticsearch_error_reason( $response ) : string { } if ( ! empty( $response['reason'] ) ) { - return $response['reason']; + return (string) $response['reason']; } if ( ! empty( $response['result']['error'] ) && ! empty( $response['result']['error']['root_cause'][0]['reason'] ) ) { - return $response['result']['error']['root_cause'][0]['reason']; + return (string) $response['result']['error']['root_cause'][0]['reason']; } if ( ! empty( $response['result']['errors'] ) && ! empty( $response['result']['items'] ) && ! empty( $response['result']['items'][0]['index']['error']['reason'] ) ) { - return $response['result']['items'][0]['index']['error']['reason']; + return (string) $response['result']['items'][0]['index']['error']['reason']; } return '';