From 9a6005a355cb9a70e3eb0e8627a2383f0513ab5e Mon Sep 17 00:00:00 2001 From: "Jorge A. Torres" Date: Mon, 12 Jun 2023 16:04:30 -0300 Subject: [PATCH 1/3] Cast partial refund related data in report to float before operating on it --- .../includes/admin/reports/class-wc-report-sales-by-date.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/woocommerce/includes/admin/reports/class-wc-report-sales-by-date.php b/plugins/woocommerce/includes/admin/reports/class-wc-report-sales-by-date.php index 709bc465fc2..69b60ddbcc9 100644 --- a/plugins/woocommerce/includes/admin/reports/class-wc-report-sales-by-date.php +++ b/plugins/woocommerce/includes/admin/reports/class-wc-report-sales-by-date.php @@ -326,7 +326,7 @@ class WC_Report_Sales_By_Date extends WC_Admin_Report { ); foreach ( $this->report_data->partial_refunds as $key => $order ) { - $this->report_data->partial_refunds[ $key ]->net_refund = $order->total_refund - ( $order->total_shipping + $order->total_tax + $order->total_shipping_tax ); + $this->report_data->partial_refunds[ $key ]->net_refund = (float) $order->total_refund - ( (float) $order->total_shipping + (float) $order->total_tax + (float) $order->total_shipping_tax ); } /** From eb3082e835af1bd99fadb50bab7c4ca16989c480 Mon Sep 17 00:00:00 2001 From: "Jorge A. Torres" Date: Mon, 12 Jun 2023 16:05:04 -0300 Subject: [PATCH 2/3] Address possible PHP warning in report code --- .../includes/admin/reports/class-wc-admin-report.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/woocommerce/includes/admin/reports/class-wc-admin-report.php b/plugins/woocommerce/includes/admin/reports/class-wc-admin-report.php index 4998d53ca58..bc1f7837cc7 100644 --- a/plugins/woocommerce/includes/admin/reports/class-wc-admin-report.php +++ b/plugins/woocommerce/includes/admin/reports/class-wc-admin-report.php @@ -512,7 +512,7 @@ class WC_Admin_Report { } if ( $data_key ) { - $prepared_data[ $time ][1] += $d->$data_key; + $prepared_data[ $time ][1] += is_numeric( $d->$data_key ) ? $d->$data_key : 0; } else { $prepared_data[ $time ][1] ++; } From 02e71e8c4bac956f5df073d846bbb26986bb474f Mon Sep 17 00:00:00 2001 From: "Jorge A. Torres" Date: Mon, 12 Jun 2023 16:05:07 -0300 Subject: [PATCH 3/3] Add changelog --- plugins/woocommerce/changelog/fix-34118 | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 plugins/woocommerce/changelog/fix-34118 diff --git a/plugins/woocommerce/changelog/fix-34118 b/plugins/woocommerce/changelog/fix-34118 new file mode 100644 index 00000000000..00cdf3fdc9a --- /dev/null +++ b/plugins/woocommerce/changelog/fix-34118 @@ -0,0 +1,4 @@ +Significance: patch +Type: fix + +Handle possibly empty refund value in reports (PHP 8.1+).