From 0d83c6a7c259c78ed2040d6545434e9d3f6f279a Mon Sep 17 00:00:00 2001 From: Ron Rennick Date: Fri, 6 Nov 2020 14:51:45 -0400 Subject: [PATCH] handle non-existent settings --- .../includes/class-wc-beta-tester-import-export.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/plugins/woocommerce-beta-tester/includes/class-wc-beta-tester-import-export.php b/plugins/woocommerce-beta-tester/includes/class-wc-beta-tester-import-export.php index d0bc8a354e8..0f1a68902d1 100644 --- a/plugins/woocommerce-beta-tester/includes/class-wc-beta-tester-import-export.php +++ b/plugins/woocommerce-beta-tester/includes/class-wc-beta-tester-import-export.php @@ -153,7 +153,11 @@ class WC_Beta_Tester_Import_Export { continue; } $setting = maybe_unserialize( $settings[ $option_name ] ); - update_option( $option_name, $setting ); + if ( is_null( $setting ) ) { + delete_option( $option_name ); + } else { + update_option( $option_name, $setting ); + } } $this->add_message( __( 'Settings Imported', 'woocommerce-beta-tester' ), 'updated' ); } else { @@ -175,6 +179,9 @@ class WC_Beta_Tester_Import_Export { if ( current_user_can( 'manage_woocommerce' ) ) { foreach ( $this->get_setting_list() as $option_name ) { $setting = get_option( $option_name ); + if ( false === $setting ) { + $setting = null; + } $settings[ $option_name ] = is_string( $setting ) ? $setting : serialize( $setting ); } }