From 35b7aeb6993c49815d6c90531789b4494ff7fd47 Mon Sep 17 00:00:00 2001 From: Ilja Zaglov Date: Sun, 6 Oct 2024 14:09:43 +0200 Subject: [PATCH] Fix: Warning thrown in HttpClient if $errors is an empty array Added an additional check to prevent warnings thrown in HttpClient if the $errors array is empty. --- src/WooCommerce/HttpClient/HttpClient.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/WooCommerce/HttpClient/HttpClient.php b/src/WooCommerce/HttpClient/HttpClient.php index f811324..72c2911 100644 --- a/src/WooCommerce/HttpClient/HttpClient.php +++ b/src/WooCommerce/HttpClient/HttpClient.php @@ -372,7 +372,7 @@ protected function lookForErrors($parsedResponse) $errorMessage = ''; $errorCode = ''; - if (is_array($errors)) { + if (is_array($errors) && !empty($errors)) { $errorMessage = $errors[0]->message; $errorCode = $errors[0]->code; } elseif (isset($errors->message, $errors->code)) {