From b578dfaeb01c9315150f92038a40b1a0d5a20efe Mon Sep 17 00:00:00 2001 From: dwindown Date: Wed, 5 Nov 2025 23:35:09 +0700 Subject: [PATCH] fix: Apply same cache flush fix to save_gateway endpoint MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ✅ Toggle Working: 156ms + 57ms (PERFECT!) Log Analysis: - Toggling gateway tripay_briva to enabled ✅ - Current enabled: no, New enabled: yes ✅ - update_option returned: true ✅ - Set gateway->enabled to: yes ✅ - Gateway after toggle: enabled=true ✅ - Total time: 156ms (toggle) + 57ms (refetch) = 213ms 🚀 The Fix That Worked: 1. Update $gateway->settings array 2. Update $gateway->enabled property (THIS WAS THE KEY!) 3. Save to database 4. Clear cache 5. Force gateway reload Now Applying Same Fix to Modal Save: - Added wp_cache_flush() before fetching updated gateway - Added debug logging to track save process - Same pattern as toggle endpoint Expected Result: - Modal settings save should now persist - Changes should appear immediately after save - Fast performance (1-2 seconds instead of 30s) Files Modified: - PaymentsController.php: save_gateway() endpoint Next: Test modal save and confirm it works! --- includes/Api/PaymentsController.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/includes/Api/PaymentsController.php b/includes/Api/PaymentsController.php index 9e9523e..823ea93 100644 --- a/includes/Api/PaymentsController.php +++ b/includes/Api/PaymentsController.php @@ -175,21 +175,32 @@ class PaymentsController extends WP_REST_Controller { } try { + // Debug: Log what we're saving + error_log(sprintf('[WooNooW] Saving gateway %s settings: %s', $gateway_id, json_encode($settings))); + $result = PaymentGatewaysProvider::save_gateway_settings($gateway_id, $settings); if (is_wp_error($result)) { + error_log(sprintf('[WooNooW] Save failed: %s', $result->get_error_message())); return $result; } - // Return updated gateway data + // Clear cache before fetching updated gateway + wp_cache_flush(); + + // Return updated gateway data (fresh from DB) $gateway = PaymentGatewaysProvider::get_gateway($gateway_id); + // Debug: Log success + error_log(sprintf('[WooNooW] Gateway %s settings saved successfully', $gateway_id)); + return rest_ensure_response([ 'success' => true, 'message' => 'Gateway settings saved successfully', 'gateway' => $gateway, ]); } catch (\Exception $e) { + error_log(sprintf('[WooNooW] Save exception: %s', $e->getMessage())); return new WP_Error( 'save_gateway_failed', $e->getMessage(),