Commit 6e75a67af86 for woocommerce

commit 6e75a67af863cc1cbbcc1e2567642d5bdc9e7e58
Author: Michal Iwanow <4765119+mcliwanow@users.noreply.github.com>
Date:   Wed Nov 4 13:45:44 2026 +0100

    Read payments settings profile data as stored (#70628)

    WordPress already decodes values from get_option() and get_user_meta(), so drop the second decode and treat a profile that is not an array as empty.

    Co-authored-by: Luigi Teschio <4463174+gigitux@users.noreply.github.com>

diff --git a/plugins/woocommerce/changelog/fix-payments-profile-data-handling b/plugins/woocommerce/changelog/fix-payments-profile-data-handling
new file mode 100644
index 00000000000..8953d792cd9
--- /dev/null
+++ b/plugins/woocommerce/changelog/fix-payments-profile-data-handling
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+
+Improve handling of unexpected payment settings profile data.
diff --git a/plugins/woocommerce/src/Internal/Admin/Settings/Payments.php b/plugins/woocommerce/src/Internal/Admin/Settings/Payments.php
index 061531911da..0b9c1e25189 100644
--- a/plugins/woocommerce/src/Internal/Admin/Settings/Payments.php
+++ b/plugins/woocommerce/src/Internal/Admin/Settings/Payments.php
@@ -254,7 +254,7 @@ class Payments {
 	 */
 	public function get_country(): string {
 		$user_nox_meta = get_user_meta( get_current_user_id(), self::PAYMENTS_NOX_PROFILE_KEY, true );
-		if ( ! empty( $user_nox_meta['business_country_code'] ) ) {
+		if ( is_array( $user_nox_meta ) && ! empty( $user_nox_meta['business_country_code'] ) ) {
 			return $user_nox_meta['business_country_code'];
 		}

@@ -271,10 +271,8 @@ class Payments {

 		$user_payments_nox_profile = get_user_meta( get_current_user_id(), self::PAYMENTS_NOX_PROFILE_KEY, true );

-		if ( empty( $user_payments_nox_profile ) ) {
+		if ( ! is_array( $user_payments_nox_profile ) ) {
 			$user_payments_nox_profile = array();
-		} else {
-			$user_payments_nox_profile = maybe_unserialize( $user_payments_nox_profile );
 		}
 		$user_payments_nox_profile['business_country_code'] = $location;

diff --git a/plugins/woocommerce/src/Internal/Admin/Settings/PaymentsProviders.php b/plugins/woocommerce/src/Internal/Admin/Settings/PaymentsProviders.php
index ae20c434c28..1a6a7a4d928 100644
--- a/plugins/woocommerce/src/Internal/Admin/Settings/PaymentsProviders.php
+++ b/plugins/woocommerce/src/Internal/Admin/Settings/PaymentsProviders.php
@@ -893,10 +893,8 @@ class PaymentsProviders {
 		}

 		$payments_nox_profile = get_option( Payments::PAYMENTS_NOX_PROFILE_KEY, array() );
-		if ( empty( $payments_nox_profile ) ) {
+		if ( ! is_array( $payments_nox_profile ) ) {
 			$payments_nox_profile = array();
-		} else {
-			$payments_nox_profile = maybe_unserialize( $payments_nox_profile );
 		}

 		// Check if it is already marked as attached.
@@ -960,10 +958,8 @@ class PaymentsProviders {
 		}

 		$user_payments_nox_profile = get_user_meta( get_current_user_id(), Payments::PAYMENTS_NOX_PROFILE_KEY, true );
-		if ( empty( $user_payments_nox_profile ) ) {
+		if ( ! is_array( $user_payments_nox_profile ) ) {
 			$user_payments_nox_profile = array();
-		} else {
-			$user_payments_nox_profile = maybe_unserialize( $user_payments_nox_profile );
 		}

 		// Mark the suggestion as hidden.
@@ -1573,12 +1569,7 @@ class PaymentsProviders {
 	 */
 	private function is_payment_extension_suggestion_hidden( array $extension ): bool {
 		$user_payments_nox_profile = get_user_meta( get_current_user_id(), Payments::PAYMENTS_NOX_PROFILE_KEY, true );
-		if ( empty( $user_payments_nox_profile ) ) {
-			return false;
-		}
-		$user_payments_nox_profile = maybe_unserialize( $user_payments_nox_profile );
-
-		if ( empty( $user_payments_nox_profile['hidden_suggestions'] ) ) {
+		if ( ! is_array( $user_payments_nox_profile ) || empty( $user_payments_nox_profile['hidden_suggestions'] ) ) {
 			return false;
 		}