Commit e60420cecb for woocommerce

commit e60420cecbb6572d7b02c60b3cf91633f32f5646
Author: Lucio Giannotta <lucio.giannotta@a8c.com>
Date:   Thu Dec 4 09:31:49 2025 -0500

    Fix undefined property warnings in `add_crumbs_category()` (#62210)

    * Fix undefined property warnings in add_crumbs_category()

    Handle the case where get_category() returns WP_Error instead of
    a category object. This prevents PHP warnings for undefined properties
    'parent' and 'term_id' on WP_Error objects when category data is
    unavailable (e.g., deleted category, database issues).

diff --git a/plugins/woocommerce/changelog/62210-wooplug-5928-undefined-property-wp_errorparent-in-includesclass-wc b/plugins/woocommerce/changelog/62210-wooplug-5928-undefined-property-wp_errorparent-in-includesclass-wc
new file mode 100644
index 0000000000..36004b4847
--- /dev/null
+++ b/plugins/woocommerce/changelog/62210-wooplug-5928-undefined-property-wp_errorparent-in-includesclass-wc
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+
+Fixes breadcrumbs sometimes throwing errors when categories inconsistencies happened in the Database.
\ No newline at end of file
diff --git a/plugins/woocommerce/includes/class-wc-breadcrumb.php b/plugins/woocommerce/includes/class-wc-breadcrumb.php
index 7a30bd58ac..f6f6a938b3 100644
--- a/plugins/woocommerce/includes/class-wc-breadcrumb.php
+++ b/plugins/woocommerce/includes/class-wc-breadcrumb.php
@@ -266,6 +266,10 @@ class WC_Breadcrumb {
 	protected function add_crumbs_category() {
 		$this_category = get_category( $GLOBALS['wp_query']->get_queried_object() );

+		if ( is_wp_error( $this_category ) || ! $this_category ) {
+			return;
+		}
+
 		if ( 0 !== intval( $this_category->parent ) ) {
 			$this->term_ancestors( $this_category->term_id, 'category' );
 		}
diff --git a/plugins/woocommerce/phpstan-baseline.neon b/plugins/woocommerce/phpstan-baseline.neon
index 3acf04d8f4..2e16da0c04 100644
--- a/plugins/woocommerce/phpstan-baseline.neon
+++ b/plugins/woocommerce/phpstan-baseline.neon
@@ -15492,24 +15492,12 @@ parameters:
 			count: 1
 			path: includes/class-wc-breadcrumb.php

-		-
-			message: '#^Cannot access property \$parent on WP_Error\|WP_Term\|null\.$#'
-			identifier: property.nonObject
-			count: 1
-			path: includes/class-wc-breadcrumb.php
-
 		-
 			message: '#^Cannot access property \$post_parent on WP_Post\|null\.$#'
 			identifier: property.nonObject
 			count: 1
 			path: includes/class-wc-breadcrumb.php

-		-
-			message: '#^Cannot access property \$term_id on WP_Error\|WP_Term\|null\.$#'
-			identifier: property.nonObject
-			count: 2
-			path: includes/class-wc-breadcrumb.php
-
 		-
 			message: '#^Cannot call method get_queried_object\(\) on mixed\.$#'
 			identifier: method.nonObject