From c0424210ab62e68f11d50a8e62358a8fab0bdd90 Mon Sep 17 00:00:00 2001 From: louwie17 Date: Wed, 17 Apr 2024 07:05:34 -0300 Subject: [PATCH] Add safety check for rare fatal case with subscription note (#46472) * Add safety check for rare fatal case * Change to is_object check --- plugins/woocommerce/changelog/fix-32216 | 4 ++++ .../src/Internal/Admin/Notes/WooSubscriptionsNotes.php | 3 +++ 2 files changed, 7 insertions(+) create mode 100644 plugins/woocommerce/changelog/fix-32216 diff --git a/plugins/woocommerce/changelog/fix-32216 b/plugins/woocommerce/changelog/fix-32216 new file mode 100644 index 00000000000..40ef4980b7d --- /dev/null +++ b/plugins/woocommerce/changelog/fix-32216 @@ -0,0 +1,4 @@ +Significance: patch +Type: fix + +Add safety check to prevent rare occurences of a fatal in WooSubscriptionsNotes diff --git a/plugins/woocommerce/src/Internal/Admin/Notes/WooSubscriptionsNotes.php b/plugins/woocommerce/src/Internal/Admin/Notes/WooSubscriptionsNotes.php index e3e4e4aabb0..58b389f28c4 100644 --- a/plugins/woocommerce/src/Internal/Admin/Notes/WooSubscriptionsNotes.php +++ b/plugins/woocommerce/src/Internal/Admin/Notes/WooSubscriptionsNotes.php @@ -221,6 +221,9 @@ class WooSubscriptionsNotes { * @return int|false */ public function get_product_id_from_subscription_note( &$note ) { + if ( ! is_object( $note ) ) { + return false; + } $content_data = $note->get_content_data(); if ( property_exists( $content_data, 'product_id' ) ) {