Commit f56dae55667 for woocommerce
commit f56dae556677a25295e3ed50389fcc348df5a670
Author: Robert Felty <robert.felty@automattic.com>
Date: Mon Apr 13 04:29:31 2026 -0600
Fix fatal error with product attributes (#63953)
* Fix fatal error with product attributes
* Fixed indentation
* code review suggestion
* Update plugins/woocommerce/includes/wc-attribute-functions.php
Co-authored-by: Michael Pretty <prettyboymp@users.noreply.github.com>
* Added changelog
* fixed linting
---------
Co-authored-by: Michael Pretty <prettyboymp@users.noreply.github.com>
diff --git a/plugins/woocommerce/changelog/fix-wc-get-attribute-text b/plugins/woocommerce/changelog/fix-wc-get-attribute-text
new file mode 100644
index 00000000000..1d57ac8a301
--- /dev/null
+++ b/plugins/woocommerce/changelog/fix-wc-get-attribute-text
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+
+Prevent fatal error when product attribute data is malformed
diff --git a/plugins/woocommerce/includes/wc-attribute-functions.php b/plugins/woocommerce/includes/wc-attribute-functions.php
index 469a8f63883..cb043264cce 100644
--- a/plugins/woocommerce/includes/wc-attribute-functions.php
+++ b/plugins/woocommerce/includes/wc-attribute-functions.php
@@ -18,6 +18,9 @@ defined( 'ABSPATH' ) || exit;
* @return array
*/
function wc_get_text_attributes( $raw_attributes ) {
+ if ( ! is_string( $raw_attributes ) ) {
+ return array();
+ }
return array_filter( array_map( 'trim', explode( WC_DELIMITER, html_entity_decode( $raw_attributes, ENT_QUOTES, get_bloginfo( 'charset' ) ) ) ), 'wc_get_text_attributes_filter_callback' );
}