Commit 14c4d09bb6 for woocommerce
commit 14c4d09bb6aaea24aa19dde9a988edf3abec935f
Author: Augusto Bennemann <augusto@augusto.dev>
Date: Thu Feb 19 20:32:31 2026 -0300
Fix undefined property warnings with HPOS Data Caching enabled (#63295)
* Add property_exists() guard in set_order_props_from_data
* Add changefile(s) from automation for the following project(s): woocommerce
* Add is_string() guard to fix PHPStan failure
PHPStan flags property_exists() because the column mapping
type annotations allow $prop_details['name'] to be an array.
Adding is_string() narrows the type for static analysis.
---------
Co-authored-by: woocommercebot <woocommercebot@users.noreply.github.com>
Co-authored-by: Brandon Kraft <public@brandonkraft.com>
diff --git a/plugins/woocommerce/changelog/63295-fix_recorded_sales_warning b/plugins/woocommerce/changelog/63295-fix_recorded_sales_warning
new file mode 100644
index 0000000000..086bff0a9e
--- /dev/null
+++ b/plugins/woocommerce/changelog/63295-fix_recorded_sales_warning
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+
+Fix PHP "Undefined property" warnings in `set_order_props_from_data` when HPOS Data Caching is enabled and cached objects have missing properties.
\ No newline at end of file
diff --git a/plugins/woocommerce/src/Internal/DataStores/Orders/OrdersTableDataStore.php b/plugins/woocommerce/src/Internal/DataStores/Orders/OrdersTableDataStore.php
index e1065eac62..12de72fd3d 100644
--- a/plugins/woocommerce/src/Internal/DataStores/Orders/OrdersTableDataStore.php
+++ b/plugins/woocommerce/src/Internal/DataStores/Orders/OrdersTableDataStore.php
@@ -1764,7 +1764,10 @@ WHERE
protected function set_order_props_from_data( &$order, $order_data ) {
foreach ( $this->get_all_order_column_mappings() as $table_name => $column_mapping ) {
foreach ( $column_mapping as $column_name => $prop_details ) {
- if ( ! isset( $prop_details['name'] ) ) {
+ if ( ! isset( $prop_details['name'] ) || ! is_string( $prop_details['name'] ) ) {
+ continue;
+ }
+ if ( ! property_exists( $order_data, $prop_details['name'] ) ) {
continue;
}
$prop_value = $order_data->{$prop_details['name']};