docs: Update Status.md with scheduled sync persistence fix
Some checks failed
HVAC Plugin CI/CD Pipeline / Code Quality & Standards (push) Has been cancelled
HVAC Plugin CI/CD Pipeline / Unit Tests (push) Has been cancelled
HVAC Plugin CI/CD Pipeline / Security Analysis (push) Has been cancelled
HVAC Plugin CI/CD Pipeline / Integration Tests (push) Has been cancelled
HVAC Plugin CI/CD Pipeline / Deploy to Staging (push) Has been cancelled
HVAC Plugin CI/CD Pipeline / Deploy to Production (push) Has been cancelled
HVAC Plugin CI/CD Pipeline / Notification (push) Has been cancelled

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
ben 2025-12-20 09:41:24 -04:00
parent 4fc6676e0c
commit 6d4bdc2f95

169
Status.md
View file

@ -1,55 +1,148 @@
# HVAC Community Events - Project Status # HVAC Community Events - Project Status
**Last Updated:** December 16, 2025 **Last Updated:** December 20, 2025
**Current Session:** Gemini Development Transition & PHP 8+ Validation **Current Session:** Scheduled Sync Persistence Fix - Complete
**Version:** 2.1.7 (Staging) **Version:** 2.1.11 (Deployed to Production)
--- ---
## 🎯 CURRENT SESSION - ZOHO CRM INTEGRATION SETUP (Dec 16, 2025) ## 🎯 CURRENT SESSION - SCHEDULED SYNC PERSISTENCE FIX (Dec 20, 2025)
### Zoho CRM Integration - Production Issue (BLOCKING) ### Status: ✅ **COMPLETE - Deployed to Production**
**Objective:** Configure and test Zoho CRM sync implementation for production environment. **Problem:** Scheduled sync showed "Not Scheduled" after page refresh, even though settings were saved correctly.
**Status:** 🔴 BLOCKING - Credential save hangs on production (400 Bad Request) **Root Cause:**
- `HVAC_Zoho_Scheduled_Sync` was only loaded in admin context
- On non-admin requests (including WP-Cron), custom cron schedules weren't registered
- WordPress was clearing cron events because it didn't recognize the schedules
### Active Issue - Credential Save Hanging on Production ### Fixes Applied
1. ✅ **Load Scheduled Sync on ALL Requests** (`class-hvac-plugin.php`)
- Moved `HVAC_Zoho_Scheduled_Sync::instance()` initialization to main plugin loader
- Now loads alongside other schedulers (like Communication Scheduler)
- Ensures cron schedules and action hooks are always registered
**Problem:** When saving Zoho CRM credentials at `https://upskillhvac.com/wp-admin/admin.php?page=hvac-zoho-sync`, the AJAX request returns a 400 Bad Request error and the form hangs on "Saving...". 2. ✅ **Add `add_option` Hook** (`class-zoho-scheduled-sync.php`)
- Added `add_option_hvac_zoho_auto_sync` hook for first-time setting creation
- WordPress fires `add_option_` (not `update_option_`) on first save
**Console Error:** 3. ✅ **Explicit Scheduling in Save** (`class-zoho-admin.php`)
``` - `save_settings()` now explicitly calls `schedule_sync()` or `unschedule_sync()`
POST https://upskillhvac.com/wp-admin/admin-ajax.php 400 (Bad Request) - Ensures scheduling works even when option value hasn't changed
``` - `update_option_` hook only fires when value actually changes
**Investigation Completed:** ### Files Modified
1. ✅ Fixed Client ID regex to allow lowercase letters (`[A-Z0-9]` → `[A-Za-z0-9]`) - `includes/class-hvac-plugin.php` - Load scheduled sync globally
2. ✅ Fixed credential storage mismatch - all methods now use `HVAC_Secure_Storage` - `includes/zoho/class-zoho-scheduled-sync.php` - Add first-time option hook
3. ✅ Updated `HVAC_Zoho_CRM_Auth` class to use encrypted storage consistently - `includes/admin/class-zoho-admin.php` - Explicit scheduling call
4. ✅ Updated OAuth callback to use secure storage
5. ✅ Updated test_connection to use secure storage
6. ✅ Deployed fixes to production - **Issue persists**
**Files Modified:**
- `includes/admin/class-zoho-admin.php` - Secure storage for credentials, fixed regex
- `includes/zoho/class-zoho-crm-auth.php` - All credential operations use HVAC_Secure_Storage
**Next Steps for Investigation:**
1. Check PHP error logs on production server for detailed error
2. Test AJAX endpoint directly via curl to isolate frontend vs backend issue
3. Verify nonce generation and validation on production
4. Check if WAF/security plugin is blocking the request
5. Test with browser network tab to see exact request/response
**Possible Causes:**
- Server-side security rules (Cloudflare, ModSecurity) blocking POST to admin-ajax.php
- Nonce validation failing due to caching
- Plugin conflict on production
- HVAC_Secure_Storage encryption key difference between environments
--- ---
## 📋 PREVIOUS SESSION - SCHEDULED ZOHO SYNC (Dec 19, 2025)
### Status: ✅ **COMPLETE - WP-Cron Scheduled Sync Implemented**
**Summary:**
- **Scheduled Sync:** WP-Cron job syncs new/modified records on configurable interval
- **Incremental Sync:** Only syncs records modified since last sync run
- **Admin UI:** Enable/disable toggle, interval selector (5min-daily), status display
- **Manual Trigger:** "Run Sync Now" button for testing
### Changes Made
1. ✅ **New File: `class-zoho-scheduled-sync.php`**
- WP-Cron management with custom intervals
- `run_scheduled_sync()` processes all data types
- Tracks last sync time for incremental filtering
- Stores results for status display
2. ✅ **Updated `class-zoho-sync.php`**
- All 5 sync methods now accept `$since_timestamp` parameter
- When provided, filters queries by `post_modified >= since_date`
3. ✅ **Updated `class-zoho-admin.php`**
- Added `save_settings()` AJAX handler
- Added `run_scheduled_sync_now()` AJAX handler
- Enhanced admin UI with new intervals and status display
4. ✅ **Updated `zoho-admin.js`**
- Settings form reloads page on save
- "Run Sync Now" button with result display
### Interval Options
| Value | Frequency |
|-------|-----------|
| `every_5_minutes` | Every 5 minutes (default) |
| `every_15_minutes` | Every 15 minutes |
| `every_30_minutes` | Every 30 minutes |
| `hourly` | Hourly |
| `every_6_hours` | Every 6 hours |
| `daily` | Daily |
### Admin Page Location
- `/wp-admin/admin.php?page=hvac-zoho-sync`
- Look for "Scheduled Sync Settings" section
---
## 📋 PREVIOUS SESSION - BATCH SYNC ENHANCEMENT (Dec 18, 2025)
### Status: ✅ **COMPLETE - All Sync Tasks Now Auto-Iterate with Progress Bar**
**Summary:**
- **All 5 Sync Types:** Now support batch pagination with auto-continue
- **Progress Bar:** Visual feedback showing `X of Y processed (N%)`
- **No Manual Repeating:** Frontend auto-loops until `has_more: false`
- **Orphan Cleanup:** Deleted 14 test attendees referencing deleted events
### Changes Made
1. ✅ **Backend Pagination:**
- All sync methods (`sync_events`, `sync_users`, `sync_attendees`, `sync_rsvps`, `sync_purchases`) now accept `$offset` and `$limit` parameters
- Each returns `has_more`, `next_offset`, and `total` for pagination
- Admin endpoint updated to pass offset to sync methods
2. ✅ **Frontend Progress UI:**
- New `syncWithProgress()` function replaces single AJAX calls
- Auto-continues batches until complete
- Progress bar shows percentage and count
- Accumulated results across all batches
### Files Modified
- `includes/zoho/class-zoho-sync.php` - Pagination for all 5 sync methods
- `includes/admin/class-zoho-admin.php` - Offset parameter handling
- `assets/js/zoho-admin.js` - Progress bar + auto-continue logic
---
## 📋 PREVIOUS SESSION - ZOHO CRM ATTENDEE SYNC (Dec 17-18, 2025)
### Status: ✅ **COMPLETE - All Attendees Syncing Successfully**
**Summary:**
- **Events Sync:** ✅ WORKING. 39 events synced with enhanced field mapping.
- **Attendees Sync:** ✅ WORKING. 50/50 synced, 0 errors, all contacts updated with custom fields.
### Issues Resolved
1. ✅ **Campaign Member Linking:**
- Fixed API endpoint: `PUT /Contacts/{id}/Campaigns` (was `/Campaigns/{id}/Contacts/{id}`)
- Fixed `log_debug()` visibility (private → public)
2. ✅ **Attendee Field Mapping:**
- measureQuick Email → `Email` (primary, used for lookup)
- Attendee Email → `Secondary_Email`
- Attendee Cell Phone → `Mobile`
- Company Role → `Primary_Role`
- Fixed meta key: `_tec_tickets_commerce_attendee_fields` with hyphenated field names
3. ✅ **Email Fallback Logic:**
- If attendee email empty, use measureQuick email (and vice versa)
- Only fails if BOTH emails are empty
4. ✅ **DUPLICATE_DATA Handling:**
- When Zoho returns "duplicate exists", extract existing contact ID from error
- Use that ID to update instead of failing
5. ✅ **Existing Contact Updates:**
- Existing contacts now updated via PUT with new field data on each sync
---
### Zoho CRM Integration - Staging Environment (Working) ### Zoho CRM Integration - Staging Environment (Working)
**Status:** ✅ OAuth Working, Sync Methods Implemented, Dry-Run Tested **Status:** ✅ OAuth Working, Sync Methods Implemented, Dry-Run Tested
@ -242,7 +335,7 @@ DISPLAY=:1 HEADLESS=false node test-comprehensive-validation.js
### Production Environment ### Production Environment
**URL:** https://upskillhvac.com **URL:** https://upskillhvac.com
**Version:** 2.1.7 (pending deployment) **Version:** 2.1.8 (latest)
**Server:** Cloudways Shared VPS **Server:** Cloudways Shared VPS
--- ---