From 92b8f9707c201d098c152b64591261a4fe49339f Mon Sep 17 00:00:00 2001 From: bengizmo Date: Thu, 24 Jul 2025 16:00:31 -0300 Subject: [PATCH] fix: Remove all remaining Zoho debug log statements MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Removed [HVAC Zoho] production/staging detection logs - Removed flush rewrite rules debug logs - Removed test_connection method called log - Removed OAuth token exchange params log - Removed all other error_log statements from Zoho admin This completes the cleanup of production error logs. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- includes/admin/class-zoho-admin.php | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/includes/admin/class-zoho-admin.php b/includes/admin/class-zoho-admin.php index 76bbb874..aca8b594 100644 --- a/includes/admin/class-zoho-admin.php +++ b/includes/admin/class-zoho-admin.php @@ -127,8 +127,6 @@ class HVAC_Zoho_Admin { // Set staging as opposite of production $is_staging = !$is_production; - error_log('[HVAC Zoho] Is Production: ' . ($is_production ? 'YES' : 'NO')); - error_log('[HVAC Zoho] Is Staging: ' . ($is_staging ? 'YES' : 'NO')); // Get stored credentials $client_id = get_option('hvac_zoho_client_id', ''); @@ -500,8 +498,6 @@ class HVAC_Zoho_Admin { $oauth_rule_exists = isset($rewrite_rules['^oauth/callback/?$']) || isset($rewrite_rules['oauth/callback/?$']); // Log for debugging - error_log('[HVAC Zoho] Flush rewrite rules result: ' . ($oauth_rule_exists ? 'SUCCESS' : 'FAILED')); - error_log('[HVAC Zoho] Total rules after flush: ' . count($rewrite_rules)); wp_send_json_success(array( 'message' => 'Rewrite rules flushed successfully', @@ -551,7 +547,6 @@ class HVAC_Zoho_Admin { // Check if we have the code parameter if (isset($_GET['code'])) { - error_log('Processing OAuth callback directly from parse_request'); $this->process_oauth_callback(); exit; } else { @@ -608,7 +603,6 @@ class HVAC_Zoho_Admin { wp_die('OAuth callback missing authorization code'); } - error_log('OAuth callback received with code: ' . substr($_GET['code'], 0, 20) . '...'); // Get credentials from WordPress options $client_id = get_option('hvac_zoho_client_id', ''); @@ -630,7 +624,6 @@ class HVAC_Zoho_Admin { 'code' => $_GET['code'] ); - error_log('OAuth token exchange params: ' . json_encode(array( 'client_id' => substr($client_id, 0, 20) . '...', 'redirect_uri' => $redirect_uri, 'code' => substr($_GET['code'], 0, 20) . '...' @@ -642,7 +635,6 @@ class HVAC_Zoho_Admin { )); if (is_wp_error($response)) { - error_log('OAuth token exchange error: ' . $response->get_error_message()); wp_redirect(admin_url('admin.php?page=hvac-zoho-sync&oauth_error=1&error_msg=' . urlencode($response->get_error_message()))); exit; } @@ -652,7 +644,6 @@ class HVAC_Zoho_Admin { // Check for errors in response if (isset($token_data['error'])) { - error_log('OAuth error: ' . $token_data['error'] . ' - ' . ($token_data['error_description'] ?? '')); wp_redirect(admin_url('admin.php?page=hvac-zoho-sync&oauth_error=1&error_msg=' . urlencode($token_data['error']))); exit; } @@ -670,17 +661,13 @@ class HVAC_Zoho_Admin { // Refresh token might not be returned on subsequent authorizations if (isset($token_data['refresh_token']) && !empty($token_data['refresh_token'])) { update_option('hvac_zoho_refresh_token', $token_data['refresh_token']); - error_log('Refresh token saved successfully'); } else { - error_log('No refresh token in response - checking for existing token'); $existing_refresh = get_option('hvac_zoho_refresh_token'); if (empty($existing_refresh)) { - error_log('WARNING: No refresh token received and no existing token found'); // This is critical - we need a refresh token for long-term access // Store a warning but still complete the flow update_option('hvac_zoho_missing_refresh_token', true); } else { - error_log('Using existing refresh token'); } } @@ -702,7 +689,6 @@ class HVAC_Zoho_Admin { * Test Zoho connection */ public function test_connection() { - error_log('test_connection method called'); try { check_ajax_referer('hvac_zoho_nonce', 'nonce'); @@ -741,7 +727,6 @@ class HVAC_Zoho_Admin { $stored_refresh_token = get_option('hvac_zoho_refresh_token'); if (empty($stored_refresh_token)) { - error_log('No stored refresh token found, triggering OAuth authorization'); $site_url = get_site_url(); $redirect_uri = $site_url . '/oauth/callback'; @@ -780,13 +765,11 @@ class HVAC_Zoho_Admin { require_once HVAC_CE_PLUGIN_DIR . 'includes/zoho/class-zoho-crm-auth.php'; $auth = new HVAC_Zoho_CRM_Auth(); - error_log('Testing API with refresh token: ' . substr($stored_refresh_token, 0, 10) . '...'); // Test API call $response = $auth->make_api_request('/settings/modules', 'GET'); if (is_wp_error($response)) { - error_log('WordPress HTTP error: ' . $response->get_error_message()); wp_send_json_error(array( 'message' => 'API Connection Failed', 'error' => $response->get_error_message(), @@ -796,7 +779,6 @@ class HVAC_Zoho_Admin { } if (isset($response['error'])) { - error_log('Zoho API error: ' . $response['error']); // Check if it's an invalid token error if (strpos($response['error'], 'invalid') !== false || strpos($response['error'], 'expired') !== false) { @@ -859,21 +841,18 @@ class HVAC_Zoho_Admin { ) )); } catch (Exception $e) { - error_log('Exception in test_connection: ' . $e->getMessage() . ' in ' . $e->getFile() . ':' . $e->getLine()); wp_send_json_error(array( 'message' => 'Connection test failed due to exception', 'error' => $e->getMessage(), 'file' => $e->getFile() . ':' . $e->getLine() )); } catch (Error $e) { - error_log('PHP Error in test_connection: ' . $e->getMessage() . ' in ' . $e->getFile() . ':' . $e->getLine()); wp_send_json_error(array( 'message' => 'Connection test failed due to PHP error', 'error' => $e->getMessage(), 'file' => $e->getFile() . ':' . $e->getLine() )); } catch (Throwable $e) { - error_log('Fatal error in test_connection: ' . $e->getMessage() . ' in ' . $e->getFile() . ':' . $e->getLine()); wp_send_json_error(array( 'message' => 'Connection test failed due to fatal error', 'error' => $e->getMessage(),