Fatal error on 4.18.8 (patch attached)
-
There is a fatal error in
includes/class-wc-gateway-revolut-blocks-support.phpfile. The functionget_optionreturnsfalseif the option does not exist in the database; if you try to runarray_mergeon non-array value, PHP throws a fatal error. Please check your argument types better.Here’s a simple patch:
From e8b898b1423d3573754fb62eb9d41fd11a1b3ac3 Mon Sep 17 00:00:00 2001
From: Aleksandr Yakovlev <keloero@oreolek.me>
Date: Wed, 19 Mar 2025 11:12:27 +0600
Subject: [PATCH] Check type on settings
get_option() returns false if option does not exists, not the
default value; array_merge() fatally breaks on non-array values.
---
...lass-wc-gateway-revolut-blocks-support.php | 20 +++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/includes/class-wc-gateway-revolut-blocks-support.php b/includes/class-wc-gateway-revolut-blocks-support.php
index 48c2543..4b1c4c8 100644
--- a/includes/class-wc-gateway-revolut-blocks-support.php
+++ b/includes/class-wc-gateway-revolut-blocks-support.php
@@ -66,10 +66,22 @@ class WC_Gateway_Revolut_Blocks_Support extends Automattic\WooCommerce\Blocks\Pa
* Initializes the payment gateway
*/
public function initialize() {
- $this->settings = array_merge(
- get_option( 'woocommerce_revolut_cc_settings', array() ),
- get_option( 'woocommerce_revolut_pay_settings', array() ),
- get_option( 'woocommerce_revolut_payment_request_settings', array() )
+ $settings_1 = get_option( 'woocommerce_revolut_cc_settings', array() );
+ if ($settings_1 === false) {
+ $settings_1 = [];
+ }
+ $settings_2 = get_option( 'woocommerce_revolut_pay_settings', array() );
+ if ($settings_2 === false) {
+ $settings_2 = [];
+ }
+ $settings_3 = get_option( 'woocommerce_revolut_payment_request_settings', array() );
+ if ($settings_3 === false) {
+ $settings_3 = [];
+ }
+ $this->settings = array_merge(
+ $settings_1,
+ $settings_2,
+ $settings_3
);
}
--
2.49.0
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
The topic ‘Fatal error on 4.18.8 (patch attached)’ is closed to new replies.