From b4745ff6728907e440ecd76244b1a216a44c2a63 Mon Sep 17 00:00:00 2001 From: asus Date: Sun, 31 Mar 2024 19:09:22 +0200 Subject: [PATCH] fixed error with option update --- plugins/xtxpatch/php/classes/plgntls_class.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/plugins/xtxpatch/php/classes/plgntls_class.php b/plugins/xtxpatch/php/classes/plgntls_class.php index d10e46d..0d6887b 100644 --- a/plugins/xtxpatch/php/classes/plgntls_class.php +++ b/plugins/xtxpatch/php/classes/plgntls_class.php @@ -1086,19 +1086,22 @@ class Plgntls_xtx { * */ $option_data = get_option($option_name); +error_log("get option safe: " . json_encode($option_data)); $false_serialized = serialize(false); $option_unserialized = @unserialize($option_data); if ($option_unserialized === false && $option_data != $false_serialized) { $ret_option = $option_data; } else { - $ret_option = $options_unserialized; + $ret_option = $option_unserialized; } +error_log("get option safe: " . json_encode($ret_option)); return $ret_option; } public static function update_option_safe($option, $option_data) { +error_log("- inside update option safe"); /* * first init option, in case it was not already * it will returns the option name or false @@ -1109,10 +1112,12 @@ class Plgntls_xtx { if (false === $option_name) { return; } +error_log("update option safe: " . json_encode($option_data)); if (!is_string($option_data)) { $option_data = serialize($option_data); } +error_log("update option safe: " . json_encode($option_data)); update_option($option_name, $option_data); } @@ -1291,15 +1296,17 @@ class Plgntls_xtx { * if nonce passed, call the callback * - with the remaining of the request * - the option name - * - and the option value + * - the option default value + * - and the option default data to have the fields * + $nonce_callback($request, $option_name, $option_data['_default']); */ $option_value = self::get_option_safe($option_name); if (false === $option_value) { self::redirect_menu_referer(); exit; } - $nonce_callback($request, $option_name, $option_value); + $nonce_callback($request, $option_name, $option_value, $option_data['_default']); /* * then redirects @@ -1309,7 +1316,7 @@ class Plgntls_xtx { exit; } - public static function default_handle_admin_post_option($request, $option_name, $option_data) { + public static function default_handle_admin_post_option($request, $option_name, $option_data, $option_default) { /* * in case the option only contains one value, just update it * @@ -1324,7 +1331,7 @@ class Plgntls_xtx { * update each values * */ - foreach ($option_data as $key) { + foreach ($option_default as $key => $value) { if (isset($request[$key])) { $option_data[$key] = $request[$key]; }