diff --git a/plugins/woocommerce/changelog/fix-comparison-operator-strpos-and-remote-payment-suggestions b/plugins/woocommerce/changelog/fix-comparison-operator-strpos-and-remote-payment-suggestions new file mode 100644 index 0000000000000..91c28afdaf7eb --- /dev/null +++ b/plugins/woocommerce/changelog/fix-comparison-operator-strpos-and-remote-payment-suggestions @@ -0,0 +1,4 @@ +Significance: patch +Type: fix + +Fix strpos php8 compliant and payment gateway recommendation rule default value diff --git a/plugins/woocommerce/src/Admin/Features/PaymentGatewaySuggestions/DefaultPaymentGateways.php b/plugins/woocommerce/src/Admin/Features/PaymentGatewaySuggestions/DefaultPaymentGateways.php index 09af178d1e015..1d5426c91c1b7 100644 --- a/plugins/woocommerce/src/Admin/Features/PaymentGatewaySuggestions/DefaultPaymentGateways.php +++ b/plugins/woocommerce/src/Admin/Features/PaymentGatewaySuggestions/DefaultPaymentGateways.php @@ -968,7 +968,7 @@ public static function get_rules_selling_offline() { 'option_name' => 'woocommerce_onboarding_profile', 'operation' => 'in', 'value' => array( 'no_im_selling_offline', 'im_selling_both_online_and_offline' ), - 'default' => array(), + 'default' => '', ); } diff --git a/plugins/woocommerce/src/Admin/RemoteInboxNotifications/ComparisonOperation.php b/plugins/woocommerce/src/Admin/RemoteInboxNotifications/ComparisonOperation.php index 82caffb187dc5..501a32a875ce6 100644 --- a/plugins/woocommerce/src/Admin/RemoteInboxNotifications/ComparisonOperation.php +++ b/plugins/woocommerce/src/Admin/RemoteInboxNotifications/ComparisonOperation.php @@ -36,22 +36,34 @@ public static function compare( $left_operand, $right_operand, $operation ) { if ( is_array( $left_operand ) && is_string( $right_operand ) ) { return in_array( $right_operand, $left_operand, true ); } - return strpos( $right_operand, $left_operand ) !== false; + if ( is_string( $right_operand ) && is_string( $left_operand ) ) { + return strpos( $right_operand, $left_operand ) !== false; + } + break; case '!contains': if ( is_array( $left_operand ) && is_string( $right_operand ) ) { return ! in_array( $right_operand, $left_operand, true ); } - return strpos( $right_operand, $left_operand ) === false; + if ( is_string( $right_operand ) && is_string( $left_operand ) ) { + return strpos( $right_operand, $left_operand ) === false; + } + break; case 'in': if ( is_array( $right_operand ) && is_string( $left_operand ) ) { return in_array( $left_operand, $right_operand, true ); } - return strpos( $left_operand, $right_operand ) !== false; + if ( is_string( $left_operand ) && is_string( $right_operand ) ) { + return strpos( $left_operand, $right_operand ) !== false; + } + break; case '!in': if ( is_array( $right_operand ) && is_string( $left_operand ) ) { return ! in_array( $left_operand, $right_operand, true ); } - return strpos( $left_operand, $right_operand ) === false; + if ( is_string( $left_operand ) && is_string( $right_operand ) ) { + return strpos( $left_operand, $right_operand ) === false; + } + break; } return false;